Java Code Examples for android.view.MotionEvent#ACTION_OUTSIDE

The following examples show how to use android.view.MotionEvent#ACTION_OUTSIDE . 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: FButton.java    From android-flat-button with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    switch (motionEvent.getAction()) {
        case MotionEvent.ACTION_DOWN:
            updateBackground(pressedDrawable);
            this.setPadding(mPaddingLeft, mPaddingTop + mShadowHeight, mPaddingRight, mPaddingBottom);
            break;
        case MotionEvent.ACTION_MOVE:
            Rect r = new Rect();
            view.getLocalVisibleRect(r);
            if (!r.contains((int) motionEvent.getX(), (int) motionEvent.getY() + 3 * mShadowHeight) &&
                    !r.contains((int) motionEvent.getX(), (int) motionEvent.getY() - 3 * mShadowHeight)) {
                updateBackground(unpressedDrawable);
                this.setPadding(mPaddingLeft, mPaddingTop + mShadowHeight, mPaddingRight, mPaddingBottom + mShadowHeight);
            }
            break;
        case MotionEvent.ACTION_OUTSIDE:
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            updateBackground(unpressedDrawable);
            this.setPadding(mPaddingLeft, mPaddingTop + mShadowHeight, mPaddingRight, mPaddingBottom + mShadowHeight);
            break;
    }
    return false;
}
 
Example 2
Source File: ShadowImageView.java    From meiShi with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            setColorFilter(Color.parseColor("#77000000"));
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_OUTSIDE:
            setColorFilter(null);
            break;
    }


    return super.onTouchEvent(event);
}
 
Example 3
Source File: PressHoverTouchListener.java    From Cornowser with MIT License 6 votes vote down vote up
@Override
public boolean onTouch(View v, MotionEvent event) {
    switch(event.getAction()) {
        case MotionEvent.ACTION_HOVER_ENTER:
        case MotionEvent.ACTION_DOWN:
            v.setBackgroundColor(downColor);
            break;
        case MotionEvent.ACTION_OUTSIDE:
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_HOVER_EXIT:
        case MotionEvent.ACTION_UP:
            v.setBackgroundColor(upColor);
            break;
        default: break;
    }
    return false;
}
 
Example 4
Source File: TouchManager.java    From MusicBobber with MIT License 6 votes vote down vote up
@Override
public boolean onTouch(@NonNull View v, @NonNull MotionEvent event) {
    boolean res = (!touchCanceled || event.getAction() == MotionEvent.ACTION_UP) && gestureDetector.onTouchEvent(event);
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        touchCanceled = false;
        gestureListener.onDown(event);
    } else if (event.getAction() == MotionEvent.ACTION_UP) {
        if (!touchCanceled) {
            gestureListener.onUpEvent(event);
        }
    } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
        if (!touchCanceled) {
            gestureListener.onMove(event);
        }
    } else if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
        gestureListener.onTouchOutsideEvent(event);
        touchCanceled = false;
    } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
        touchCanceled = true;
    }
    return res;
}
 
Example 5
Source File: libraryHome.java    From Android-Music-Player with MIT License 6 votes vote down vote up
public boolean dispatchTouchEvent(MotionEvent event) {

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                ONDown(event);
                break;
            case MotionEvent.ACTION_MOVE:
                 ONMove(event);
                break;
            case MotionEvent.ACTION_OUTSIDE:
                //onOut(event);
                break;
            case MotionEvent.ACTION_UP:
                ONUp(event);
                break;
            default:
                //onleave(event);
        }
        if(moved){
            return  false;
        }
        return super.dispatchTouchEvent(event);
    }
 
Example 6
Source File: BannerPager.java    From BannerPager with Apache License 2.0 6 votes vote down vote up
private void handleEvent(MotionEvent ev) {
    //没有使能loop 或者 没有调用start
    if (!mPagerOptions.mLoopEnable || !isStartLoop) {
        return;
    }
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_OUTSIDE:
            trace("dispatchTouchEvent: " + ev.getX());
            removeHandlerMessages();
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            trace("dispatchTouchEvent: " + ev.getX());
            removeHandlerMessages();
            sendHandlerEmptyMessage();
            break;
        default:
            trace("未知事件: " + ev.getAction());
            break;
    }
}
 
