Example usage for android.view ViewConfiguration getLongPressTimeout

List of usage examples for android.view ViewConfiguration getLongPressTimeout

Introduction

In this page you can find the example usage for android.view ViewConfiguration getLongPressTimeout.

Prototype

public static int getLongPressTimeout() 

Source Link

Usage

From source file:org.getlantern.firetweet.view.MessageCardItemFrameLayout.java

@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();
    final Drawable d = getBackground();
    if (d != null && d.isStateful()) {
        final int[] state = getDrawableState();
        d.setState(state);//from   w  ww  .j a v a  2  s  . c o m
        final Drawable current = d.getCurrent();
        if (current instanceof TransitionDrawable) {
            final TransitionDrawable td = (TransitionDrawable) current;
            if (ArrayUtils.contains(state, android.R.attr.state_pressed)) {
                td.startTransition(ViewConfiguration.getLongPressTimeout());
            } else {
                td.resetTransition();
            }
        }
    }
}

From source file:android.support.v7.widget.ForwardingListener.java

public ForwardingListener(View src) {
    mSrc = src;//from  w ww . j a va2 s.  c  o m
    mScaledTouchSlop = ViewConfiguration.get(src.getContext()).getScaledTouchSlop();
    mTapTimeout = ViewConfiguration.getTapTimeout();
    // Use a medium-press timeout. Halfway between tap and long-press.
    mLongPressTimeout = (mTapTimeout + ViewConfiguration.getLongPressTimeout()) / 2;
}

From source file:com.google.android.marvin.mytalkback.ProcessorVolumeStream.java

private void handleVolumeKeyDown(int keyCode) {
    // Don't perform actions on key down, just track long-presses
    mLongPressHandler.sendMessageDelayed(
            Message.obtain(mLongPressHandler, LongPressHandler.MSG_LONG_PRESSED, keyCode),
            ViewConfiguration.getLongPressTimeout());
}

From source file:com.example.carlitos.swipeitemrecycler.view.animation.swipe_item.swipeable.RecyclerViewSwipeManager.java

/**
 * Constructor.//from   ww w  .java 2 s . co m
 */
public RecyclerViewSwipeManager() {
    mInternalUseOnItemTouchListener = new RecyclerView.OnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            return RecyclerViewSwipeManager.this.onInterceptTouchEvent(rv, e);
        }

        @Override
        public void onTouchEvent(RecyclerView rv, MotionEvent e) {
            RecyclerViewSwipeManager.this.onTouchEvent(rv, e);
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
            RecyclerViewSwipeManager.this.onRequestDisallowInterceptTouchEvent(disallowIntercept);
        }
    };
    mVelocityTracker = VelocityTracker.obtain();
    mLongPressTimeout = ViewConfiguration.getLongPressTimeout();
}

From source file:android.support.v7.widget.TooltipCompatHandler.java

private void show(boolean fromTouch) {
    if (!ViewCompat.isAttachedToWindow(mAnchor)) {
        return;/*  w w w  . j  a v  a2 s  .c  o  m*/
    }
    setPendingHandler(null);
    if (sActiveHandler != null) {
        sActiveHandler.hide();
    }
    sActiveHandler = this;

    mFromTouch = fromTouch;
    mPopup = new TooltipPopup(mAnchor.getContext());
    mPopup.show(mAnchor, mAnchorX, mAnchorY, mFromTouch, mTooltipText);
    // Only listen for attach state change while the popup is being shown.
    mAnchor.addOnAttachStateChangeListener(this);

    final long timeout;
    if (mFromTouch) {
        timeout = LONG_CLICK_HIDE_TIMEOUT_MS;
    } else if ((ViewCompat.getWindowSystemUiVisibility(mAnchor)
            & SYSTEM_UI_FLAG_LOW_PROFILE) == SYSTEM_UI_FLAG_LOW_PROFILE) {
        timeout = HOVER_HIDE_TIMEOUT_SHORT_MS - ViewConfiguration.getLongPressTimeout();
    } else {
        timeout = HOVER_HIDE_TIMEOUT_MS - ViewConfiguration.getLongPressTimeout();
    }
    mAnchor.removeCallbacks(mHideRunnable);
    mAnchor.postDelayed(mHideRunnable, timeout);
}

