Java Code Examples for android.view.TouchDelegate#onTouchEvent()

The following examples show how to use android.view.TouchDelegate#onTouchEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TouchDelegateGroup.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
        if (!mEnabled) return false;

        TouchDelegate delegate = null;

        switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                        for (int i = 0; i < mTouchDelegates.size(); i++) {
                                TouchDelegate touchDelegate = mTouchDelegates.get(i);
                                if (touchDelegate.onTouchEvent(event)) {
                                        mCurrentTouchDelegate = touchDelegate;
                                        return true;
                                }
                        }
                        break;

                case MotionEvent.ACTION_MOVE:
                        delegate = mCurrentTouchDelegate;
                        break;

                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_UP:
                        delegate = mCurrentTouchDelegate;
                        mCurrentTouchDelegate = null;
                        break;
        }

        return delegate != null && delegate.onTouchEvent(event);
}
 
Example 2
Source File: TouchDelegateGroup.java    From FABsMenu with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    if (!mEnabled) return false;

    TouchDelegate delegate = null;

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            for (int i = 0; i < mTouchDelegates.size(); i++) {
                TouchDelegate touchDelegate = mTouchDelegates.get(i);
                if (touchDelegate.onTouchEvent(event)) {
                    mCurrentTouchDelegate = touchDelegate;
                    return true;
                }
            }
            break;

        case MotionEvent.ACTION_MOVE:
            delegate = mCurrentTouchDelegate;
            break;

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            delegate = mCurrentTouchDelegate;
            mCurrentTouchDelegate = null;
            break;
        default: // Do Nothing
            break;
    }

    return delegate != null && delegate.onTouchEvent(event);
}
 
Example 3
Source File: TouchDelegateGroup.java    From TestChat with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
        if (!mEnabled) return false;

        TouchDelegate delegate = null;

        switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                        for (int i = 0; i < mTouchDelegates.size(); i++) {
                                TouchDelegate touchDelegate = mTouchDelegates.get(i);
                                if (touchDelegate.onTouchEvent(event)) {
                                        mCurrentTouchDelegate = touchDelegate;
                                        return true;
                                }
                        }
                        break;

                case MotionEvent.ACTION_MOVE:
                        delegate = mCurrentTouchDelegate;
                        break;

                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_UP:
                        delegate = mCurrentTouchDelegate;
                        mCurrentTouchDelegate = null;
                        break;
        }

        return delegate != null && delegate.onTouchEvent(event);
}
 
Example 4
Source File: AccessibilityUtils.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
  // Go through the list and see if any of the delegates could claim this event.
  // Note: Assumes non-overlapping touchDelegates.
  boolean result = false;
  // Check against all the touchDelegates in the list -- this could be an
  // ACTION_MOVE or ACTION_UP that impacts a view that isn't at the (x,y) of an event.
  for (TouchDelegate touchDelegate : delegateList) {
    result = touchDelegate.onTouchEvent(event) || result;
  }
  return result;
}
 
Example 5
Source File: TouchDelegateGroup.java    From FlowGeek with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  if (!mEnabled) return false;

  TouchDelegate delegate = null;

  switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN:
    for (int i = 0; i < mTouchDelegates.size(); i++) {
      TouchDelegate touchDelegate = mTouchDelegates.get(i);
      if (touchDelegate.onTouchEvent(event)) {
        mCurrentTouchDelegate = touchDelegate;
        return true;
      }
    }
    break;

  case MotionEvent.ACTION_MOVE:
    delegate = mCurrentTouchDelegate;
    break;

  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    delegate = mCurrentTouchDelegate;
    mCurrentTouchDelegate = null;
    break;
  }

  return delegate != null && delegate.onTouchEvent(event);
}
 
Example 6
Source File: TouchDelegateGroup.java    From TvRemoteControl with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  if (!mEnabled) return false;

  TouchDelegate delegate = null;

  switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN:
    for (int i = 0; i < mTouchDelegates.size(); i++) {
      TouchDelegate touchDelegate = mTouchDelegates.get(i);
      if (touchDelegate.onTouchEvent(event)) {
        mCurrentTouchDelegate = touchDelegate;
        return true;
      }
    }
    break;

  case MotionEvent.ACTION_MOVE:
    delegate = mCurrentTouchDelegate;
    break;

  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    delegate = mCurrentTouchDelegate;
    mCurrentTouchDelegate = null;
    break;
  }

  return delegate != null && delegate.onTouchEvent(event);
}
 
Example 7
Source File: TouchDelegateGroup.java    From android-chat-ui with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  if (!mEnabled) return false;

  TouchDelegate delegate = null;

  switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN:
    for (int i = 0; i < mTouchDelegates.size(); i++) {
      TouchDelegate touchDelegate = mTouchDelegates.get(i);
      if (touchDelegate.onTouchEvent(event)) {
        mCurrentTouchDelegate = touchDelegate;
        return true;
      }
    }
    break;

  case MotionEvent.ACTION_MOVE:
    delegate = mCurrentTouchDelegate;
    break;

  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    delegate = mCurrentTouchDelegate;
    mCurrentTouchDelegate = null;
    break;
  }

  return delegate != null && delegate.onTouchEvent(event);
}
 
Example 8
Source File: TouchDelegateGroup.java    From FloatingActionButton with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  if (!mEnabled) return false;

  TouchDelegate delegate = null;

  switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN:
    for (int i = 0; i < mTouchDelegates.size(); i++) {
      TouchDelegate touchDelegate = mTouchDelegates.get(i);
      if (touchDelegate.onTouchEvent(event)) {
        mCurrentTouchDelegate = touchDelegate;
        return true;
      }
    }
    break;

  case MotionEvent.ACTION_MOVE:
    delegate = mCurrentTouchDelegate;
    break;

  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    delegate = mCurrentTouchDelegate;
    mCurrentTouchDelegate = null;
    break;
  }

  return delegate != null && delegate.onTouchEvent(event);
}
 
Example 9
Source File: TouchDelegateGroup.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    TouchDelegate delegate = null;

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (mTouchDelegates != null) {
                for (TouchDelegate touchDelegate : mTouchDelegates) {
                    if (touchDelegate != null) {
                        if (touchDelegate.onTouchEvent(event)) {
                            mCurrentTouchDelegate = touchDelegate;
                            return true;
                        }
                    }
                }
            }
            break;

        case MotionEvent.ACTION_MOVE:
            delegate = mCurrentTouchDelegate;
            break;

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            delegate = mCurrentTouchDelegate;
            mCurrentTouchDelegate = null;
            break;
    }

    return delegate == null ? false : delegate.onTouchEvent(event);
}
 
Example 10
Source File: TouchDelegateGroup.java    From android-floating-action-button with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  if (!mEnabled) return false;

  TouchDelegate delegate = null;

  switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN:
    for (int i = 0; i < mTouchDelegates.size(); i++) {
      TouchDelegate touchDelegate = mTouchDelegates.get(i);
      if (touchDelegate.onTouchEvent(event)) {
        mCurrentTouchDelegate = touchDelegate;
        return true;
      }
    }
    break;

  case MotionEvent.ACTION_MOVE:
    delegate = mCurrentTouchDelegate;
    break;

  case MotionEvent.ACTION_CANCEL:
  case MotionEvent.ACTION_UP:
    delegate = mCurrentTouchDelegate;
    mCurrentTouchDelegate = null;
    break;
  }

  return delegate != null && delegate.onTouchEvent(event);
}