diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2015-05-01 14:21:57 -0700 |
---|---|---|
committer | Hyunyoung Song <hyunyoungs@google.com> | 2015-05-01 14:21:57 -0700 |
commit | e809332032c8f0c2f361eb8fc753f3b57d9cfaaa (patch) | |
tree | 9567244ed400054b3ca3bc758035fb64472552bb /src/com | |
parent | 111c83579a165fe9d8f915cda4e08de47e16c056 (diff) | |
download | android_packages_apps_Trebuchet-e809332032c8f0c2f361eb8fc753f3b57d9cfaaa.tar.gz android_packages_apps_Trebuchet-e809332032c8f0c2f361eb8fc753f3b57d9cfaaa.tar.bz2 android_packages_apps_Trebuchet-e809332032c8f0c2f361eb8fc753f3b57d9cfaaa.zip |
Set preloading for the WidgetTray recycler view.
b/20339302
Introduced a constant that we can use to tweak how much extra screen
space worth of widgets are preloaded.
Change-Id: I47f0fec134b4e268140482694a1903cf902731c6
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/widget/WidgetsContainerView.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java index 8090c88a4..22e29f304 100644 --- a/src/com/android/launcher3/widget/WidgetsContainerView.java +++ b/src/com/android/launcher3/widget/WidgetsContainerView.java @@ -24,6 +24,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.RecyclerView.State; import android.util.AttributeSet; import android.util.Log; import android.view.View; @@ -62,6 +63,9 @@ public class WidgetsContainerView extends FrameLayout implements Insettable, private static final int SPRING_MODE_DELAY_MS = 150; + /* Coefficient multiplied to the screen height for preloading widgets. */ + private static final int PRELOAD_SCREEN_HEIGHT_MULTIPLE = 1; + /* Global instances that are used inside this container. */ private Launcher mLauncher; private DragController mDragController; @@ -114,8 +118,15 @@ public class WidgetsContainerView extends FrameLayout implements Insettable, } mView = (RecyclerView) findViewById(R.id.widgets_list_view); mView.setAdapter(mAdapter); - mView.setLayoutManager(new LinearLayoutManager(getContext())); + // This extends the layout space so that preloading happen for the {@link RecyclerView} + mView.setLayoutManager(new LinearLayoutManager(getContext()) { + @Override + protected int getExtraLayoutSpace(State state) { + return super.getExtraLayoutSpace(state) + + WidgetsContainerView.this.getHeight() * PRELOAD_SCREEN_HEIGHT_MULTIPLE; + } + }); mPadding.set(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom()); } |