List of usage examples for android.view MotionEvent recycle
@Override public final void recycle()
From source file:de.gebatzens.ggvertretungsplan.view.SubstSwipeLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: MotionEvent m = MotionEvent.obtain(event); mPrevX = m.getX();/* w ww .j av a2 s. c o m*/ m.recycle(); break; case MotionEvent.ACTION_MOVE: float xd = Math.abs(event.getX() - mPrevX); if (xd > mTouchSlop) return false; if (GGApp.GG_APP.getFragmentType() == GGApp.FragmentType.PLAN) { int i = ((SubstFragment) ((MainActivity) getContext()).mContent).mViewPager.getCurrentItem(); SubstPagerFragment frag = (SubstPagerFragment) ((FragmentPagerAdapter) ((SubstFragment) ((MainActivity) getContext()).mContent).mViewPager .getAdapter()).getItem(i); ScrollView sv = (ScrollView) frag.getView().findViewWithTag("ggfrag_scrollview"); if (sv != null && sv.getScrollY() != 0) return false; } } return super.onInterceptTouchEvent(event); }
From source file:de.gebatzens.sia.view.CustomSwipeLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: MotionEvent m = MotionEvent.obtain(event); prevX = m.getX();/*from www .j av a 2s. com*/ m.recycle(); return super.onInterceptTouchEvent(event); case MotionEvent.ACTION_MOVE: if (SIAApp.SIA_APP.school.fragments.get(SIAApp.SIA_APP.getFragmentIndex()) .getType() == FragmentData.FragmentType.PLAN) { float xd = Math.abs(event.getX() - prevX); if (xd > touchSlop) return false; } } return super.onInterceptTouchEvent(event); }
From source file:de.stadtrallye.rallyesoft.widget.GalleryPager.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (touchEnabled) { return super.onInterceptTouchEvent(ev); } else {//from w w w. ja va 2 s. co m if (!cancelled) { MotionEvent e = MotionEvent.obtain(ev); e.setAction(MotionEvent.ACTION_CANCEL); super.onInterceptTouchEvent(e); cancelled = true; e.recycle(); } return false; } }
From source file:com.hippo.ehviewer.gallery.gl.GestureRecognizer.java
public void cancelScale() { long now = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0); mScaleDetector.onTouchEvent(cancelEvent); cancelEvent.recycle(); }
From source file:android.support.v7.widget.ForwardingListener.java
private void onLongPress() { clearCallbacks();// w w w. ja v a2 s . c o m final View src = mSrc; if (!src.isEnabled() || src.isLongClickable()) { // Ignore long-press if the view is disabled or has its own // handler. return; } if (!onForwardingStarted()) { return; } // Don't let the parent intercept our events. src.getParent().requestDisallowInterceptTouchEvent(true); // Make sure we cancel any ongoing source event stream. final long now = SystemClock.uptimeMillis(); final MotionEvent e = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0); src.onTouchEvent(e); e.recycle(); mForwarding = true; }
From source file:android.support.v7.widget.ForwardingListener.java
@Override public boolean onTouch(View v, MotionEvent event) { final boolean wasForwarding = mForwarding; final boolean forwarding; if (wasForwarding) { forwarding = onTouchForwarded(event) || !onForwardingStopped(); } else {//from w w w. j av a 2 s. com forwarding = onTouchObserved(event) && onForwardingStarted(); if (forwarding) { // Make sure we cancel any ongoing source event stream. final long now = SystemClock.uptimeMillis(); final MotionEvent e = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); mSrc.onTouchEvent(e); e.recycle(); } } mForwarding = forwarding; return forwarding || wasForwarding; }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewWithMiniKeyboard.java
protected void setPopupStickinessValues(boolean isSticky, boolean requiresSlideInMotionEvent, int touchX, int touchY) { mChildKeyboardActionListener.setInOneShot(!isSticky); if (requiresSlideInMotionEvent) { // Inject down event on the key to mini keyboard. long eventTime = SystemClock.uptimeMillis(); mMiniKeyboardPopupTime = eventTime; MotionEvent downEvent = generateMiniKeyboardMotionEvent(MotionEvent.ACTION_DOWN, touchX, touchY, eventTime);// w w w . j a va 2 s . c o m mMiniKeyboard.onTouchEvent(downEvent); downEvent.recycle(); } }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewWithMiniKeyboard.java
@Override public boolean onTouchEvent(@NonNull MotionEvent me) { if (getMiniKeyboard() != null && mMiniKeyboardPopup.isShowing()) { final int miniKeyboardX = (int) me.getX(); final int miniKeyboardY = (int) me.getY(); final int action = MotionEventCompat.getActionMasked(me); MotionEvent translated = generateMiniKeyboardMotionEvent(action, miniKeyboardX, miniKeyboardY, me.getEventTime());/*from w ww . ja v a 2 s . c o m*/ getMiniKeyboard().onTouchEvent(translated); translated.recycle(); return true; } return super.onTouchEvent(me); }
From source file:com.android.inputmethod.accessibility.KeyboardAccessibilityDelegate.java
/** * Simulating a touch event by injecting a synthesized touch event into {@link KeyboardView}. * * @param touchAction The action of the synthesizing touch event. * @param key The key that a synthesized touch event is on. *//*from www . ja v a 2 s. c om*/ private void simulateTouchEvent(final int touchAction, final Key key) { final int x = key.getHitBox().centerX(); final int y = key.getHitBox().centerY(); final long eventTime = SystemClock.uptimeMillis(); final MotionEvent touchEvent = MotionEvent.obtain(eventTime, eventTime, touchAction, x, y, 0 /* metaState */); mKeyboardView.onTouchEvent(touchEvent); touchEvent.recycle(); }
From source file:android.support.v7.widget.ForwardingListener.java
/** * Handles forwarded motion events and determines when to stop * forwarding.//from ww w. j a v a 2 s . c om * * @param srcEvent motion event in source view coordinates * @return true to continue forwarding motion events, false to cancel */ private boolean onTouchForwarded(MotionEvent srcEvent) { final View src = mSrc; final ShowableListMenu popup = getPopup(); if (popup == null || !popup.isShowing()) { return false; } final DropDownListView dst = (DropDownListView) popup.getListView(); if (dst == null || !dst.isShown()) { return false; } // Convert event to destination-local coordinates. final MotionEvent dstEvent = MotionEvent.obtainNoHistory(srcEvent); toGlobalMotionEvent(src, dstEvent); toLocalMotionEvent(dst, dstEvent); // Forward converted event to destination view, then recycle it. final boolean handled = dst.onForwardedEvent(dstEvent, mActivePointerId); dstEvent.recycle(); // Always cancel forwarding when the touch stream ends. final int action = MotionEventCompat.getActionMasked(srcEvent); final boolean keepForwarding = action != MotionEvent.ACTION_UP && action != MotionEvent.ACTION_CANCEL; return handled && keepForwarding; }