當前位置: 首頁>>代碼示例>>Java>>正文


Java MotionEvent.ACTION_UP屬性代碼示例

本文整理匯總了Java中android.view.MotionEvent.ACTION_UP屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.ACTION_UP屬性的具體用法?Java MotionEvent.ACTION_UP怎麽用?Java MotionEvent.ACTION_UP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.ACTION_UP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTouchEvent

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    int action = event.getActionMasked();
    Editable text = getText();

    if (text != null && action == MotionEvent.ACTION_UP) {
        int offset = getOffsetForPosition(event.getX(), event.getY());

        if (offset != -1) {
            TokenImageSpan[] links = text.getSpans(offset, offset, RecipientTokenSpan.class);
            if (links.length > 0) {
                showAlternates(links[0].getToken());
                return true;
            }
        }
    }

    return super.onTouchEvent(event);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:19,代碼來源:RecipientSelectView.java

示例2: onTouch

/**
 * 當有觸摸時停止
 */
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    mHandler.removeMessages(LOOP_MSG);
    switch (motionEvent.getAction()){
        case MotionEvent.ACTION_UP :
            if (isLoop) {
                mHandler.sendEmptyMessageDelayed(LOOP_MSG, mLoopTime);
            }
            break;

        default:
            break;
    }
    return false;
}
 
開發者ID:LillteZheng,項目名稱:ViewPagerHelper,代碼行數:18,代碼來源:BannerViewPager.java

示例3: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()){
        case MotionEvent.ACTION_DOWN:
            mPath.moveTo(event.getX(),event.getY());
            mPreX = event.getX();
            mPreY = event.getY();
            return true;
        case MotionEvent.ACTION_MOVE:
            float endX = (mPreX+event.getX())/2;
            float endY = (mPreY+event.getY())/2;
            mPath.quadTo(mPreX,mPreY,endX,endY);
            mPreX = event.getX();
            mPreY =event.getY();
            break;
        case MotionEvent.ACTION_UP:
            break;
    }
    postInvalidate();
    return super.onTouchEvent(event);
}
 
開發者ID:halohoop,項目名稱:AndroidDigIn,代碼行數:21,代碼來源:EraserView_SRCOUT.java

示例4: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            startTouch(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_MOVE:
            moveTouch(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_UP:
            upTouch();
            invalidate();
            break;
    }
    return true;
}
 
開發者ID:ajithvgiri,項目名稱:Canvas-Library,代碼行數:21,代碼來源:CanvasView.java

示例5: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!isEnabled()) {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(ev) & MotionEventCompat.ACTION_MASK) {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            viewDragHelper.cancel();
            return false;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            activePointerId = MotionEventCompat.getPointerId(ev, index);
            if (activePointerId == INVALID_VIEW_POINTER) {
                return false;
            }
            break;
        default:
            break;
    }
    boolean interceptTap = viewDragHelper.isViewUnder(dragView, (int) ev.getX(), (int) ev.getY());
    return viewDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
}
 
開發者ID:mugku,項目名稱:slidingplayersampleapp,代碼行數:23,代碼來源:SlidingViewK.java

示例6: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
	if(event.getAction() == MotionEvent.ACTION_DOWN)
	{
		down = true;
		setPosition((int)event.getY());
		return true;
	}
	if(event.getAction() == MotionEvent.ACTION_UP)
	{
		down = false;
		return true;
	}
	if(down && event.getAction() == MotionEvent.ACTION_MOVE)
	{
		setPosition((int)event.getY());
		return true;
	}
	return super.onTouchEvent(event);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:20,代碼來源:HsvAlphaSelectorView.java

示例7: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {

    if (ev.getAction() == MotionEvent.ACTION_UP) {
        // 開始翻頁
        if (canTurn)startTurning(autoTurningTime);
    } else if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        // 停止翻頁
        if (canTurn)stopTurning();
    }
    return super.dispatchTouchEvent(ev);
}
 
開發者ID:AndroidBoySC,項目名稱:Mybilibili,代碼行數:12,代碼來源:ConvenientBanner.java

示例8: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    if ( event.getAction() == MotionEvent.ACTION_UP) {
        GET_AGE=true;
    }
    return super.onTouchEvent(event);
}
 
開發者ID:spacejake,項目名稱:android-age-estimator,代碼行數:7,代碼來源:MainActivity.java

示例9: onInterceptTouchEvent

