From 41bccc244efc5f337931422d01df2e4ecec700a9 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Tue, 28 Nov 2017 11:34:09 +0000 Subject: [PATCH] Preserve tab position To reproduce the issue: 1. Swipe to work tab 2. Tap Home 3. Swipe up to show all apps, you can see the personal tab is highlighted while the view pager is showing work apps. We cleared the state whenever onLayout is called, we should make use of mSelectedPosition. Change-Id: I621b3c9ada0eb608280fe5e4ea8715f3a341820d --- src/com/android/launcher3/views/SlidingTabStrip.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/views/SlidingTabStrip.java b/src/com/android/launcher3/views/SlidingTabStrip.java index 45c6261468..c2ef41bdbd 100644 --- a/src/com/android/launcher3/views/SlidingTabStrip.java +++ b/src/com/android/launcher3/views/SlidingTabStrip.java @@ -34,7 +34,7 @@ public class SlidingTabStrip extends LinearLayout { private int mSelectedIndicatorHeight; private int mIndicatorLeft = -1; private int mIndicatorRight = -1; - private int mSelectedPosition = -1; + private int mSelectedPosition = 0; private float mSelectionOffset; public SlidingTabStrip(@NonNull Context context, @Nullable AttributeSet attrs) { @@ -63,8 +63,8 @@ public class SlidingTabStrip extends LinearLayout { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - updateTabTextColor(0); - updateIndicatorPosition(0, 0); + updateTabTextColor(mSelectedPosition); + updateIndicatorPosition(mSelectedPosition, 0); } private void updateIndicatorPosition() {