diff options
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsRecyclerView.java')
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsRecyclerView.java | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 0173847e0..ab34287eb 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -101,7 +101,6 @@ public class AllAppsRecyclerView extends BaseRecyclerView { pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows * mNumAppsPerRow); pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON, mNumAppsPerRow); pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER, 1); - pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SECTION_BREAK, approxRows); } /** @@ -116,21 +115,21 @@ public class AllAppsRecyclerView extends BaseRecyclerView { // Icons BubbleTextView icon = (BubbleTextView) adapter.onCreateViewHolder(this, - AllAppsGridAdapter.VIEW_TYPE_ICON).mContent; + AllAppsGridAdapter.VIEW_TYPE_ICON).itemView; int iconHeight = icon.getLayoutParams().height; mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_ICON, iconHeight); mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON, iconHeight); // Search divider View searchDivider = adapter.onCreateViewHolder(this, - AllAppsGridAdapter.VIEW_TYPE_SEARCH_DIVIDER).mContent; + AllAppsGridAdapter.VIEW_TYPE_SEARCH_DIVIDER).itemView; searchDivider.measure(widthMeasureSpec, heightMeasureSpec); int searchDividerHeight = searchDivider.getMeasuredHeight(); mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_SEARCH_DIVIDER, searchDividerHeight); // Generic dividers View divider = adapter.onCreateViewHolder(this, - AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER).mContent; + AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER).itemView; divider.measure(widthMeasureSpec, heightMeasureSpec); int dividerHeight = divider.getMeasuredHeight(); mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER, dividerHeight); @@ -138,18 +137,15 @@ public class AllAppsRecyclerView extends BaseRecyclerView { // Search views View emptySearch = adapter.onCreateViewHolder(this, - AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH).mContent; + AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH).itemView; emptySearch.measure(widthMeasureSpec, heightMeasureSpec); mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, emptySearch.getMeasuredHeight()); View searchMarket = adapter.onCreateViewHolder(this, - AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET).mContent; + AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET).itemView; searchMarket.measure(widthMeasureSpec, heightMeasureSpec); mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, searchMarket.getMeasuredHeight()); - - // Section breaks - mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_SECTION_BREAK, 0); } /** @@ -166,27 +162,10 @@ public class AllAppsRecyclerView extends BaseRecyclerView { } } - /** - * We need to override the draw to ensure that we don't draw the overscroll effect beyond the - * background bounds. - */ - @Override - protected void dispatchDraw(Canvas canvas) { - // Clip to ensure that we don't draw the overscroll effect beyond the background bounds - canvas.clipRect(mBackgroundPadding.left, mBackgroundPadding.top, - getWidth() - mBackgroundPadding.right, - getHeight() - mBackgroundPadding.bottom); - super.dispatchDraw(canvas); - } - @Override public void onDraw(Canvas c) { // Draw the background if (mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) { - c.clipRect(mBackgroundPadding.left, mBackgroundPadding.top, - getWidth() - mBackgroundPadding.right, - getHeight() - mBackgroundPadding.bottom); - mEmptySearchBackground.draw(c); } @@ -299,14 +278,14 @@ public class AllAppsRecyclerView extends BaseRecyclerView { // Skip early if there are no items or we haven't been measured if (items.isEmpty() || mNumAppsPerRow == 0) { - mScrollbar.setThumbOffset(-1, -1); + mScrollbar.setThumbOffsetY(-1); return; } // Skip early if, there no child laid out in the container. int scrollY = getCurrentScrollY(); if (scrollY < 0) { - mScrollbar.setThumbOffset(-1, -1); + mScrollbar.setThumbOffsetY(-1); return; } @@ -314,7 +293,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { int availableScrollBarHeight = getAvailableScrollBarHeight(); int availableScrollHeight = getAvailableScrollHeight(); if (availableScrollHeight <= 0) { - mScrollbar.setThumbOffset(-1, -1); + mScrollbar.setThumbOffsetY(-1); return; } @@ -323,11 +302,10 @@ public class AllAppsRecyclerView extends BaseRecyclerView { // Calculate the current scroll position, the scrollY of the recycler view accounts // for the view padding, while the scrollBarY is drawn right up to the background // padding (ignoring padding) - int scrollBarX = getScrollBarX(); - int scrollBarY = mBackgroundPadding.top + - (int) (((float) scrollY / availableScrollHeight) * availableScrollBarHeight); + int scrollBarY = (int) + (((float) scrollY / availableScrollHeight) * availableScrollBarHeight); - int thumbScrollY = mScrollbar.getThumbOffset().y; + int thumbScrollY = mScrollbar.getThumbOffsetY(); int diffScrollY = scrollBarY - thumbScrollY; if (diffScrollY * dy > 0f) { // User is scrolling in the same direction the thumb needs to catch up to the @@ -344,7 +322,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { thumbScrollY += Math.min(offset, diffScrollY); } thumbScrollY = Math.max(0, Math.min(availableScrollBarHeight, thumbScrollY)); - mScrollbar.setThumbOffset(scrollBarX, thumbScrollY); + mScrollbar.setThumbOffsetY(thumbScrollY); if (scrollBarY == thumbScrollY) { mScrollbar.reattachThumbToScroll(); } @@ -352,7 +330,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { // User is scrolling in an opposite direction to the direction that the thumb // needs to catch up to the scroll position. Do nothing except for updating // the scroll bar x to match the thumb width. - mScrollbar.setThumbOffset(scrollBarX, thumbScrollY); + mScrollbar.setThumbOffsetY(thumbScrollY); } } } else { @@ -416,8 +394,8 @@ public class AllAppsRecyclerView extends BaseRecyclerView { } @Override - protected int getVisibleHeight() { - return super.getVisibleHeight() + protected int getScrollbarTrackHeight() { + return super.getScrollbarTrackHeight() - Launcher.getLauncher(getContext()).getDragLayer().getInsets().bottom; } @@ -429,7 +407,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { protected int getAvailableScrollHeight() { int paddedHeight = getCurrentScrollY(mApps.getAdapterItems().size(), 0); int totalHeight = paddedHeight + getPaddingBottom(); - return totalHeight - getVisibleHeight(); + return totalHeight - getScrollbarTrackHeight(); } /** |