/**
 * Override method to intercept only touch events over the drag view and to cancel the drag when
 * the action associated to the MotionEvent is equals to ACTION_CANCEL or ACTION_UP.
 *
 * @param ev captured.
 * @return true if the view is going to process the touch event or false if not.
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
    if (!isEnabled())
    {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(ev) & MotionEventCompat.ACTION_MASK)
    {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            viewDragHelper.cancel();
            return false;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            activePointerId = MotionEventCompat.getPointerId(ev, index);
            if (activePointerId == INVALID_POINTER)
            {
                return false;
            }
            break;
        default:
            break;
    }
    boolean interceptTap = viewDragHelper.isViewUnder(dragView, (int) ev.getX(), (int) ev.getY());
    return viewDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
}
 
開發者ID:jbmlaird,項目名稱:DiscogsBrowser,代碼行數:34,代碼來源:DraggableView.java

示例10: onTouch

@Override
public boolean onTouch(View v, MotionEvent ev) {

    if (ev.getAction() == MotionEvent.ACTION_UP)
    {
        mAdapter.add("" + ev.getAxisValue(0) + ", " + ev.getAxisValue(1));

        try {
            FileOutputStream fos = openFileOutput ("MousePos.txt", Context.MODE_APPEND);
            FileChannel outChannel = fos.getChannel();

            float[] pos = new float[2];
            pos[0] = ev.getAxisValue(0);
            pos[1] = ev.getAxisValue(1);

            ByteBuffer buff = ByteBuffer.allocate(4*2);
            buff.clear();
            buff.asFloatBuffer().put(pos);

            outChannel.write(buff);
            outChannel.close();
            fos.close();

            FileInputStream fis = openFileInput ("MousePos.txt");
            int a = fis.available();
            int b = 0;

        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }

    return false;
}
 
開發者ID:jjuiddong,項目名稱:Android-Practice,代碼行數:34,代碼來源:MainActivity.java

示例11: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
	if (isEnabled()) {
		isLastTouch = true;
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			radius = getHeight() / rippleSize;
			x = event.getX();
			y = event.getY();
		} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
			radius = getHeight() / rippleSize;
			x = event.getX();
			y = event.getY();
			if (!((event.getX() <= getWidth() && event.getX() >= 0) && 
					(event.getY() <= getHeight() && event.getY() >= 0))) {
				isLastTouch = false;
				x = -1;
				y = -1;
			}
		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			if ((event.getX() <= getWidth() && event.getX() >= 0)
					&& (event.getY() <= getHeight() && event.getY() >= 0)) {
				radius++;
			} else {
				isLastTouch = false;
				x = -1;
				y = -1;
			}
			if (clickAfterRipple == false && onClickListener != null) {
				onClickListener.onClick(this);
			}
		}
	}
	return true;
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:34,代碼來源:RippleView.java

示例12: onTouch

@Override
public boolean onTouch(View v, MotionEvent event) {
  int action = event.getAction();
  if (mOnActivePseudoListner != null) {
    if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) {
      mOnActivePseudoListner.updateActivePseudo(true);
    } else if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
      mOnActivePseudoListner.updateActivePseudo(false);
    }
  }
  return mIsConsumeOnTouch;
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:12,代碼來源:TouchActivePseudoListener.java

示例13: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mSlideable == false)
        return super.onTouchEvent(event);
    int action = MotionEventCompat.getActionMasked(event);
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mEventStartX = (int) event.getRawX();
            break;
        case MotionEvent.ACTION_MOVE:
            mEventLastX = (int) event.getRawX();
            mDiffX = mEventLastX - mEventStartX;
            int tempX = mDiffX + mFrontRectLeftBegin;
            tempX = (tempX > mMaxLeft ? mMaxLeft : tempX);
            tempX = (tempX < mMinLeft ? mMinLeft : tempX);
            if (tempX >= mMinLeft && tempX <= mMaxLeft) {
                mFrontRectLeft = tempX;
                mAlpha = (int) (255 * (float) tempX / (float) mMaxLeft);
                invalidateView();
            }
            break;
        case MotionEvent.ACTION_UP:
            int wholeX = (int) (event.getRawX() - mEventStartX);
            mFrontRectLeftBegin = mFrontRectLeft;
            boolean toRight;
            toRight = (mFrontRectLeftBegin > mMaxLeft / 2 ? true : false);
            if (Math.abs(wholeX) < 3) {
                toRight = !toRight;
            }
            moveToDest(toRight);
            break;
        default:
            break;
    }
    return true;
}
 
開發者ID:TechIsFun,項目名稱:SlidingSwitch,代碼行數:36,代碼來源:SlidingSwitchBase.java

示例14: onTouch

@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    final int x = (int) motionEvent.getX();
    if (mClearTextIcon.isVisible() && x > getWidth() - getPaddingRight() - mClearTextIcon.getIntrinsicWidth()) {
        if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
            setError(null);
            setText("");
        }
        return true;
    }
    return mOnTouchListener != null && mOnTouchListener.onTouch(view, motionEvent);
}
 
開發者ID:iTXTech,項目名稱:Daedalus,代碼行數:12,代碼來源:ClearAutoCompleteTextView.java

示例15: handleItemDragEvent

public boolean handleItemDragEvent(MotionEvent event){
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            mDownX = (int)event.getRawX();
            mDownY = (int)event.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            if(mDownY == -1){
                mDownY = (int)event.getRawY();

            }
            if(mDownX == -1){
                mDownX = (int)event.getRawX();
            }
            if(mScrollDownY == -1){
                mScrollDownY = mRootLayout.getScrollY();
            }

            mLastEventX = (int) event.getRawX();
            mLastEventY = (int) event.getRawY();
            int deltaX = mLastEventX - mDownX;
            int deltaY = mLastEventY - mDownY;

            if (mCellIsMobile) {
                int location[] = new int[2];
                mobileView.getLocationOnScreen(location);
                int root_location[] = new int[2];
                mRootLayout.getLocationOnScreen(root_location);
                int offsetX = deltaX-root_location[0];
                int offsetY = location[1]+deltaY-root_location[1]+mRootLayout.getScrollY()-mScrollDownY;
                mHoverCellCurrentBounds.offsetTo(offsetX,
                        offsetY);
                mHoverCell.setBounds(rotatedBounds(mHoverCellCurrentBounds,0.0523599f));
                invalidate();
                handleItemDrag();
                return true;
            }
            break;
        case MotionEvent.ACTION_UP:
            touchEventsCancelled();
            break;
        case MotionEvent.ACTION_CANCEL:
            touchEventsCancelled();
            break;
        case MotionEvent.ACTION_POINTER_UP:
            break;
        default:
            break;
    }
    return false;
}
 
開發者ID:tangqipeng,項目名稱:draggable-tree-itemview,代碼行數:51,代碼來源:DraggableTreeView.java


注:本文中的android.view.MotionEvent.ACTION_UP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。