Explorations in dense grids for all apps.

- Adds sticky section headers
- Removing AppsListAdapter
- Adding search bar field
- Subtitle filtering

Bug: 20222023

Change-Id: I1eaef701b5d68f475615f09d86561eacc91c937f
This commit is contained in:
Winson Chung
2015-05-05 17:21:58 -07:00
parent 04ac4faab0
commit 83f59abc9c
20 changed files with 479 additions and 279 deletions
@@ -66,6 +66,7 @@ public class AppsContainerRecyclerView extends RecyclerView
private int mScrollbarWidth;
private int mScrollbarMinHeight;
private int mScrollbarInset;
private RecyclerView.OnScrollListener mScrollListenerProxy;
public AppsContainerRecyclerView(Context context) {
this(context, null);
@@ -102,7 +103,7 @@ public class AppsContainerRecyclerView extends RecyclerView
mDeltaThreshold = getResources().getDisplayMetrics().density * SCROLL_DELTA_THRESHOLD;
ScrollListener listener = new ScrollListener();
addOnScrollListener(listener);
setOnScrollListener(listener);
}
private class ScrollListener extends RecyclerView.OnScrollListener {
@@ -112,6 +113,7 @@ public class AppsContainerRecyclerView extends RecyclerView
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
mDy = dy;
mScrollListenerProxy.onScrolled(recyclerView, dx, dy);
}
}
@@ -129,6 +131,13 @@ public class AppsContainerRecyclerView extends RecyclerView
mNumAppsPerRow = rowSize;
}
/**
* Sets an additional scroll listener, not necessary in master support lib.
*/
public void setOnScrollListenerProxy(RecyclerView.OnScrollListener listener) {
mScrollListenerProxy = listener;
}
/**
* Sets the fast scroller alpha.
*/
@@ -178,10 +187,6 @@ public class AppsContainerRecyclerView extends RecyclerView
handleTouchEvent(ev);
}
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
// Do nothing
}
/**
* Handles the touch event and determines whether to show the fast scroller (or updates it if
* it is already showing).
@@ -322,6 +327,7 @@ public class AppsContainerRecyclerView extends RecyclerView
// Find the position of the first application in the section that contains the row at the
// current progress
List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
int rowAtProgress = (int) (progress * getNumRows());
int rowCount = 0;
AlphabeticalAppsList.SectionInfo lastSectionInfo = null;
@@ -333,7 +339,7 @@ public class AppsContainerRecyclerView extends RecyclerView
}
rowCount += numRowsInSection;
}
int position = mApps.getAdapterItems().indexOf(lastSectionInfo.firstAppItem);
int position = items.indexOf(lastSectionInfo.firstAppItem);
// Scroll the position into view, anchored at the top of the screen if possible. We call the
// scroll method on the LayoutManager directly since it is not exposed by RecyclerView.
@@ -342,15 +348,17 @@ public class AppsContainerRecyclerView extends RecyclerView
layoutManager.scrollToPositionWithOffset(position, 0);
// Return the section name of the row
return mApps.getAdapterItems().get(position).sectionName;
return lastSectionInfo.sectionName;
}
/**
* Returns the bounds for the scrollbar.
*/
private void updateVerticalScrollbarBounds() {
List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems();
// Skip early if there are no items
if (mApps.getAdapterItems().isEmpty()) {
if (items.isEmpty()) {
mVerticalScrollbarBounds.setEmpty();
return;
}
@@ -369,7 +377,7 @@ public class AppsContainerRecyclerView extends RecyclerView
View child = getChildAt(i);
int position = getChildPosition(child);
if (position != NO_POSITION) {
AlphabeticalAppsList.AdapterItem item = mApps.getAdapterItems().get(position);
AlphabeticalAppsList.AdapterItem item = items.get(position);
if (!item.isSectionHeader) {
rowIndex = findRowForAppIndex(item.appIndex);
rowTopOffset = getLayoutManager().getDecoratedTop(child);