summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-02-16 13:33:15 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-02-23 16:15:25 -0800
commit2a76e3fbc654481eb05ac3187896884ad1497b9f (patch)
treec5b1aa7edd31277e487bada373da308e8234c487 /src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
parentf28629a47b5fcd9532683e9c9ad7aad049e0106d (diff)
downloadandroid_packages_apps_Trebuchet-2a76e3fbc654481eb05ac3187896884ad1497b9f.tar.gz
android_packages_apps_Trebuchet-2a76e3fbc654481eb05ac3187896884ad1497b9f.tar.bz2
android_packages_apps_Trebuchet-2a76e3fbc654481eb05ac3187896884ad1497b9f.zip
Removing custom state definition from FastBitmapDrawable
> For Fast scrolling, using state list animator defined in xml > For Pressed state, using onState change method in a drawable Change-Id: Ia608690f593938cf0f77e00afcc2a3076e48d8f4
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java48
1 files changed, 16 insertions, 32 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java b/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
index 28b7685ed..a1ff8223a 100644
--- a/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
+++ b/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
@@ -19,6 +19,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.android.launcher3.BaseRecyclerViewFastScrollBar;
+import com.android.launcher3.BubbleTextView;
import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.util.Thunk;
@@ -45,8 +46,7 @@ public class AllAppsFastScrollHelper implements AllAppsGridAdapter.BindViewCallb
// Set of all views animated during fast scroll. We keep track of these ourselves since there
// is no way to reset a view once it gets scrapped or recycled without other hacks
- private HashSet<BaseRecyclerViewFastScrollBar.FastScrollFocusableView> mTrackedFastScrollViews =
- new HashSet<>();
+ private HashSet<RecyclerView.ViewHolder> mTrackedFastScrollViews = new HashSet<>();
// Smooth fast-scroll animation frames
@Thunk int mFastScrollFrameIndex;
@@ -186,12 +186,7 @@ public class AllAppsFastScrollHelper implements AllAppsGridAdapter.BindViewCallb
public void onBindView(AllAppsGridAdapter.ViewHolder holder) {
// Update newly bound views to the current fast scroll state if we are fast scrolling
if (mCurrentFastScrollSection != null || mTargetFastScrollSection != null) {
- if (holder.itemView instanceof BaseRecyclerViewFastScrollBar.FastScrollFocusableView) {
- BaseRecyclerViewFastScrollBar.FastScrollFocusableView v =
- (BaseRecyclerViewFastScrollBar.FastScrollFocusableView) holder.itemView;
- updateViewFastScrollFocusState(v, holder.getPosition(), false /* animated */);
- mTrackedFastScrollViews.add(v);
- }
+ mTrackedFastScrollViews.add(holder);
}
}
@@ -201,9 +196,9 @@ public class AllAppsFastScrollHelper implements AllAppsGridAdapter.BindViewCallb
private void trackAllChildViews() {
int childCount = mRv.getChildCount();
for (int i = 0; i < childCount; i++) {
- View v = mRv.getChildAt(i);
- if (v instanceof BaseRecyclerViewFastScrollBar.FastScrollFocusableView) {
- mTrackedFastScrollViews.add((BaseRecyclerViewFastScrollBar.FastScrollFocusableView) v);
+ RecyclerView.ViewHolder viewHolder = mRv.getChildViewHolder(mRv.getChildAt(i));
+ if (viewHolder != null) {
+ mTrackedFastScrollViews.add(viewHolder);
}
}
}
@@ -212,27 +207,16 @@ public class AllAppsFastScrollHelper implements AllAppsGridAdapter.BindViewCallb
* Updates the fast scroll focus on all the children.
*/
private void updateTrackedViewsFastScrollFocusState() {
- for (BaseRecyclerViewFastScrollBar.FastScrollFocusableView v : mTrackedFastScrollViews) {
- RecyclerView.ViewHolder viewHolder = mRv.getChildViewHolder((View) v);
- int pos = (viewHolder != null) ? viewHolder.getPosition() : -1;
- updateViewFastScrollFocusState(v, pos, true);
- }
- }
-
- /**
- * Updates the fast scroll focus on all a given view.
- */
- private void updateViewFastScrollFocusState(BaseRecyclerViewFastScrollBar.FastScrollFocusableView v,
- int pos, boolean animated) {
- FastBitmapDrawable.State newState = FastBitmapDrawable.State.NORMAL;
- if (mCurrentFastScrollSection != null && pos > -1) {
- AlphabeticalAppsList.AdapterItem item = mApps.getAdapterItems().get(pos);
- boolean highlight = item.sectionName.equals(mCurrentFastScrollSection) &&
- item.position == mTargetFastScrollPosition;
- newState = highlight ?
- FastBitmapDrawable.State.FAST_SCROLL_HIGHLIGHTED :
- FastBitmapDrawable.State.FAST_SCROLL_UNHIGHLIGHTED;
+ for (RecyclerView.ViewHolder viewHolder : mTrackedFastScrollViews) {
+ int pos = viewHolder.getAdapterPosition();
+ boolean isActive = false;
+ if (mCurrentFastScrollSection != null && pos > -1) {
+ AlphabeticalAppsList.AdapterItem item = mApps.getAdapterItems().get(pos);
+ isActive = item != null &&
+ mCurrentFastScrollSection.equals(item.sectionName) &&
+ item.position == mTargetFastScrollPosition;
+ }
+ viewHolder.itemView.setActivated(isActive);
}
- v.setFastScrollFocusState(newState, animated);
}
}