summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-05-14 17:14:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-14 17:14:27 +0000
commit421a40d39ff3e5433e99036522b229af1819398c (patch)
tree6cd3f2fc910f48c9615308a2f3f045769a32bdc7
parent5f80ef2d019aa66d585cf14d92ef340534a453ed (diff)
parent02baa79e1f75f4c0cc9633d2e634a191321be316 (diff)
downloadandroid_packages_apps_Trebuchet-421a40d39ff3e5433e99036522b229af1819398c.tar.gz
android_packages_apps_Trebuchet-421a40d39ff3e5433e99036522b229af1819398c.tar.bz2
android_packages_apps_Trebuchet-421a40d39ff3e5433e99036522b229af1819398c.zip
Merge "Fixing issue where the prediction bar could be misplaced after installing an app." into ub-launcher3-burnaby
-rw-r--r--src/com/android/launcher3/AppsContainerRecyclerView.java39
-rw-r--r--src/com/android/launcher3/AppsContainerView.java8
2 files changed, 36 insertions, 11 deletions
diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java
index 3952923af..34e621a46 100644
--- a/src/com/android/launcher3/AppsContainerRecyclerView.java
+++ b/src/com/android/launcher3/AppsContainerRecyclerView.java
@@ -120,6 +120,24 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView {
mApps = apps;
}
+ @Override
+ public void setAdapter(Adapter adapter) {
+ // Register a change listener to update the scroll position state whenever the data set
+ // changes.
+ adapter.registerAdapterDataObserver(new AdapterDataObserver() {
+ @Override
+ public void onChanged() {
+ post(new Runnable() {
+ @Override
+ public void run() {
+ refreshCurScrollPosition();
+ }
+ });
+ }
+ });
+ super.setAdapter(adapter);
+ }
+
/**
* Sets the number of apps per row in this recycler view.
*/
@@ -369,13 +387,7 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView {
}
// We need to workaround the RecyclerView to get the right scroll position
- List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
- getCurScrollState(mScrollPosState, items);
- if (mScrollPosState.rowIndex != -1) {
- int scrollY = getPaddingTop() + (mScrollPosState.rowIndex * mScrollPosState.rowHeight) +
- mPredictionBarHeight - mScrollPosState.rowTopOffset;
- updateScrollY(scrollY);
- }
+ refreshCurScrollPosition();
// Scroll to the view at the position, anchored at the top of the screen. We call the scroll
// method on the LayoutManager directly since it is not exposed by RecyclerView.
@@ -465,6 +477,19 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView {
}
/**
+ * Forces a refresh of the scroll position to any scroll listener.
+ */
+ private void refreshCurScrollPosition() {
+ List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
+ getCurScrollState(mScrollPosState, items);
+ if (mScrollPosState.rowIndex != -1) {
+ int scrollY = getPaddingTop() + (mScrollPosState.rowIndex * mScrollPosState.rowHeight) +
+ mPredictionBarHeight - mScrollPosState.rowTopOffset;
+ updateScrollY(scrollY);
+ }
+ }
+
+ /**
* Returns the current scroll state.
*/
private void getCurScrollState(ScrollPositionState stateOut,
diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java
index 57ccff06d..989026e36 100644
--- a/src/com/android/launcher3/AppsContainerView.java
+++ b/src/com/android/launcher3/AppsContainerView.java
@@ -82,11 +82,11 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
private int mNumAppsPerRow;
private int mNumPredictedAppsPerRow;
// This coordinate is relative to this container view
- private Point mBoundsCheckLastTouchDownPos = new Point(-1, -1);
+ private final Point mBoundsCheckLastTouchDownPos = new Point(-1, -1);
// This coordinate is relative to its parent
- private Point mIconLastTouchPos = new Point();
- // This coordinate is used to proxy click and long-click events
- private Point mPredictionIconTouchDownPos = new Point();
+ private final Point mIconLastTouchPos = new Point();
+ // This coordinate is used to proxy click and long-click events to the prediction bar icons
+ private final Point mPredictionIconTouchDownPos = new Point();
private int mContentMarginStart;
// Normal container insets
private int mContainerInset;