diff options
Diffstat (limited to 'library/main/src/com/android/setupwizardlib/view/TouchableMovementMethod.java')
-rw-r--r-- | library/main/src/com/android/setupwizardlib/view/TouchableMovementMethod.java | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/library/main/src/com/android/setupwizardlib/view/TouchableMovementMethod.java b/library/main/src/com/android/setupwizardlib/view/TouchableMovementMethod.java index 10e91f4..526883c 100644 --- a/library/main/src/com/android/setupwizardlib/view/TouchableMovementMethod.java +++ b/library/main/src/com/android/setupwizardlib/view/TouchableMovementMethod.java @@ -24,60 +24,56 @@ import android.view.MotionEvent; import android.widget.TextView; /** - * A movement method that tracks the last result of whether touch events are handled. This is - * used to patch the return value of {@link TextView#onTouchEvent} so that it consumes the touch - * events only when the movement method says the event is consumed. + * A movement method that tracks the last result of whether touch events are handled. This is used + * to patch the return value of {@link TextView#onTouchEvent} so that it consumes the touch events + * only when the movement method says the event is consumed. */ public interface TouchableMovementMethod { - /** - * @return The last touch event received in {@link MovementMethod#onTouchEvent} - */ - MotionEvent getLastTouchEvent(); + /** @return The last touch event received in {@link MovementMethod#onTouchEvent} */ + MotionEvent getLastTouchEvent(); - /** - * @return The return value of the last {@link MovementMethod#onTouchEvent}, or whether the - * last touch event should be considered handled by the text view - */ - boolean isLastTouchEventHandled(); + /** + * @return The return value of the last {@link MovementMethod#onTouchEvent}, or whether the last + * touch event should be considered handled by the text view + */ + boolean isLastTouchEventHandled(); - /** - * An extension of LinkMovementMethod that tracks whether the event is handled when it is - * touched. - */ - class TouchableLinkMovementMethod extends LinkMovementMethod - implements TouchableMovementMethod { + /** + * An extension of LinkMovementMethod that tracks whether the event is handled when it is touched. + */ + class TouchableLinkMovementMethod extends LinkMovementMethod implements TouchableMovementMethod { - public static TouchableLinkMovementMethod getInstance() { - return new TouchableLinkMovementMethod(); - } + public static TouchableLinkMovementMethod getInstance() { + return new TouchableLinkMovementMethod(); + } - boolean mLastEventResult = false; - MotionEvent mLastEvent; + boolean lastEventResult = false; + MotionEvent lastEvent; - @Override - public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { - mLastEvent = event; - boolean result = super.onTouchEvent(widget, buffer, event); - if (event.getAction() == MotionEvent.ACTION_DOWN) { - // Unfortunately, LinkMovementMethod extends ScrollMovementMethod, and it always - // consume the down event. So here we use the selection instead as a hint of whether - // the down event landed on a link. - mLastEventResult = Selection.getSelectionStart(buffer) != -1; - } else { - mLastEventResult = result; - } - return result; - } + @Override + public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { + lastEvent = event; + boolean result = super.onTouchEvent(widget, buffer, event); + if (event.getAction() == MotionEvent.ACTION_DOWN) { + // Unfortunately, LinkMovementMethod extends ScrollMovementMethod, and it always + // consume the down event. So here we use the selection instead as a hint of whether + // the down event landed on a link. + lastEventResult = Selection.getSelectionStart(buffer) != -1; + } else { + lastEventResult = result; + } + return result; + } - @Override - public MotionEvent getLastTouchEvent() { - return mLastEvent; - } + @Override + public MotionEvent getLastTouchEvent() { + return lastEvent; + } - @Override - public boolean isLastTouchEventHandled() { - return mLastEventResult; - } + @Override + public boolean isLastTouchEventHandled() { + return lastEventResult; } + } } |