@Override
  public boolean onTouchEvent(MotionEvent event) {
    int action = event.getAction();
    boolean flag = false;

    switch (action) {
      case MotionEvent.ACTION_DOWN:
        try {
          MovementMethod m = getMovementMethod();
          setMovementMethod(null);
          CharSequence sequence = getText();
          if (sequence instanceof Spannable) {
            boolean mt = m.onTouchEvent(this, (Spannable) getText(), event);
            if (mt) {
              event.setAction(MotionEvent.ACTION_UP);
              mt = m.onTouchEvent(this, (Spannable) getText(), event);
              event.setAction(MotionEvent.ACTION_DOWN);
            }
            boolean st = super.onTouchEvent(event);
            setMovementMethod(m);
            setFocusable(false);
            flag = mt || st;
          }
        } catch (Exception e) {

        }

        break;
      default:
        break;
    }
    return flag;
  }
Exemplo n.º 2
0
 @SuppressLint("ClickableViewAccessibility")
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   MovementMethod mm = getMovementMethod();
   CharSequence text = getText();
   if (mm != null && (text instanceof Spannable) && handleTouchEvent(event)) {
     mm.onTouchEvent(this, (Spannable) text, event);
     if (dispatchToParent) {
       return false;
     }
   }
   return super.onTouchEvent(event);
 }
Exemplo n.º 3
0
  @Implementation
  public boolean onTouchEvent(MotionEvent event) {
    boolean superResult = super.onTouchEvent(event);

    if (movementMethod != null) {
      boolean handled = movementMethod.onTouchEvent(null, null, event);

      if (handled) {
        return true;
      }
    }

    return superResult;
  }
Exemplo n.º 4
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    CharSequence mText = getText();
    MovementMethod mMovement = getMovementMethod();
    if (getText() instanceof Spannable) {
      if (mMovement != null) {
        boolean handled = mMovement.onTouchEvent(this, (Spannable) mText, event);
        if (handled) return true;
      }

      // final boolean textIsSelectable = isTextSelectable();

      ClickableSpan[] links =
          ((Spannable) mText).getSpans(getSelectionStart(), getSelectionEnd(), ClickableSpan.class);

      if (links.length > 0) {
        return super.onTouchEvent(event);
      } else {
        return false;
      }
    } else {
      return false;
    }
  }