Example 7
Source File: abLyt.java    From Android-Music-Player with MIT License 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
	switch (event.getAction()) {
	case MotionEvent.ACTION_DOWN:
		onDown(event);
	case MotionEvent.ACTION_MOVE:
		onMove(event);
		break;
	case MotionEvent.ACTION_OUTSIDE:
		onOut(event);
	case MotionEvent.ACTION_UP:
		onUp(event);
		break;
	default:
		onleave(event);
	}
	invalidate();
	super.onTouchEvent(event);
	return true;
}
 
Example 8
Source File: CircularImageView.java    From Conquer with Apache License 2.0 6 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
	// Check for clickable state and do nothing if disabled
	if (!this.isClickable()) {
		this.isSelected = false;
		return super.onTouchEvent(event);
	}

	// Set selected state based on Motion Event
	switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			this.isSelected = true;
			break;
		case MotionEvent.ACTION_UP:
		case MotionEvent.ACTION_SCROLL:
		case MotionEvent.ACTION_OUTSIDE:
		case MotionEvent.ACTION_CANCEL:
			this.isSelected = false;
			break;
	}

	// Redraw image and return super type
	this.invalidate();
	return super.dispatchTouchEvent(event);
}
 
Example 9
Source File: AbstractPowerMenu.java    From PowerMenu with Apache License 2.0 5 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
  if (event.getAction() == MotionEvent.ACTION_OUTSIDE && !showBackground) {
    dismiss();
    return true;
  }
  return false;
}
 
Example 10
Source File: Banner.java    From Banner with Apache License 2.0 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_OUTSIDE:
            startAutoPlay();
            break;
        case MotionEvent.ACTION_DOWN:
            stopAutoPlay();
            break;
    }
    return super.dispatchTouchEvent(ev);
}
 
Example 11
Source File: BannerViewPager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    int action = ev.getAction();
    if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL
            || action == MotionEvent.ACTION_OUTSIDE) {
        startAutoPlay();
    } else if (action == MotionEvent.ACTION_DOWN) {
        stopAutoPlay();
    }
    return super.dispatchTouchEvent(ev);
}
 
Example 12
Source File: NavigationTabStrip.java    From NavigationTabStrip with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(final MotionEvent event) {
    // Return if animation is running
    if (mAnimator.isRunning()) return true;
    // If is not idle state, return
    if (mScrollState != ViewPager.SCROLL_STATE_IDLE) return true;

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // Action down touch
            mIsActionDown = true;
            if (!mIsViewPagerMode) break;
            // Detect if we touch down on tab, later to move
            mIsTabActionDown = (int) (event.getX() / mTabSize) == mIndex;
            break;
        case MotionEvent.ACTION_MOVE:
            // If tab touched, so move
            if (mIsTabActionDown) {
                mViewPager.setCurrentItem((int) (event.getX() / mTabSize), true);
                break;
            }
            if (mIsActionDown) break;
        case MotionEvent.ACTION_UP:
            // Press up and set tab index relative to current coordinate
            if (mIsActionDown) setTabIndex((int) (event.getX() / mTabSize));
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_OUTSIDE:
        default:
            // Reset action touch variables
            mIsTabActionDown = false;
            mIsActionDown = false;
            break;
    }

    return true;
}
 
Example 13
Source File: PopupWindow.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** @hide */
public boolean shouldCloseOnTouch(MotionEvent event) {
    if (mCloseOnTouchOutside && (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE || isOutOfBounds(event)) && mDecor != null) {
        return true;
    }
    
    return false;
}
 
Example 14
Source File: MyRecyclerView.java    From Netease with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    Log.d("HorizontalImage", "parent onTouchEvent" + event.getAction());
    switch (event.getAction()) {
       /* 这段代码理论是不要的,因为onInterceptTouchEvent已经处理了所有情况,这里有少数情况会触发。
        case MotionEvent.ACTION_DOWN:
            getParent().requestDisallowInterceptTouchEvent(true);
            firstTime = true;
            x = event.getX();
            y = event.getY();
            break;*/
        case MotionEvent.ACTION_MOVE:
            if (firstTime) {
                float deltaX = Math.abs(x - event.getX());
                float deltaY = Math.abs(y - event.getY());

                if (deltaX > 1 || deltaY > 1) {
                    // 水平滑动距离大于两倍的垂直距离才判断为水平
                    if (deltaX > deltaY * 2) {
                        getParent().requestDisallowInterceptTouchEvent(true);
                    } else {
                        getParent().requestDisallowInterceptTouchEvent(false);
                    }
                    firstTime = false;
                }
            }
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_OUTSIDE:
            getParent().requestDisallowInterceptTouchEvent(false);
            ((HorizontalImageRecyclerViewAdapter)getAdapter()).isIntercept = false;
            break;
    }
    return super.onTouchEvent(event);

}
 
