1b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwellpackage com.android.contacts.widget; 2b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell 3b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwellimport android.content.Context; 4b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwellimport android.os.Parcelable; 5b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwellimport android.util.AttributeSet; 6b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwellimport android.view.MotionEvent; 7b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwellimport android.widget.ScrollView; 8b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell 9b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell/** 10b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell * A {@link ScrollView} that doesn't respond or intercept touch events. 11b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell * 12b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell * This is used in combination with {@link com.android.contacts.widget.MultiShrinkScroller} so 13b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell * that MultiShrinkScroller can handle all scrolling & saving. 14b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell */ 15b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwellpublic class TouchlessScrollView extends ScrollView { 16b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell 17b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell public TouchlessScrollView(Context context) { 18b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell this(context, null); 19b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell } 20b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell 21b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell public TouchlessScrollView(Context context, AttributeSet attrs) { 22b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell this(context, attrs, 0); 23b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell } 24b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell 25b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell public TouchlessScrollView(Context context, AttributeSet attrs, int defStyleAttr) { 26b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell super(context, attrs, defStyleAttr); 27b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell } 28b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell 29b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell @Override 30b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell protected Parcelable onSaveInstanceState() { 31b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell // Do not save the current scroll position. Always store scrollY=0 and delegate 32b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell // responsibility of saving state to the MultiShrinkScroller. 33b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell final int scrollY = getScrollY(); 34b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell setScrollY(0); 35b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell final Parcelable returnValue = super.onSaveInstanceState(); 36b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell setScrollY(scrollY); 37b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell return returnValue; 38b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell } 39b80b4fe87efae6f09d544a8af294b7db9b50558fBrian Attwell 40b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell /** 41b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell * {@inheritDoc} 42b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell */ 43b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell @Override 44b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell public boolean onInterceptTouchEvent(MotionEvent ev) { 45b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell return false; 46b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell } 47b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell 48b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell /** 49b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell * {@inheritDoc} 50b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell */ 51b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell @Override 52b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell public boolean onTouchEvent(MotionEvent event) { 53b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell return false; 54b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell } 55b7e4364d6536449271ac4534dbeb7430134c096bBrian Attwell}