diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-03-14 17:51:49 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-03-19 20:02:34 -0700 |
commit | 7185dd63eb8942dec65c2babeb39ee6ec64b4533 (patch) | |
tree | bec53b0f31970f001716a95876de2306d3cc9f1a /src/com/android/launcher3/allapps/FloatingHeaderView.java | |
parent | 9d69c8da9a4f933cc700ef1672b4e60d34a2fb10 (diff) | |
download | android_packages_apps_Trebuchet-7185dd63eb8942dec65c2babeb39ee6ec64b4533.tar.gz android_packages_apps_Trebuchet-7185dd63eb8942dec65c2babeb39ee6ec64b4533.tar.bz2 android_packages_apps_Trebuchet-7185dd63eb8942dec65c2babeb39ee6ec64b4533.zip |
Changing the overviewState to show appsearch and floating header
Change-Id: I2cfd61cfc9978e4c8e4520f0f7217e49e7344c79
Diffstat (limited to 'src/com/android/launcher3/allapps/FloatingHeaderView.java')
-rw-r--r-- | src/com/android/launcher3/allapps/FloatingHeaderView.java | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java index a0dc5a382..461f5b5ba 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.allapps; +import static com.android.launcher3.anim.Interpolators.LINEAR; + import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Point; @@ -29,6 +31,7 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import com.android.launcher3.R; +import com.android.launcher3.anim.PropertySetter; public class FloatingHeaderView extends LinearLayout implements ValueAnimator.AnimatorUpdateListener { @@ -57,7 +60,7 @@ public class FloatingHeaderView extends LinearLayout implements } }; - private ViewGroup mTabLayout; + protected ViewGroup mTabLayout; private AllAppsRecyclerView mMainRV; private AllAppsRecyclerView mWorkRV; private AllAppsRecyclerView mCurrentRV; @@ -65,6 +68,8 @@ public class FloatingHeaderView extends LinearLayout implements private boolean mHeaderCollapsed; private int mSnappedScrolledY; private int mTranslationY; + + private boolean mAllowTouchForwarding; private boolean mForwardToRecyclerView; protected boolean mTabsHidden; @@ -91,7 +96,7 @@ public class FloatingHeaderView extends LinearLayout implements mWorkRV = setupRV(mWorkRV, mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView); mParent = (ViewGroup) mMainRV.getParent(); setMainActive(true); - reset(); + reset(false); } private AllAppsRecyclerView setupRV(AllAppsRecyclerView old, AllAppsRecyclerView updated) { @@ -158,12 +163,19 @@ public class FloatingHeaderView extends LinearLayout implements } } - public void reset() { - int translateTo = 0; - mAnimator.setIntValues(mTranslationY, translateTo); - mAnimator.addUpdateListener(this); - mAnimator.setDuration(150); - mAnimator.start(); + public void reset(boolean animate) { + if (mAnimator.isStarted()) { + mAnimator.cancel(); + } + if (animate) { + mAnimator.setIntValues(mTranslationY, 0); + mAnimator.addUpdateListener(this); + mAnimator.setDuration(150); + mAnimator.start(); + } else { + mTranslationY = 0; + apply(); + } mHeaderCollapsed = false; mSnappedScrolledY = -mMaxTranslation; mCurrentRV.scrollToTop(); @@ -181,6 +193,10 @@ public class FloatingHeaderView extends LinearLayout implements @Override public boolean onInterceptTouchEvent(MotionEvent ev) { + if (!mAllowTouchForwarding) { + mForwardToRecyclerView = false; + return super.onInterceptTouchEvent(ev); + } calcOffset(mTempOffset); ev.offsetLocation(mTempOffset.x, mTempOffset.y); mForwardToRecyclerView = mCurrentRV.onInterceptTouchEvent(ev); @@ -208,6 +224,19 @@ public class FloatingHeaderView extends LinearLayout implements p.x = getLeft() - mCurrentRV.getLeft() - mParent.getLeft(); p.y = getTop() - mCurrentRV.getTop() - mParent.getTop(); } + + public void setContentVisibility(boolean hasHeader, boolean hasContent, PropertySetter setter) { + setter.setViewAlpha(this, hasContent ? 1 : 0, LINEAR); + allowTouchForwarding(hasContent); + } + + protected void allowTouchForwarding(boolean allow) { + mAllowTouchForwarding = allow; + } + + public boolean hasVisibleContent() { + return false; + } } |