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