当前位置: 首页>>代码示例>>Java>>正文


Java MotionEvent.getDownTime方法代码示例

本文整理汇总了Java中android.view.MotionEvent.getDownTime方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.getDownTime方法的具体用法?Java MotionEvent.getDownTime怎么用?Java MotionEvent.getDownTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.getDownTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInterceptTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
  final long downTime = ev.getDownTime();
  if (downTime != mLastTouchDownTime) {
    mLastTouchDownTime = downTime;
    if (interceptsTouchEvent(ev.getX(), ev.getY())) {
      return true;
    }
  }

  if (mOnInterceptTouchEventListener != null &&
      mOnInterceptTouchEventListener.onInterceptTouchEvent(this, ev)) {
    return true;
  }
  // We intercept the touch event if the children are not supposed to receive it.
  if (mPointerEvents == PointerEvents.NONE || mPointerEvents == PointerEvents.BOX_ONLY) {
    return true;
  }
  return super.onInterceptTouchEvent(ev);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:21,代码来源:FlatViewGroup.java

示例2: sendMouseEventCode

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * Send a single mouse event code to the terminal.
 */
void sendMouseEventCode(MotionEvent e, int button, boolean pressed) {
    int x = (int) (e.getX() / mRenderer.mFontWidth) + 1;
    int y = (int) ((e.getY() - mRenderer.mFontLineSpacingAndAscent) / mRenderer.mFontLineSpacing) + 1;
    if (pressed && (button == TerminalEmulator.MOUSE_WHEELDOWN_BUTTON || button == TerminalEmulator.MOUSE_WHEELUP_BUTTON)) {
        if (mMouseStartDownTime == e.getDownTime()) {
            x = mMouseScrollStartX;
            y = mMouseScrollStartY;
        } else {
            mMouseStartDownTime = e.getDownTime();
            mMouseScrollStartX = x;
            mMouseScrollStartY = y;
        }
    }
    mEmulator.sendMouseEvent(button, x, y, pressed);
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:19,代码来源:TerminalView.java

示例3: isClickEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
private boolean isClickEvent(float startX, float startY, MotionEvent event) {
    float duration = event.getEventTime() - event.getDownTime();
    if (duration > MAX_CLICK_DURATION) {
        return false;
    }

    float differenceX = Math.abs(startX - event.getX());
    float differenceY = Math.abs(startY - event.getY());
    return !(differenceX > MAX_CLICK_DISTANCE || differenceY > MAX_CLICK_DISTANCE);
}
 
开发者ID:ome450901,项目名称:SimpleRatingBar,代码行数:11,代码来源:BaseRatingBar.java

示例4: onTouchMove

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public void onTouchMove(MotionEvent event) {
    if (!hold && event.getEventTime() - event.getDownTime() >= holdDelay) {
        hold = true;
        onVibrate(100);
    }
}
 
开发者ID:Elbehiry,项目名称:Pc-Control,代码行数:8,代码来源:MousePresenter.java

示例5: onTouchMoveMouseMove

import android.view.MotionEvent; //导入方法依赖的package包/类
private void onTouchMoveMouseMove(MotionEvent event) {
    if (holdPossible) {
        if (getDistanceFromDown(event) > immobileDistance) {
            holdPossible = false;
        } else if (event.getEventTime() - event.getDownTime() > this.holdDelay) {
            onMouseClick(MouseClickAction.STATE_DOWN, MouseClickAction.BUTTON_LEFT);
            holdPossible = false;
            setHold(true);
            onVibrate(100);
        }
    }

    float moveRawX = event.getRawX() - movePreviousX;
    float moveRawY = event.getRawY() - movePreviousY;

    moveRawX *= moveSensitivity;
    moveRawY *= moveSensitivity;

    moveRawX = (float) ((Math.pow(Math.abs(moveRawX), moveAcceleration) * Math.signum(moveRawX)));
    moveRawY = (float) ((Math.pow(Math.abs(moveRawY), moveAcceleration) * Math.signum(moveRawY)));

    moveRawX += moveResultX;
    moveRawY += moveResultY;

    int moveXFinal = Math.round(moveRawX);
    int moveYFinal = Math.round(moveRawY);

    if (moveXFinal != 0 || moveYFinal != 0) {
        mouseMove(moveXFinal, moveYFinal);
    }

    moveResultX = moveRawX - moveXFinal;
    moveResultY = moveRawY - moveYFinal;

    movePreviousX = event.getRawX();
    movePreviousY = event.getRawY();
}
 
开发者ID:Elbehiry,项目名称:Pc-Control,代码行数:38,代码来源:MousePresenter.java

示例6: handleDebugLayout

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * 多点按下, 是否处理
 */
protected boolean handleDebugLayout(MotionEvent ev) {
    int actionMasked = ev.getActionMasked();
    long downTime = ev.getDownTime();
    if (actionMasked == MotionEvent.ACTION_DOWN) {
        firstDownTime = downTime;
    }

    if (L.LOG_DEBUG &&
            showDebugLayout &&
            actionMasked == MotionEvent.ACTION_POINTER_DOWN &&
            ev.getPointerCount() == 6) {

        if (ev.getEventTime() - firstDownTime < 500) {
            //快速三指按下才受理操作

            //debug模式下, 三指按下
            if (isInDebugLayout) {
                closeDebugLayout();
            } else {
                startDebugLayout();
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:30,代码来源:UILayoutImpl.java

示例7: onDown

import android.view.MotionEvent; //导入方法依赖的package包/类
public boolean onDown(MotionEvent e) {
	if(DBG) Log.d(TAG, "onDown: stopScrollingAnim");
	if (mAnimHandler.isSpeedScrollingAnimating()) {
		mAnimHandler.stopScrollingAnimation();
		// Remember down time stopping scrolling so that it is not used for onClick file opening
		mThisOnDownMustNotOpen = e.getDownTime();
	}
	return true;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:10,代码来源:CoverGLSurfaceView.java

示例8: onSingleTapConfirmed

import android.view.MotionEvent; //导入方法依赖的package包/类
public boolean onSingleTapConfirmed(MotionEvent e) {
	final int x=(int)e.getX();
	final int y=(int)e.getY();
	Log.d(TAG,"onSingleTapConfirmed " + x + " " + y);

	// If the down event has been used to stop scrolling, it must not open the file
	if (e.getDownTime() == mThisOnDownMustNotOpen) {
		Log.d(TAG, "onSingleTapConfirmed: don't open item because view was scrolling!");
		return true; // has been consumed to stop the scrolling
	}

	// Ask the 3D world coordinates to the GL thread.
	// Will reply using the RendererListener
	/* 2010-10-26 STOP with this crappy 3D picking for now...
	queueEvent(new Runnable(){
		public void run() {
			mRenderer.click(x,y);
		}});
	 */   // Use a more basic hard-coded 2D operation instead:

	// Ask the layout for a basic 2D pseudo-picking
	Integer tappedCoverId = mLayout.getCoverIndexAtPosition(x, y);
	if (tappedCoverId==null) {
		if(DBG) Log.d(TAG,"Found no cover at the click point!");
		return false;
	}
	// If the clicked cover is the front one, we open the browser
	if (tappedCoverId.intValue() == mLayout.getFrontCoverIndex()) {
		// Animations intent will be launched at the end of the click animation
		mAnimHandler.startItemClickAnimation(tappedCoverId, getOpenAction(tappedCoverId), 0);
		mAnimHandler.startBackgroundCoversFadeOutAnimation();
	}
	// If the clicked cover is not the front one, put it to front position
	else {
		float targetScroll = mLayout.getScrollingPositionToCenterThisCover(tappedCoverId);
		mAnimHandler.startScrollingAnimPosition(targetScroll, AnimHandler.SPEED_FAST);
	}

	return true;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:41,代码来源:CoverGLSurfaceView.java

示例9: dispatchTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    int actionMasked = MotionEventCompat.getActionMasked(ev);
    if (actionMasked == MotionEvent.ACTION_DOWN) {
        isFling = false;

        fastDownX = ev.getX();
        fastDownY = ev.getY();
        fastDownTime = ev.getDownTime();

        if (enableScroll && isEnabled()) {
            stopAutoScroll();
        }
    } else if (actionMasked == MotionEvent.ACTION_UP ||
            actionMasked == MotionEvent.ACTION_CANCEL) {

        if (actionMasked == MotionEvent.ACTION_UP &&
                mOnFastTouchListener != null) {

            long eventTime = ev.getEventTime();
            int dv = 10;
            if (eventTime - fastDownTime <= OnFastTouchListener.FAST_TIME) {
                float x = ev.getX();
                float y = ev.getY();
                if (Math.abs(x - fastDownX) <= dv && Math.abs(y - fastDownY) <= dv) {
                    mOnFastTouchListener.onFastClick();
                }
            }
        }

        if (enableScroll && isEnabled()) {
            startAutoScroll();
        }
    }
    return super.dispatchTouchEvent(ev);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:37,代码来源:RRecyclerView.java

示例10: onActionUp

import android.view.MotionEvent; //导入方法依赖的package包/类
private void onActionUp(MotionEvent event)
{
    long duration = event.getEventTime() - event.getDownTime();
    if (duration < mClickTimeout
            && mTouchHelper.getDeltaXFrom(FTouchHelper.EVENT_DOWN) < mTouchSlop
            && mTouchHelper.getDeltaYFrom(FTouchHelper.EVENT_DOWN) < mTouchSlop)
    {
        toggleChecked(mAttrModel.isNeedToggleAnim(), true);
    } else
    {
        if (mTouchHelper.isNeedCosume())
        {
            final int left = mViewThumb.getLeft();
            final boolean checked = left >= ((getLeftNormal() + getLeftChecked()) / 2);

            boolean updatePosition = false;
            if (checked)
            {
                if (left != getLeftChecked())
                {
                    updatePosition = true;
                }
            } else
            {
                if (left != getLeftNormal())
                {
                    updatePosition = true;
                }
            }

            if (setChecked(checked, true, true))
            {
                // 更新状态成功,内部会更新view的位置
            } else
            {
                if (updatePosition)
                {
                    updateViewByState(true);
                }
            }
        }
    }
}
 
开发者ID:zj565061763,项目名称:switchbutton,代码行数:44,代码来源:FSwitchButton.java

示例11: onTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {

	if (!isEnabled() || !isClickable() || !isFocusable()) {
		return false;
	}

	int action = event.getAction();

	float deltaX = event.getX() - mStartX;
	float deltaY = event.getY() - mStartY;

	// status the view going to change to when finger released
	boolean nextStatus;

	switch (action) {
		case MotionEvent.ACTION_DOWN:
			catchView();
			mStartX = event.getX();
			mStartY = event.getY();
			mLastX = mStartX;
			setPressed(true);
			break;

		case MotionEvent.ACTION_MOVE:
			float x = event.getX();
			setProcess(getProcess() + (x - mLastX) / mSafeRectF.width());
			mLastX = x;
			break;

		case MotionEvent.ACTION_CANCEL:
		case MotionEvent.ACTION_UP:
			setPressed(false);
			nextStatus = getStatusBasedOnPos();
			float time = event.getEventTime() - event.getDownTime();
			if (deltaX < mTouchSlop && deltaY < mTouchSlop && time < mClickTimeout) {
				performClick();
			} else {
				if (nextStatus != isChecked()) {
					playSoundEffect(SoundEffectConstants.CLICK);
					setChecked(nextStatus);
				} else {
					animateToState(nextStatus);
				}
			}
			break;

		default:
			break;
	}
	return true;
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:53,代码来源:SwitchButton.java

示例12: onTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (getParent() != null) {
        getParent().requestDisallowInterceptTouchEvent(true);
    }

    if (isOnAnimator) {
        return false;
    }
    int action = event.getAction();

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            onTouchMove = true;
            if (mScroller.computeScrollOffset()) {
                mScroller.abortAnimation();
                invalidate();
                requestLayout();
            }
            touchBegan(event);
            touchViewItem = getTopView();
            isOnTopView = inRangeOfView(touchViewItem, event);
            downX = event.getX();
            downY = event.getY();
            if (isOnTopView) {
                sendLongClickAction();
            }
            return true;
        case MotionEvent.ACTION_MOVE:
            touchMoved(event);

            if (Math.abs(downX - event.getX()) >= 10
                    || Math.abs(downY - event.getY()) >= 10) { //10像素以外,不属于点击事件
                removeLongClickAction();
                touchViewItem = null;
                isOnTopView = false;
            }

            return true;
        case MotionEvent.ACTION_UP:
            removeLongClickAction();
            if (isOnTopView && touchViewItem == getTopView()
                    && inRangeOfView(touchViewItem, event)) {
                if (mTopViewClickLister != null) {
                    mTopViewClickLister.onClick(getTopViewPosition(), getTopView());
                }
            }

            touchViewItem = null;
            isOnTopView = false;
            touchEnded(event);

            //不是点击top view。并且启用点击切换。并且点击了
            if (!isOnTopView && clickSwitchEnable
                    && Math.abs(downX - event.getX()) < 10
                    && Math.abs(downY - event.getY()) < 10
                    && event.getEventTime() - event.getDownTime() < 500) {
                if (atLeftOfView(getTopView(), event)) {
                    gotoPrevious();
                } else if (atRightOfView(getTopView(), event)) {
                    gotoForward();
                }
            }
            return true;
    }

    return false;
}
 
开发者ID:xieyangxuejun,项目名称:Views,代码行数:69,代码来源:CoverFlowView.java

示例13: onTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * 触摸触发事件
 * @param event 触摸事件
 * @return 是否已处理
 */
@Override
public boolean onTouchEvent(MotionEvent event) {
    int action = event.getAction();
    float x = event.getX();
    float y = event.getY();
    float deltaX = Math.abs(x - mFirstDownX);
    float deltaY = Math.abs(y - mFirstDownY);
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            attemptClaimDrag();
            mFirstDownX = x;
            mFirstDownY = y;
            mCurBtnPic = mBtnPressed;
            mBtnInitPos = mChecked ? mBtnOnPos : mBtnOffPos;
            break;
        case MotionEvent.ACTION_MOVE:
            mBtnPos = mBtnInitPos + event.getX() - mFirstDownX;
            if (mBtnPos >= mBtnOffPos) {
                mBtnPos = mBtnOffPos;
            }
            if (mBtnPos <= mBtnOnPos) {
                mBtnPos = mBtnOnPos;
            }
            mTurningOn = mBtnPos > (mBtnOffPos - mBtnOnPos) / 2 + mBtnOnPos;

            mRealPos = getRealPos(mBtnPos);
            break;
        case MotionEvent.ACTION_UP:
            mCurBtnPic = mBtnNormal;
            float time = event.getEventTime() - event.getDownTime();
            if (deltaY < mTouchSlop && deltaX < mTouchSlop && time < mClickTimeout) {
                if (mPerformClick == null) {
                    mPerformClick = new PerformClick();
                }
                if (!post(mPerformClick)) {
                    performClick();
                }
            } else {
                startAnimation(!mTurningOn);
            }
            break;
    }

    invalidate();
    return isEnabled();
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:52,代码来源:SwitchButton.java

示例14: onTouch

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }
    mVelocityTracker.addMovement(event);
    int velocityX = 0;
    int velocityY = 0;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        updateTargetViewLocation();
        mShieldView.setVisibility(mShieldEnabled ? View.VISIBLE : View.GONE);
    } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
        if (event.getEventTime() - event.getDownTime() >= 150) {
            float accX = 0;
            float accY = 0;
            if (mVelocityTracker != null) {
                mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
                velocityX = (int) mVelocityTracker.getXVelocity();
                velocityY = (int) mVelocityTracker.getYVelocity();
                accX = velocityX / (mMaxVelocity);
                accY = velocityY / (mMaxVelocity);
            }
            dragView(event.getRawX() - mTargetWidth / 2,
                    event.getRawY() - mTargetHeight / 2 - mContentTopInWindow,
                    velocityX, velocityY, accX, accY);
            mChildren.get(mChildCount - 1).setClickable(false);
            return true;
        }

    } else if (event.getAction() == MotionEvent.ACTION_UP) {
        mChildren.get(mChildCount - 1).setClickable(true);
        if (event.getEventTime() - event.getDownTime() < 150) {
            mShieldView.setVisibility(View.GONE);
            return false;
        } else {
            releaseView();
            return true;
        }
    }
    return false;
}
 
开发者ID:devilist,项目名称:SnakeViewMaker,代码行数:42,代码来源:SnakeViewMaker.java

示例15: onTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {

    if (!isEnabled() || !isClickable()) {
        return false;
    }

    int action = event.getAction();

    float deltaX = event.getX() - mStartX;
    float deltaY = event.getY() - mStartY;

    // status the view going to change to when finger released
    boolean nextStatus;

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            catchView();
            mStartX = event.getX();
            mStartY = event.getY();
            mLastX = mStartX;
            setPressed(true);
            break;

        case MotionEvent.ACTION_MOVE:
            float x = event.getX();
            setProcess(getProcess() + (x - mLastX) / mSafeRectF.width());
            mLastX = x;
            break;

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            setPressed(false);
            nextStatus = getStatusBasedOnPos();
            float time = event.getEventTime() - event.getDownTime();
            if (deltaX < mTouchSlop && deltaY < mTouchSlop && time < mClickTimeout) {
                performClick();
            } else {
                if (nextStatus != isChecked()) {
                    playSoundEffect(SoundEffectConstants.CLICK);
                    setChecked(nextStatus);
                } else {
                    animateToState(nextStatus);
                }
            }
            break;

        default:
            break;
    }
    return true;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:53,代码来源:SwitchButton.java


注:本文中的android.view.MotionEvent.getDownTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。