Example 15
Source File: PullToZoomListView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public boolean onTouchEvent(MotionEvent paramMotionEvent) {
    Log.d(TAG, "action = " + (0xFF & paramMotionEvent.getAction()));
    if (mHeaderView != null && !isHideHeader && isEnableZoom) {
        switch (0xFF & paramMotionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_OUTSIDE:
                if (!mScalingRunnable.isFinished()) {
                    mScalingRunnable.abortAnimation();
                }
                mLastMotionY = paramMotionEvent.getY();
                mActivePointerId = paramMotionEvent.getPointerId(0);
                mMaxScale = (mScreenHeight / mHeaderHeight);
                mLastScale = (mHeaderContainer.getBottom() / mHeaderHeight);
                break;
            case MotionEvent.ACTION_MOVE:
                Log.d(TAG, "mActivePointerId" + mActivePointerId);
                int j = paramMotionEvent.findPointerIndex(mActivePointerId);
                if (j == INVALID_VALUE) {
                    Log.e("PullToZoomListView", "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
                } else {
                    if (mLastMotionY == -1.0F) {
                        mLastMotionY = paramMotionEvent.getY(j);
                    }
                    if (mHeaderContainer.getBottom() >= mHeaderHeight) {
                        ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
                        float f = ((paramMotionEvent.getY(j) - mLastMotionY + mHeaderContainer.getBottom()) / mHeaderHeight - mLastScale) / 2.0F + mLastScale;
                        if ((mLastScale <= 1.0D) && (f < mLastScale)) {
                            localLayoutParams.height = mHeaderHeight;
                            mHeaderContainer.setLayoutParams(localLayoutParams);
                            return super.onTouchEvent(paramMotionEvent);
                        }
                        mLastScale = Math.min(Math.max(f, 1.0F), mMaxScale);
                        localLayoutParams.height = ((int) (mHeaderHeight * mLastScale));
                        if (localLayoutParams.height < mScreenHeight) {
                            mHeaderContainer.setLayoutParams(localLayoutParams);
                        }
                        mLastMotionY = paramMotionEvent.getY(j);
                        return true;
                    }
                    mLastMotionY = paramMotionEvent.getY(j);
                }
                break;
            case MotionEvent.ACTION_UP:
                reset();
                endScaling();
                break;
            case MotionEvent.ACTION_CANCEL:
                int i = paramMotionEvent.getActionIndex();
                mLastMotionY = paramMotionEvent.getY(i);
                mActivePointerId = paramMotionEvent.getPointerId(i);
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                onSecondaryPointerUp(paramMotionEvent);
                mLastMotionY = paramMotionEvent.getY(paramMotionEvent.findPointerIndex(mActivePointerId));
                break;
        }
    }
    return super.onTouchEvent(paramMotionEvent);
}
 
Example 16
Source File: PullToZoomListView.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean onTouchEvent(MotionEvent paramMotionEvent) {
    Log.d(TAG, "action = " + (0xFF & paramMotionEvent.getAction()));
    if (mHeaderView != null && !isHideHeader && isEnableZoom) {
        switch (0xFF & paramMotionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_OUTSIDE:
                if (!mScalingRunnable.isFinished()) {
                    mScalingRunnable.abortAnimation();
                }
                mLastMotionY = paramMotionEvent.getY();
                mActivePointerId = paramMotionEvent.getPointerId(0);
                mMaxScale = (mScreenHeight / mHeaderHeight);
                mLastScale = (mHeaderContainer.getBottom() / mHeaderHeight);
                break;
            case MotionEvent.ACTION_MOVE:
                Log.d(TAG, "mActivePointerId" + mActivePointerId);
                int j = paramMotionEvent.findPointerIndex(mActivePointerId);
                if (j == INVALID_VALUE) {
                    Log.e("PullToZoomListView", "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
                } else {
                    if (mLastMotionY == -1.0F) {
                        mLastMotionY = paramMotionEvent.getY(j);
                    }
                    if (mHeaderContainer.getBottom() >= mHeaderHeight) {
                        ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
                        float f = ((paramMotionEvent.getY(j) - mLastMotionY + mHeaderContainer.getBottom()) / mHeaderHeight - mLastScale) / 2.0F + mLastScale;
                        if ((mLastScale <= 1.0D) && (f < mLastScale)) {
                            localLayoutParams.height = mHeaderHeight;
                            mHeaderContainer.setLayoutParams(localLayoutParams);
                            return super.onTouchEvent(paramMotionEvent);
                        }
                        mLastScale = Math.min(Math.max(f, 1.0F), mMaxScale);
                        localLayoutParams.height = ((int) (mHeaderHeight * mLastScale));
                        if (localLayoutParams.height < mScreenHeight) {
                            mHeaderContainer.setLayoutParams(localLayoutParams);
                        }
                        mLastMotionY = paramMotionEvent.getY(j);
                        return true;
                    }
                    mLastMotionY = paramMotionEvent.getY(j);
                }
                break;
            case MotionEvent.ACTION_UP:
                reset();
                endScaling();
                break;
            case MotionEvent.ACTION_CANCEL:
                int i = paramMotionEvent.getActionIndex();
                mLastMotionY = paramMotionEvent.getY(i);
                mActivePointerId = paramMotionEvent.getPointerId(i);
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                onSecondaryPointerUp(paramMotionEvent);
                mLastMotionY = paramMotionEvent.getY(paramMotionEvent.findPointerIndex(mActivePointerId));
                break;
        }
    }
    return super.onTouchEvent(paramMotionEvent);
}
 
Example 17
Source File: SwitchButton.java    From umeng_community_android with MIT License 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN: {
            // 如果按钮当前可用并且按下位置正好在按钮之内
            if (isEnabled() && buttonRectF.contains(event.getX(), event.getY())) {
                touchMode = TOUCH_MODE_DOWN;
                tempTotalSlideDistance = 0; // 清空总滑动距离
                touchX = event.getX(); // 记录X轴坐标
                setClickable(false); // 当用户触摸在按钮位置的时候禁用点击效果,这样做的目的是为了不让背景有按下效果
            }
            break;
        }

        case MotionEvent.ACTION_MOVE: {
            switch (touchMode) {
                case TOUCH_MODE_IDLE: {
                    break;
                }
                case TOUCH_MODE_DOWN: {
                    final float x = event.getX();
                    if (Math.abs(x - touchX) > touchSlop) {
                        touchMode = TOUCH_MODE_DRAGGING;
                        // 禁值父View拦截触摸事件
                        // 如果不加这段代码的话,当被ScrollView包括的时候,你会发现,当你在此按钮上按下,
                        // 紧接着滑动的时候ScrollView会跟着滑动,然后按钮的事件就丢失了,这会造成很难完成滑动操作
                        // 这样一来用户会抓狂的,加上这句话呢ScrollView就不会滚动了
                        if (getParent() != null) {
                            getParent().requestDisallowInterceptTouchEvent(true);
                        }
                        touchX = x;
                        return true;
                    }
                    break;
                }
                case TOUCH_MODE_DRAGGING: {
                    float newTouchX = event.getX();
                    tempTotalSlideDistance += setSlideX(tempSlideX
                            + ((int) (newTouchX - touchX))); // 更新X轴坐标并记录总滑动距离
                    touchX = newTouchX;
                    invalidate();
                    return true;
                }
            }
            break;
        }

        case MotionEvent.ACTION_UP: {
            setClickable(true);

            // 结尾滑动操作
            if (touchMode == TOUCH_MODE_DRAGGING) {// 这是滑动操作
                touchMode = TOUCH_MODE_IDLE;
                // 如果滑动距离大于等于最小切换距离就切换状态,否则回滚
                if (Math.abs(tempTotalSlideDistance) >= Math.abs(frameDrawable
                        .getIntrinsicWidth() * minChangeDistanceScale)) {
                    toggle(); // 切换状态
                } else {
                    switchScroller.startScroll(isChecked());
                }
            } else if (touchMode == TOUCH_MODE_DOWN) { // 这是按在按钮上的单击操作
                touchMode = TOUCH_MODE_IDLE;
                toggle();
            }
            break;
        }

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_OUTSIDE: {
            setClickable(true);
            if (touchMode == TOUCH_MODE_DRAGGING) {
                touchMode = TOUCH_MODE_IDLE;
                switchScroller.startScroll(isChecked()); // 回滚
            } else {
                touchMode = TOUCH_MODE_IDLE;
            }
            break;
        }
    }

    super.onTouchEvent(event);
    return isEnabled();
}
 
