Fixed a crash that could occur in the ObservableScrollView
Bug: 17644848 Change-Id: I771c27f9fee8c0d5edfbd21998ea015fd1d6f685
This commit is contained in:
@@ -34,6 +34,7 @@ public class ObservableScrollView extends ScrollView {
|
|||||||
private float mLastX;
|
private float mLastX;
|
||||||
private float mLastY;
|
private float mLastY;
|
||||||
private boolean mBlockFlinging;
|
private boolean mBlockFlinging;
|
||||||
|
private boolean mTouchCancelled;
|
||||||
|
|
||||||
public ObservableScrollView(Context context, AttributeSet attrs) {
|
public ObservableScrollView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -87,9 +88,20 @@ public class ObservableScrollView extends ScrollView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||||
boolean isEndGuesture = (ev.getAction() == MotionEvent.ACTION_UP
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|| ev.getAction() == MotionEvent.ACTION_CANCEL);
|
if (!mTouchEnabled) {
|
||||||
if (!mTouchEnabled && !isEndGuesture) {
|
mTouchCancelled = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
mTouchCancelled = false;
|
||||||
|
} else if (mTouchCancelled) {
|
||||||
|
return false;
|
||||||
|
} else if (!mTouchEnabled) {
|
||||||
|
MotionEvent cancel = MotionEvent.obtain(ev);
|
||||||
|
cancel.setAction(MotionEvent.ACTION_CANCEL);
|
||||||
|
super.dispatchTouchEvent(ev);
|
||||||
|
cancel.recycle();
|
||||||
|
mTouchCancelled = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.dispatchTouchEvent(ev);
|
return super.dispatchTouchEvent(ev);
|
||||||
|
|||||||
Reference in New Issue
Block a user