List of usage examples for android.view MotionEvent ACTION_DOWN
int ACTION_DOWN
To view the source code for android.view MotionEvent ACTION_DOWN.
Click Source Link
From source file:com.android_mobile.core.ui.comp.banner.LoopViewPager.java
/** * ??/* ww w. ja v a 2 s . c o m*/ */ @Override public boolean dispatchTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { // if (getAdapter().getCount() > 0 && autoable) { startImageTimerTask(); } } else if (event.getAction() == MotionEvent.ACTION_DOWN) { // ? stopImageTimerTask(); } return super.dispatchTouchEvent(event); }
From source file:com.android.inputmethod.accessibility.KeyboardAccessibilityDelegate.java
/** * Perform click on a key.// ww w .j a va 2s. c om * * @param key A key to be registered. */ public void performClickOn(final Key key) { if (DEBUG_HOVER) { Log.d(TAG, "performClickOn: key=" + key); } simulateTouchEvent(MotionEvent.ACTION_DOWN, key); simulateTouchEvent(MotionEvent.ACTION_UP, key); }
From source file:cn.bingoogolapple.refreshlayout.BGAStickyNavLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { float currentTouchY = ev.getY(); switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mLastTouchY = currentTouchY;/* w ww . jav a 2 s . co m*/ break; case MotionEvent.ACTION_MOVE: float differentY = currentTouchY - mLastTouchY; if (Math.abs(differentY) > mTouchSlop) { if (!isHeaderViewCompleteInvisible() || (isContentViewToTop() && isHeaderViewCompleteInvisible() && mIsInControl)) { mLastTouchY = currentTouchY; return true; } } break; } return super.onInterceptTouchEvent(ev); }
From source file:com.android.hareime.accessibility.AccessibilityEntityProvider.java
/** * Simulates a key press by injecting touch events into the keyboard view. * This avoids the complexity of trackers and listeners within the keyboard. * * @param key The key to press.// ww w .j ava2 s . c om */ void simulateKeyPress(Key key) { final int x = key.mHitBox.centerX(); final int y = key.mHitBox.centerY(); final long downTime = SystemClock.uptimeMillis(); final MotionEvent downEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, x, y, 0); final MotionEvent upEvent = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0); mKeyboardView.onTouchEvent(downEvent); mKeyboardView.onTouchEvent(upEvent); }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardView.java
@Override public boolean onTouchEvent(@NonNull MotionEvent me) { if (getKeyboard() == null)//I mean, if there isn't any keyboard I'm handling, what's the point? return false; if (areTouchesDisabled(me)) { return super.onTouchEvent(me); }/* ww w . jav a 2 s. c o m*/ final int action = MotionEventCompat.getActionMasked(me); // Gesture detector must be enabled only when mini-keyboard is not // on the screen. if (!mMiniKeyboardPopup.isShowing() && mGestureDetector != null && mGestureDetector.onTouchEvent(me)) { Logger.d(TAG, "Gesture detected!"); mKeyPressTimingHandler.cancelAllMessages(); dismissAllKeyPreviews(); return true; } if (action == MotionEvent.ACTION_DOWN) { mFirstTouchPoint.x = (int) me.getX(); mFirstTouchPoint.y = (int) me.getY(); mIsFirstDownEventInsideSpaceBar = mSpaceBarKey != null && mSpaceBarKey.isInside(mFirstTouchPoint.x, mFirstTouchPoint.y); } // If the motion event is above the keyboard and it's a MOVE event // coming even before the first MOVE event into the extension area if (!mIsFirstDownEventInsideSpaceBar && me.getY() < mExtensionKeyboardYActivationPoint && !mMiniKeyboardPopup.isShowing() && !mExtensionVisible && action == MotionEvent.ACTION_MOVE) { if (mExtensionKeyboardAreaEntranceTime <= 0) mExtensionKeyboardAreaEntranceTime = SystemClock.uptimeMillis(); if (SystemClock.uptimeMillis() - mExtensionKeyboardAreaEntranceTime > DELAY_BEFORE_POPPING_UP_EXTENSION_KBD) { KeyboardExtension extKbd = ((ExternalAnyKeyboard) getKeyboard()).getExtensionLayout(); if (extKbd == null || extKbd.getKeyboardResId() == AddOn.INVALID_RES_ID) { Logger.i(TAG, "No extension keyboard"); return super.onTouchEvent(me); } else { // telling the main keyboard that the last touch was // canceled MotionEvent cancel = MotionEvent.obtain(me.getDownTime(), me.getEventTime(), MotionEvent.ACTION_CANCEL, me.getX(), me.getY(), 0); super.onTouchEvent(cancel); cancel.recycle(); mExtensionVisible = true; dismissAllKeyPreviews(); if (mExtensionKey == null) { mExtensionKey = new AnyKey(new Row(getKeyboard()), getThemedKeyboardDimens()); mExtensionKey.edgeFlags = 0; mExtensionKey.height = 1; mExtensionKey.width = 1; mExtensionKey.popupResId = extKbd.getKeyboardResId(); mExtensionKey.externalResourcePopupLayout = mExtensionKey.popupResId != 0; mExtensionKey.x = getWidth() / 2; mExtensionKey.y = mExtensionKeyboardPopupOffset; } // so the popup will be right above your finger. mExtensionKey.x = (int) me.getX(); onLongPress(extKbd, mExtensionKey, AnyApplication.getConfig().isStickyExtensionKeyboard(), getPointerTracker(me)); // it is an extension.. getMiniKeyboard().setPreviewEnabled(true); return true; } } else { return super.onTouchEvent(me); } } else if (mExtensionVisible && me.getY() > mExtensionKeyboardYDismissPoint) { // closing the popup dismissPopupKeyboard(); return true; } else { return super.onTouchEvent(me); } }
From source file:com.android.inputmethod.accessibility.AccessibilityEntityProvider.java
/** * Simulates a key press by injecting touch events into the keyboard view. * This avoids the complexity of trackers and listeners within the keyboard. * * @param key The key to press.// w ww . ja v a2 s . c o m */ void simulateKeyPress(Key key) { final int x = key.mHitBox.centerX(); final int y = key.mHitBox.centerY(); final long downTime = SystemClock.uptimeMillis(); final MotionEvent downEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, x, y, 0); final MotionEvent upEvent = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0); mKeyboardView.onTouchEvent(downEvent); mKeyboardView.onTouchEvent(upEvent); downEvent.recycle(); upEvent.recycle(); }
From source file:com.heneryh.aquanotes.ui.controllers.ControllersActivity.java
/***************************** Activity Methods ******************************** * /*w ww .j a v a 2 s.co m*/ * */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); controllerActContext = this; AnalyticsUtils.getInstance(this).trackPageView("/Controllers"); /** * The handler in this case only gets the list of active controllers * then creates a swipeable tab-view for each. */ mHandler = new NotifyingAsyncQueryHandler(getContentResolver(), this); /** * The main view is a left/right scroll button a title and a workspace below it for content */ setContentView(R.layout.activity_controllers); mLeftIndicator = findViewById(R.id.indicator_left); mWorkspaceTitleView = (TextView) findViewById(R.id.controller_ws_title); mRightIndicator = findViewById(R.id.indicator_right); mWorkspace = (Workspace) findViewById(R.id.workspace); getActivityHelper().setupActionBar("empty", 0); /** * Add click listeners for the scroll buttons. */ mLeftIndicator.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent motionEvent) { if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) { mWorkspace.scrollLeft(); return true; } return false; } }); mLeftIndicator.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mWorkspace.scrollLeft(); } }); mRightIndicator.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent motionEvent) { if ((motionEvent.getAction() & MotionEventUtils.ACTION_MASK) == MotionEvent.ACTION_DOWN) { mWorkspace.scrollRight(); return true; } return false; } }); mRightIndicator.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mWorkspace.scrollRight(); } }); /** * Need at least one tab-view for the next step to continue * so put a dummy one in. We'll swap this out when we get real data. */ setupCtlr(new Ctlr(), null); /** * Set the scroll listener for the workspace */ mWorkspace.setOnScrollListener(new Workspace.OnScrollListener() { public void onScroll(float screenFraction) { updateWorkspaceHeader(Math.round(screenFraction)); } }, true); /** * Interface to the database which is passed into the remoteExecutor. Is there an advantage to * having a centralized one rather than each getting there own??? Might want to look at this more. * Seems like the answer is that you need the context to get the resolver */ dbResolverControllerAct = getContentResolver(); /** * Setup stuff below for the ApexExecutor that will handle the spinner-select and outlet change function */ /** * helper class for defaultHttpClient seen below */ final HttpClient httpClient = getHttpClient(this); /** * Create the executor for the controller of choice. Now it is just the apex but I can see using * other ones like the DA. Pass in the http client and database resolver it will need to do its job. */ mRemoteExecutor = new ApexExecutor(this, httpClient, dbResolverControllerAct); /** * For the status update messages from the syncService thread */ statusIntentReceiver = new MyIntentReceiver(); }
From source file:org.artoolkit.ar.samples.ARMovie.ARMovieActivity.java
@Override public void onStart() { Log.i(TAG, "onStart()"); super.onStart(); mainLayout = (FrameLayout) this.findViewById(R.id.mainLayout); mainLayout.setOnTouchListener(new View.OnTouchListener() { @Override// w ww .j av a 2s . c o m public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { //focusOnTouch(event); } return true; } }); // Bundle extras = getIntent().getExtras(); // String videoUrl = extras.getString("videoUrl"); // Log.i(TAG, videoUrl); try { movieController = new MovieController(this.getCacheDir() + "/" + movieFile); //movieController = new MovieController("http://133.130.111.186/pilot/uploads/p1270436.MP4"); //movieController = new MovieController(videoUrl); movieController.mLoop = true; movieController.mStartPaused = true; } catch (IOException e) { Log.e(TAG, "Unable to create movie controller."); movieController = null; } ARMovieActivity.nativeStart(); }
From source file:io.selendroid.server.model.AndroidWebElement.java
@Override public void click() { String tagName = getTagName(); if ((tagName != null && "OPTION".equals(tagName.toUpperCase())) || driver.isInFrame()) { driver.resetPageIsLoading();/*from ww w . j a va 2 s . c o m*/ driver.executeAtom(AndroidAtoms.CLICK, null, this); driver.waitForPageToLoad(); if (driver.isInFrame()) { return; } } Point center = getCenterCoordinates(); long downTime = SystemClock.uptimeMillis(); final List<MotionEvent> events = new ArrayList<MotionEvent>(); MotionEvent downEvent = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, center.x, center.y, 0); events.add(downEvent); MotionEvent upEvent = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, center.x, center.y, 0); events.add(upEvent); driver.resetPageIsLoading(); driver.getMotionSender().send(events); // If the page started loading we should wait // until the page is done loading. driver.waitForPageToLoad(); }
From source file:cc.solart.turbo.TurboRecyclerView.java
@Override public boolean onInterceptTouchEvent(MotionEvent e) { if (!mLoadEnabled || canScrollEnd() || mIsLoading || isEmpty()) { return super.onInterceptTouchEvent(e); }// w ww .j av a 2s . co m if (dispatchOnItemTouchIntercept(e)) { return true; } final int action = MotionEventCompat.getActionMasked(e); final int actionIndex = MotionEventCompat.getActionIndex(e); switch (action) { case MotionEvent.ACTION_DOWN: { mActivePointerId = MotionEventCompat.getPointerId(e, 0); mInitialMotionX = getMotionEventX(e, actionIndex); mInitialMotionY = getMotionEventY(e, actionIndex); } break; case MotionEvent.ACTION_POINTER_DOWN: { mActivePointerId = MotionEventCompat.getPointerId(e, actionIndex); mInitialMotionX = getMotionEventX(e, actionIndex); mInitialMotionY = getMotionEventY(e, actionIndex); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mActivePointerId = INVALID_POINTER; break; case MotionEventCompat.ACTION_POINTER_UP: { onPointerUp(e); } break; } return super.onInterceptTouchEvent(e); }