From 12717c04c197364359fc1d74efc1210478a56b5d Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 14 May 2015 19:27:22 +0000 Subject: [PATCH] Revert "Fixing issue where the prediction bar could be misplaced after installing an app." This reverts commit 02baa79e1f75f4c0cc9633d2e634a191321be316. Change-Id: I69c6766d78affcc2a1a4b41a69888cba99fcf7d0 --- .../launcher3/AppsContainerRecyclerView.java | 39 ++++--------------- .../android/launcher3/AppsContainerView.java | 8 ++-- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java index 34e621a46c..3952923afb 100644 --- a/src/com/android/launcher3/AppsContainerRecyclerView.java +++ b/src/com/android/launcher3/AppsContainerRecyclerView.java @@ -120,24 +120,6 @@ 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. */ @@ -387,7 +369,13 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView { } // We need to workaround the RecyclerView to get the right scroll position - refreshCurScrollPosition(); + List items = mApps.getAdapterItems(); + getCurScrollState(mScrollPosState, items); + if (mScrollPosState.rowIndex != -1) { + int scrollY = getPaddingTop() + (mScrollPosState.rowIndex * mScrollPosState.rowHeight) + + mPredictionBarHeight - mScrollPosState.rowTopOffset; + updateScrollY(scrollY); + } // 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. @@ -476,19 +464,6 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView { return rowCount; } - /** - * Forces a refresh of the scroll position to any scroll listener. - */ - private void refreshCurScrollPosition() { - List 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. */ diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java index 989026e36c..57ccff06dd 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 final Point mBoundsCheckLastTouchDownPos = new Point(-1, -1); + private Point mBoundsCheckLastTouchDownPos = new Point(-1, -1); // This coordinate is relative to its parent - 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 Point mIconLastTouchPos = new Point(); + // This coordinate is used to proxy click and long-click events + private Point mPredictionIconTouchDownPos = new Point(); private int mContentMarginStart; // Normal container insets private int mContainerInset;