summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/AppsGridAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/AppsGridAdapter.java')
-rw-r--r--src/com/android/launcher3/AppsGridAdapter.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/com/android/launcher3/AppsGridAdapter.java b/src/com/android/launcher3/AppsGridAdapter.java
index 5b6967c26..c8ce397f2 100644
--- a/src/com/android/launcher3/AppsGridAdapter.java
+++ b/src/com/android/launcher3/AppsGridAdapter.java
@@ -112,6 +112,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
private LayoutInflater mLayoutInflater;
@Thunk AlphabeticalAppsList mApps;
+ private GridLayoutManager mGridLayoutMgr;
private GridSpanSizer mGridSizer;
private GridItemDecoration mItemDecoration;
private View.OnTouchListener mTouchListener;
@@ -135,6 +136,9 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
mApps = apps;
mAppsPerRow = appsPerRow;
mGridSizer = new GridSpanSizer();
+ mGridLayoutMgr = new GridLayoutManager(context, appsPerRow, GridLayoutManager.VERTICAL,
+ false);
+ mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
mItemDecoration = new GridItemDecoration();
mLayoutInflater = LayoutInflater.from(context);
mTouchListener = touchListener;
@@ -150,6 +154,14 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
}
/**
+ * Sets the number of apps per row.
+ */
+ public void setNumAppsPerRow(int appsPerRow) {
+ mAppsPerRow = appsPerRow;
+ mGridLayoutMgr.setSpanCount(appsPerRow);
+ }
+
+ /**
* Sets whether we are in RTL mode.
*/
public void setRtl(boolean rtl) {
@@ -167,10 +179,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
* Returns the grid layout manager.
*/
public GridLayoutManager getLayoutManager(Context context) {
- GridLayoutManager layoutMgr = new GridLayoutManager(context, mAppsPerRow,
- GridLayoutManager.VERTICAL, false);
- layoutMgr.setSpanSizeLookup(mGridSizer);
- return layoutMgr;
+ return mGridLayoutMgr;
}
/**