From source file:android.support.v7.widget.TooltipCompatHandler.java

private void scheduleShow() {
    mAnchor.postDelayed(mShowRunnable, ViewConfiguration.getLongPressTimeout());
}

From source file:org.petero.droidfish.activities.EditBoard.java

private final void initUI() {
    setContentView(R.layout.editboard);//  w  ww .  ja  v a2s.  co  m
    Util.overrideFonts(findViewById(android.R.id.content));

    View firstTitleLine = findViewById(R.id.first_title_line);
    View secondTitleLine = findViewById(R.id.second_title_line);
    cb = (ChessBoardEdit) findViewById(R.id.eb_chessboard);
    status = (TextView) findViewById(R.id.eb_status);
    okButton = (Button) findViewById(R.id.eb_ok);
    cancelButton = (Button) findViewById(R.id.eb_cancel);

    TextView whiteTitleText = (TextView) findViewById(R.id.white_clock);
    whiteTitleText.setVisibility(View.GONE);
    TextView blackTitleText = (TextView) findViewById(R.id.black_clock);
    blackTitleText.setVisibility(View.GONE);
    TextView engineTitleText = (TextView) findViewById(R.id.title_text);
    engineTitleText.setVisibility(View.GONE);
    whiteFigText = (TextView) findViewById(R.id.white_pieces);
    whiteFigText.setTypeface(figNotation);
    whiteFigText.setSelected(true);
    whiteFigText.setTextColor(whiteTitleText.getTextColors());
    blackFigText = (TextView) findViewById(R.id.black_pieces);
    blackFigText.setTypeface(figNotation);
    blackFigText.setSelected(true);
    blackFigText.setTextColor(blackTitleText.getTextColors());
    TextView summaryTitleText = (TextView) findViewById(R.id.title_text_summary);
    summaryTitleText.setText(R.string.edit_board);

    TextUtils.TruncateAt where = autoScrollTitle ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END;
    engineTitleText.setEllipsize(where);
    whiteFigText.setEllipsize(where);
    blackFigText.setEllipsize(where);

    firstTitleLine.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            openOptionsMenu();
        }
    });
    secondTitleLine.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            openOptionsMenu();
        }
    });

    okButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            sendBackResult();
        }
    });
    cancelButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    status.setFocusable(false);
    cb.setFocusable(true);
    cb.requestFocus();
    cb.setClickable(true);
    cb.setOnTouchListener(new OnTouchListener() {
        private boolean pending = false;
        private int sq0 = -1;
        private Handler handler = new Handler();
        private Runnable runnable = new Runnable() {
            public void run() {
                pending = false;
                handler.removeCallbacks(runnable);
                ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(20);
                showDialog(EDIT_DIALOG);
            }
        };

        public boolean onTouch(View v, MotionEvent event) {
            int action = MotionEventCompat.getActionMasked(event);
            switch (action) {
            case MotionEvent.ACTION_DOWN:
                handler.postDelayed(runnable, ViewConfiguration.getLongPressTimeout());
                sq0 = cb.eventToSquare(event);
                pending = true;
                break;
            case MotionEvent.ACTION_UP:
                if (pending) {
                    pending = false;
                    handler.removeCallbacks(runnable);
                    int sq = cb.eventToSquare(event);
                    if (sq == sq0) {
                        Move m = cb.mousePressed(sq);
                        if (m != null)
                            doMove(m);
                        setEgtbHints(cb.getSelectedSquare());
                    }
                }
                break;
            case MotionEvent.ACTION_CANCEL:
                pending = false;
                handler.removeCallbacks(runnable);
                break;
            }
            return true;
        }
    });
    cb.setOnTrackballListener(new ChessBoard.OnTrackballListener() {
        public void onTrackballEvent(MotionEvent event) {
            Move m = cb.handleTrackballEvent(event);
            if (m != null)
                doMove(m);
            setEgtbHints(cb.getSelectedSquare());
        }
    });
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerViewPager.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!mCanPickRange) {
        return super.onInterceptTouchEvent(ev);
    }/* w  ww  .  j av  a 2 s.co  m*/

    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        if (Config.DEBUG) {
            Log.i(TAG, "OITE: DOWN");
        }

        mInitialDownX = ev.getX();
        mInitialDownY = ev.getY();

        if (mCheckForLongPress == null) {
            mCheckForLongPress = new CheckForLongPress();
        }

        postDelayed(mCheckForLongPress, ViewConfiguration.getLongPressTimeout());
    } else if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) {
        if (Config.DEBUG) {
            Log.i(TAG, "OITE: (UP || CANCEL)");
        }

        if (mCheckForLongPress != null) {
            removeCallbacks(mCheckForLongPress);
        }

        mIsLongPressed = false;
        mInitialDownX = -1;
        mInitialDownY = -1;
    } else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
        if (Config.DEBUG) {
            Log.i(TAG, "OITE: MOVE");
        }

        if (!isStillALongPress((int) ev.getX(), (int) ev.getY())) {
            if (Config.DEBUG) {
                Log.i(TAG, "OITE: MOVED TOO MUCH, CANCELLING CheckForLongPress Runnable");
            }

            if (mCheckForLongPress != null) {
                removeCallbacks(mCheckForLongPress);
            }
        }
    }

    return mIsLongPressed || super.onInterceptTouchEvent(ev);
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.RecyclerViewDragDropManager.java