Example 18
Source File: PullToZoomListView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public boolean onTouchEvent(MotionEvent paramMotionEvent) {
    Log.d(TAG, "action = " + (0xFF & paramMotionEvent.getAction()));
    if (mHeaderView != null && !isHideHeader && isEnableZoom) {
        switch (0xFF & paramMotionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_OUTSIDE:
                if (!mScalingRunnable.isFinished()) {
                    mScalingRunnable.abortAnimation();
                }
                mLastMotionY = paramMotionEvent.getY();
                mActivePointerId = paramMotionEvent.getPointerId(0);
                mMaxScale = (mScreenHeight / mHeaderHeight);
                mLastScale = (mHeaderContainer.getBottom() / mHeaderHeight);
                break;
            case MotionEvent.ACTION_MOVE:
                Log.d(TAG, "mActivePointerId" + mActivePointerId);
                int j = paramMotionEvent.findPointerIndex(mActivePointerId);
                if (j == INVALID_VALUE) {
                    Log.e("PullToZoomListView", "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
                } else {
                    if (mLastMotionY == -1.0F) {
                        mLastMotionY = paramMotionEvent.getY(j);
                    }
                    if (mHeaderContainer.getBottom() >= mHeaderHeight) {
                        ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
                        float f = ((paramMotionEvent.getY(j) - mLastMotionY + mHeaderContainer.getBottom()) / mHeaderHeight - mLastScale) / 2.0F + mLastScale;
                        if ((mLastScale <= 1.0D) && (f < mLastScale)) {
                            localLayoutParams.height = mHeaderHeight;
                            mHeaderContainer.setLayoutParams(localLayoutParams);
                            return super.onTouchEvent(paramMotionEvent);
                        }
                        mLastScale = Math.min(Math.max(f, 1.0F), mMaxScale);
                        localLayoutParams.height = ((int) (mHeaderHeight * mLastScale));
                        if (localLayoutParams.height < mScreenHeight) {
                            mHeaderContainer.setLayoutParams(localLayoutParams);
                        }
                        mLastMotionY = paramMotionEvent.getY(j);
                        return true;
                    }
                    mLastMotionY = paramMotionEvent.getY(j);
                }
                break;
            case MotionEvent.ACTION_UP:
                reset();
                endScaling();
                break;
            case MotionEvent.ACTION_CANCEL:
                int i = paramMotionEvent.getActionIndex();
                mLastMotionY = paramMotionEvent.getY(i);
                mActivePointerId = paramMotionEvent.getPointerId(i);
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                onSecondaryPointerUp(paramMotionEvent);
                mLastMotionY = paramMotionEvent.getY(paramMotionEvent.findPointerIndex(mActivePointerId));
                break;
        }
    }
    return super.onTouchEvent(paramMotionEvent);
}
 
Example 19
Source File: LineColorPicker.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

	int actionId = event.getAction();

	int newColor;

	switch (actionId) {
	case MotionEvent.ACTION_DOWN:
		isClick = true;
		break;
	case MotionEvent.ACTION_UP:
		newColor = getColorAtXY(event.getX(), event.getY());

		setSelectedColor(newColor);

		if (isClick) {
			performClick();
		}

		break;

	case MotionEvent.ACTION_MOVE:
		newColor = getColorAtXY(event.getX(), event.getY());

		setSelectedColor(newColor);

		break;
	case MotionEvent.ACTION_CANCEL:
		isClick = false;
		break;

	case MotionEvent.ACTION_OUTSIDE:
		isClick = false;
		break;

	default:
		break;
	}

	return true;
}
 
Example 20
Source File: LineColorPicker.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

	int actionId = event.getAction();

	int newColor;

	switch (actionId) {
	case MotionEvent.ACTION_DOWN:
		isClick = true;
		break;
	case MotionEvent.ACTION_UP:
		newColor = getColorAtXY(event.getX(), event.getY());

		setSelectedColor(newColor);

		if (isClick) {
			performClick();
		}

		break;

	case MotionEvent.ACTION_MOVE:
		newColor = getColorAtXY(event.getX(), event.getY());

		setSelectedColor(newColor);

		break;
	case MotionEvent.ACTION_CANCEL:
		isClick = false;
		break;

	case MotionEvent.ACTION_OUTSIDE:
		isClick = false;
		break;

	default:
		break;
	}

	return true;
}