diff options
author | cretin45 <cretin45@gmail.com> | 2015-11-13 16:51:43 -0800 |
---|---|---|
committer | cretin45 <cretin45@gmail.com> | 2015-11-23 12:10:32 -0800 |
commit | acab44fc939b4083ab7ec889b0c6d4fe0db00cca (patch) | |
tree | 6d7dd6d411404b804814ec4091e007f05dfd4ae5 /src/com/android/launcher3/BaseContainerView.java | |
parent | 35614fdc7d13179ba9cbc80f15eca6d63cf3229d (diff) | |
download | android_packages_apps_Trebuchet-acab44fc939b4083ab7ec889b0c6d4fe0db00cca.tar.gz android_packages_apps_Trebuchet-acab44fc939b4083ab7ec889b0c6d4fe0db00cca.tar.bz2 android_packages_apps_Trebuchet-acab44fc939b4083ab7ec889b0c6d4fe0db00cca.zip |
Reimplement the CM scrubber against the new Launcher
PS4: Implement RTL support
Change-Id: I4456d54b5924913d1b36e1cfa9a2269150f6fb3e
Diffstat (limited to 'src/com/android/launcher3/BaseContainerView.java')
-rw-r--r-- | src/com/android/launcher3/BaseContainerView.java | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/com/android/launcher3/BaseContainerView.java b/src/com/android/launcher3/BaseContainerView.java index c11824054..ac2afa944 100644 --- a/src/com/android/launcher3/BaseContainerView.java +++ b/src/com/android/launcher3/BaseContainerView.java @@ -20,7 +20,10 @@ import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.util.Log; +import android.view.View; +import android.view.ViewStub; import android.widget.LinearLayout; +import android.widget.TextView; /** * A base container view, which supports resizing. @@ -43,6 +46,11 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab // The inset to apply to the edges and between the search bar and the container private int mContainerBoundsInset; private boolean mHasSearchBar; + private boolean mUseScrubber; + + protected View mScrubberContainerView; + protected BaseRecyclerViewScrubber mScrubber; + protected final int mScrubberHeight; public BaseContainerView(Context context) { this(context, null); @@ -55,6 +63,7 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab public BaseContainerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mContainerBoundsInset = getResources().getDimensionPixelSize(R.dimen.container_bounds_inset); + mScrubberHeight = getResources().getDimensionPixelSize(R.dimen.scrubber_height); } @Override @@ -67,6 +76,10 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab mHasSearchBar = true; } + protected boolean hasSearchBar() { + return mHasSearchBar; + } + /** * Sets the search bar bounds for this container view to match. */ @@ -87,10 +100,46 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab }); } + public final void setUseScrubber(boolean use) { + mUseScrubber = use; + if (use) { + ViewStub stub = (ViewStub) findViewById(R.id.scrubber_container_stub); + mScrubberContainerView = stub.inflate(); + if (mScrubberContainerView == null) { + throw new IllegalStateException( + "Layout must contain an id: R.id.scrubber_container"); + } + mScrubber = (BaseRecyclerViewScrubber) + mScrubberContainerView.findViewById(R.id.base_scrubber); + BaseRecyclerView recyclerView = getRecyclerView(); + if (recyclerView != null) { + mScrubber.setRecycler(recyclerView); + mScrubber + .setScrubberIndicator((TextView) mScrubberContainerView + .findViewById(R.id.scrubberIndicator)); + mScrubber.updateSections(); + } + } else { + removeView(mScrubberContainerView); + BaseRecyclerView recyclerView = getRecyclerView(); + if (recyclerView != null) { + recyclerView.setUseScrollbar(true); + } + } + } + + public final boolean userScrubber() { + return mUseScrubber; + } + + protected void updateBackgroundAndPaddings() { + updateBackgroundAndPaddings(false); + } + /** * Update the backgrounds and padding in response to a change in the bounds or insets. */ - protected void updateBackgroundAndPaddings() { + protected void updateBackgroundAndPaddings(boolean force) { Rect padding; Rect searchBarBounds = new Rect(); if (!isValidSearchBarBounds(mFixedSearchBarBounds)) { @@ -119,7 +168,8 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab // If either the computed container padding has changed, or the computed search bar bounds // has changed, then notify the container - if (!padding.equals(mContentPadding) || !searchBarBounds.equals(mSearchBarBounds)) { + if (force || !padding.equals(mContentPadding) || + !searchBarBounds.equals(mSearchBarBounds)) { mContentPadding.set(padding); mContentBounds.set(padding.left, padding.top, getMeasuredWidth() - padding.right, @@ -135,6 +185,11 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab protected abstract void onUpdateBackgroundAndPaddings(Rect searchBarBounds, Rect padding); /** + * This might be null if the container doesn't have a recycler. + */ + protected abstract BaseRecyclerView getRecyclerView(); + + /** * Returns whether the search bar bounds we got are considered valid. */ private boolean isValidSearchBarBounds(Rect searchBarBounds) { |