diff options
Diffstat (limited to 'src/com/android/launcher3/widget/WidgetsRecyclerView.java')
-rw-r--r-- | src/com/android/launcher3/widget/WidgetsRecyclerView.java | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/com/android/launcher3/widget/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/WidgetsRecyclerView.java index 2560661c1..e0a80c679 100644 --- a/src/com/android/launcher3/widget/WidgetsRecyclerView.java +++ b/src/com/android/launcher3/widget/WidgetsRecyclerView.java @@ -17,7 +17,6 @@ package com.android.launcher3.widget; import android.content.Context; -import android.graphics.Canvas; import android.graphics.Color; import android.support.v7.widget.LinearLayoutManager; import android.util.AttributeSet; @@ -32,7 +31,7 @@ import com.android.launcher3.model.WidgetsModel; public class WidgetsRecyclerView extends BaseRecyclerView { private static final String TAG = "WidgetsRecyclerView"; - private WidgetsModel mWidgets; + private WidgetsListAdapter mAdapter; public WidgetsRecyclerView(Context context) { this(context, null); @@ -65,23 +64,10 @@ public class WidgetsRecyclerView extends BaseRecyclerView { return Color.WHITE; } - /** - * Sets the widget model in this view, used to determine the fast scroll position. - */ - public void setWidgets(WidgetsModel widgets) { - mWidgets = widgets; - } - - /** - * 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) { - canvas.clipRect(mBackgroundPadding.left, mBackgroundPadding.top, - getWidth() - mBackgroundPadding.right, - getHeight() - mBackgroundPadding.bottom); - super.dispatchDraw(canvas); + public void setAdapter(Adapter adapter) { + super.setAdapter(adapter); + mAdapter = (WidgetsListAdapter) adapter; } /** @@ -97,15 +83,14 @@ public class WidgetsRecyclerView extends BaseRecyclerView { // Stop the scroller if it is scrolling stopScroll(); - int rowCount = mWidgets.getPackageSize(); + int rowCount = mAdapter.getItemCount(); float pos = rowCount * touchFraction; int availableScrollHeight = getAvailableScrollHeight(); LinearLayoutManager layoutManager = ((LinearLayoutManager) getLayoutManager()); layoutManager.scrollToPositionWithOffset(0, (int) -(availableScrollHeight * touchFraction)); int posInt = (int) ((touchFraction == 1)? pos -1 : pos); - PackageItemInfo p = mWidgets.getPackageItemInfo(posInt); - return p.titleSectionName; + return mAdapter.getSectionName(posInt); } /** @@ -121,7 +106,7 @@ public class WidgetsRecyclerView extends BaseRecyclerView { // 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; } @@ -150,13 +135,13 @@ public class WidgetsRecyclerView extends BaseRecyclerView { @Override protected int getAvailableScrollHeight() { View child = getChildAt(0); - int height = child.getMeasuredHeight() * mWidgets.getPackageSize(); + int height = child.getMeasuredHeight() * mAdapter.getItemCount(); int totalHeight = getPaddingTop() + height + getPaddingBottom(); - int availableScrollHeight = totalHeight - getVisibleHeight(); + int availableScrollHeight = totalHeight - getScrollbarTrackHeight(); return availableScrollHeight; } private boolean isModelNotReady() { - return mWidgets == null || mWidgets.getPackageSize() == 0; + return mAdapter.getItemCount() == 0; } }
\ No newline at end of file |