Don't save scroll position inside nested scroller
Delegate all saving/restoring to the parent scrollview.
Bug: 16555313
Change-Id: If2165b1b05eddf4ef923d27f3e9ba050a4e43288
diff --git a/src/com/android/contacts/widget/TouchlessScrollView.java b/src/com/android/contacts/widget/TouchlessScrollView.java
index 693dcbc..a0c0eb2 100644
--- a/src/com/android/contacts/widget/TouchlessScrollView.java
+++ b/src/com/android/contacts/widget/TouchlessScrollView.java
@@ -1,6 +1,7 @@
package com.android.contacts.widget;
import android.content.Context;
+import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;
@@ -9,7 +10,7 @@
* A {@link ScrollView} that doesn't respond or intercept touch events.
*
* This is used in combination with {@link com.android.contacts.widget.MultiShrinkScroller} so
- * that MultiShrinkScroller can handle all scrolling.
+ * that MultiShrinkScroller can handle all scrolling & saving.
*/
public class TouchlessScrollView extends ScrollView {
@@ -25,6 +26,17 @@
super(context, attrs, defStyleAttr);
}
+ @Override
+ protected Parcelable onSaveInstanceState() {
+ // Do not save the current scroll position. Always store scrollY=0 and delegate
+ // responsibility of saving state to the MultiShrinkScroller.
+ final int scrollY = getScrollY();
+ setScrollY(0);
+ final Parcelable returnValue = super.onSaveInstanceState();
+ setScrollY(scrollY);
+ return returnValue;
+ }
+
/**
* {@inheritDoc}
*/