/**
 * Constructor./*  w w  w. j  a  va2  s . c o m*/
 */
public RecyclerViewDragDropManager() {
    mInternalUseOnItemTouchListener = new RecyclerView.OnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            return RecyclerViewDragDropManager.this.onInterceptTouchEvent(rv, e);
        }

        @Override
        public void onTouchEvent(RecyclerView rv, MotionEvent e) {
            RecyclerViewDragDropManager.this.onTouchEvent(rv, e);
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
            RecyclerViewDragDropManager.this.onRequestDisallowInterceptTouchEvent(disallowIntercept);
        }
    };

    mInternalUseOnScrollListener = new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            RecyclerViewDragDropManager.this.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            RecyclerViewDragDropManager.this.onScrolled(recyclerView, dx, dy);
        }
    };

    mScrollOnDraggingProcess = new ScrollOnDraggingProcessRunnable(this);

    mLongPressTimeout = ViewConfiguration.getLongPressTimeout();
}

From source file:org.telegram.ui.Components.NumberPicker.java

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    if (!isEnabled()) {
        return false;
    }//  w  w w .j a  va2 s. co  m
    final int action = event.getActionMasked();
    switch (action) {
    case MotionEvent.ACTION_DOWN: {
        removeAllCallbacks();
        mInputText.setVisibility(View.INVISIBLE);
        mLastDownOrMoveEventY = mLastDownEventY = event.getY();
        mLastDownEventTime = event.getEventTime();
        mIngonreMoveEvents = false;
        if (mLastDownEventY < mTopSelectionDividerTop) {
            if (mScrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                mPressedStateHelper.buttonPressDelayed(PressedStateHelper.BUTTON_DECREMENT);
            }
        } else if (mLastDownEventY > mBottomSelectionDividerBottom) {
            if (mScrollState == OnScrollListener.SCROLL_STATE_IDLE) {
                mPressedStateHelper.buttonPressDelayed(PressedStateHelper.BUTTON_INCREMENT);
            }
        }
        getParent().requestDisallowInterceptTouchEvent(true);
        if (!mFlingScroller.isFinished()) {
            mFlingScroller.forceFinished(true);
            mAdjustScroller.forceFinished(true);
            onScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
        } else if (!mAdjustScroller.isFinished()) {
            mFlingScroller.forceFinished(true);
            mAdjustScroller.forceFinished(true);
        } else if (mLastDownEventY < mTopSelectionDividerTop) {
            postChangeCurrentByOneFromLongPress(false, ViewConfiguration.getLongPressTimeout());
        } else if (mLastDownEventY > mBottomSelectionDividerBottom) {
            postChangeCurrentByOneFromLongPress(true, ViewConfiguration.getLongPressTimeout());
        }
        return true;
    }
    }
    return false;
}