本文整理匯總了Java中android.view.ViewConfiguration.getLongPressTimeout方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewConfiguration.getLongPressTimeout方法的具體用法?Java ViewConfiguration.getLongPressTimeout怎麽用?Java ViewConfiguration.getLongPressTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.ViewConfiguration
的用法示例。
在下文中一共展示了ViewConfiguration.getLongPressTimeout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onInterceptTouchEvent
import android.view.ViewConfiguration; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mLongClickStarted = System.currentTimeMillis();
break;
case MotionEvent.ACTION_MOVE:
boolean upVal = System.currentTimeMillis() - mLongClickStarted > ViewConfiguration.getLongPressTimeout();
if (upVal && mLongClickListener != null) {
mLongClickListener.onLongClick(LaunchAppWidgetHostView.this);
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
break;
case MotionEvent.ACTION_UP:
mLongClickStarted = -1;
}
return false;
}
示例2: run
import android.view.ViewConfiguration; //導入方法依賴的package包/類
public void run() {
if (this.this$0.mTouchMode == 0) {
this.this$0.mTouchMode = 1;
View child = this.this$0.getChildAt(this.this$0.mMotionPosition - this.this$0
.mFirstPosition);
if (child != null && !child.hasFocusable()) {
this.this$0.mLayoutMode = 0;
if (this.this$0.mDataChanged) {
this.this$0.mTouchMode = 2;
return;
}
this.this$0.layoutChildren();
child.setPressed(true);
this.this$0.positionSelector(child);
this.this$0.setPressed(true);
int longPressTimeout = ViewConfiguration.getLongPressTimeout();
boolean longClickable = this.this$0.isLongClickable();
if (this.this$0.mSelector != null) {
Drawable d = this.this$0.mSelector.getCurrent();
if (d != null && (d instanceof TransitionDrawable)) {
if (longClickable) {
((TransitionDrawable) d).startTransition(longPressTimeout);
} else {
((TransitionDrawable) d).resetTransition();
}
}
}
if (!longClickable) {
this.this$0.mTouchMode = 2;
}
}
}
}
示例3: onKeyUp
import android.view.ViewConfiguration; //導入方法依賴的package包/類
@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_MENU)
&& (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN)
&& (Build.MANUFACTURER.compareTo("LGE") == 0)) {
// Workaround for stupid LG devices that crash
openOptionsMenu();
return true;
} else if (keyCode == KeyEvent.KEYCODE_BACK) {
Handlers.MAIN.removeCallbacks(mLongPressBackRunnable);
if ((System.currentTimeMillis() - mKeyDownStartTime) > ViewConfiguration.getLongPressTimeout()) {
return true;
}
}
return super.onKeyUp(keyCode, event);
}
示例4: run
import android.view.ViewConfiguration; //導入方法依賴的package包/類
public void run() {
if (mTouchMode == TOUCH_MODE_DOWN) {
mTouchMode = TOUCH_MODE_TAP;
final View child = getChildAt(mMotionPosition - mFirstPosition);
if (child != null && !child.hasFocusable()) {
mLayoutMode = LAYOUT_NORMAL;
if (!mDataChanged) {
layoutChildren();
child.setPressed(true);
positionSelector(child);
setPressed(true);
final int longPressTimeout = ViewConfiguration.getLongPressTimeout();
final boolean longClickable = isLongClickable();
if (mSelector != null) {
Drawable d = mSelector.getCurrent();
if (d != null && d instanceof TransitionDrawable) {
if (longClickable) {
((TransitionDrawable) d).startTransition(longPressTimeout);
} else {
((TransitionDrawable) d).resetTransition();
}
}
}
if (longClickable) {
} else {
mTouchMode = TOUCH_MODE_DONE_WAITING;
}
} else {
mTouchMode = TOUCH_MODE_DONE_WAITING;
}
}
}
}
示例5: run
import android.view.ViewConfiguration; //導入方法依賴的package包/類
@Override
public void run() {
if (mTouchMode == TOUCH_MODE_DOWN) {
mTouchMode = TOUCH_MODE_TAP;
if (mOnTouchModeChangedListener != null) {
mOnTouchModeChangedListener.onTouchModeChanged(mTouchMode);
}
if (beginTouchAt != null && beginTouchAt.view != null) {
beginTouchAt.view.setPressed(true);
// setPressed(true);
}
refreshDrawableState();
final int longPressTimeout = ViewConfiguration
.getLongPressTimeout();
final boolean longClickable = isLongClickable();
if (longClickable) {
if (mPendingCheckForLongPress == null) {
mPendingCheckForLongPress = new CheckForLongPress();
}
postDelayed(mPendingCheckForLongPress, longPressTimeout);
} else {
mTouchMode = TOUCH_MODE_DONE_WAITING;
if (mOnTouchModeChangedListener != null) {
mOnTouchModeChangedListener
.onTouchModeChanged(mTouchMode);
}
}
}
}
示例6: onTouchEvent
import android.view.ViewConfiguration; //導入方法依賴的package包/類
/** Handles the touch event */
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mIsCapturingGesture = true;
mIsClickCandidate = true;
mActionDownTime = event.getEventTime();
mActionDownX = event.getX();
mActionDownY = event.getY();
break;
case MotionEvent.ACTION_MOVE:
if (Math.abs(event.getX() - mActionDownX) > mSingleTapSlopPx ||
Math.abs(event.getY() - mActionDownY) > mSingleTapSlopPx) {
mIsClickCandidate = false;
}
break;
case MotionEvent.ACTION_CANCEL:
mIsCapturingGesture = false;
mIsClickCandidate = false;
break;
case MotionEvent.ACTION_UP:
mIsCapturingGesture = false;
if (Math.abs(event.getX() - mActionDownX) > mSingleTapSlopPx ||
Math.abs(event.getY() - mActionDownY) > mSingleTapSlopPx) {
mIsClickCandidate = false;
}
if (mIsClickCandidate) {
if (event.getEventTime() - mActionDownTime <= ViewConfiguration.getLongPressTimeout()) {
if (mClickListener != null) {
mClickListener.onClick();
}
} else {
// long click, not handled
}
}
mIsClickCandidate = false;
break;
}
return true;
}
示例7: SwipeHelper
import android.view.ViewConfiguration; //導入方法依賴的package包/類
SwipeHelper(int swipeDirection, Callback callback, Context context) {
mCallback = callback;
mHandler = new Handler();
mSwipeDirection = swipeDirection;
mVelocityTracker = VelocityTracker.obtain();
mDensityScale = context.getResources().getDisplayMetrics().density;
mPagingTouchSlop = ViewConfiguration.get(context).getScaledPagingTouchSlop();
mLongPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f); // extra long-press!
mFalsingThreshold = context.getResources().getDimensionPixelSize(
R.dimen.swipe_helper_falsing_threshold);
mFlingAnimationUtils = new FlingAnimationUtils(context, getMaxEscapeAnimDuration() / 1000f);
}
示例8: AppMenuDragHelper
import android.view.ViewConfiguration; //導入方法依賴的package包/類
AppMenuDragHelper(Activity activity, AppMenu appMenu, int itemRowHeight) {
mActivity = activity;
mAppMenu = appMenu;
mItemRowHeight = itemRowHeight;
Resources res = mActivity.getResources();
mAutoScrollFullVelocity = res.getDimensionPixelSize(R.dimen.auto_scroll_full_velocity);
// If user is dragging and the popup ListView is too big to display at once,
// mDragScrolling animator scrolls mPopup.getListView() automatically depending on
// the user's touch position.
mDragScrolling.setTimeListener(new TimeAnimator.TimeListener() {
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
ListPopupWindow popup = mAppMenu.getPopup();
if (popup == null || popup.getListView() == null) return;
// We keep both mDragScrollOffset and mDragScrollOffsetRounded because
// the actual scrolling is by the rounded value but at the same time we also
// want to keep the precise scroll value in float.
mDragScrollOffset += (deltaTime * 0.001f) * mDragScrollingVelocity;
int diff = Math.round(mDragScrollOffset - mDragScrollOffsetRounded);
mDragScrollOffsetRounded += diff;
popup.getListView().smoothScrollBy(diff, 0);
// Force touch move event to highlight items correctly for the scrolled position.
if (!Float.isNaN(mLastTouchX) && !Float.isNaN(mLastTouchY)) {
menuItemAction(Math.round(mLastTouchX), Math.round(mLastTouchY),
ITEM_ACTION_HIGHLIGHT);
}
}
});
// We use medium timeout, the average of tap and long press timeouts. This is consistent
// with ListPopupWindow#ForwardingListener implementation.
mTapTimeout =
(ViewConfiguration.getTapTimeout() + ViewConfiguration.getLongPressTimeout()) / 2;
mScaledTouchSlop = ViewConfiguration.get(activity).getScaledTouchSlop();
}
示例9: run
import android.view.ViewConfiguration; //導入方法依賴的package包/類
@Override
public void run() {
if (mTouchMode == TOUCH_MODE_DOWN) {
mTouchMode = TOUCH_MODE_TAP;
final View child = getChildAt(mMotionPosition - mFirstPosition);
if (child != null && !child.hasFocusable()) {
mLayoutMode = LAYOUT_NORMAL;
if (!mDataChanged) {
child.setPressed(true);
setPressed(true);
layoutChildren();
positionSelector(mMotionPosition, child);
refreshDrawableState();
final int longPressTimeout = ViewConfiguration
.getLongPressTimeout();
final boolean longClickable = isLongClickable();
if (mSelector != null) {
Drawable d = mSelector.getCurrent();
if (d != null && d instanceof TransitionDrawable) {
if (longClickable) {
((TransitionDrawable) d)
.startTransition(longPressTimeout);
} else {
((TransitionDrawable) d).resetTransition();
}
}
}
if (longClickable) {
if (mPendingCheckForLongPress == null) {
mPendingCheckForLongPress = new CheckForLongPress();
}
mPendingCheckForLongPress
.rememberWindowAttachCount();
postDelayed(mPendingCheckForLongPress,
longPressTimeout);
} else {
mTouchMode = TOUCH_MODE_DONE_WAITING;
}
} else {
mTouchMode = TOUCH_MODE_DONE_WAITING;
}
}
}
}
示例10: show
import android.view.ViewConfiguration; //導入方法依賴的package包/類
private void show(boolean fromTouch) {
if (!ViewCompat.isAttachedToWindow(mAnchor)) {
return;
}
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);
}
示例11: setLongpressDelay
import android.view.ViewConfiguration; //導入方法依賴的package包/類
public void setLongpressDelay(int delay) {
mLongpressDelay = delay;
if (mLongpressDelay == 0) {
mLongpressDelay = ViewConfiguration.getLongPressTimeout();
}
if (mPieContainer != null) {
mPieContainer.setLongpressDelay(mLongpressDelay);
}
}
示例12: init
import android.view.ViewConfiguration; //導入方法依賴的package包/類
public void init(Context context) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
mDensity = metrics.density;
ViewConfiguration vc = ViewConfiguration.get(context);
mTouchSlop = vc.getScaledTouchSlop();
mLongPressTimeout = vc.getLongPressTimeout();
mScroller = new OverScroller(context);
mTouchRadius = TOUCH_RADIUS_DP * mDensity;
mEditCtrlStrokeWidth = EDIT_CTRL_STROKE_DP * mDensity;
mEditColor = getResources().getColor(R.color.colorAccent, context.getTheme());
mOnListChangedCallback = new ObservableList
.OnListChangedCallback<ObservableList<Layer>>() {
@Override
public void onChanged(ObservableList<Layer> layers) {
invalidate();
}
@Override
public void onItemRangeChanged(ObservableList<Layer> layers, int i, int i1) {
invalidate();
}
@Override
public void onItemRangeInserted(ObservableList<Layer> layers, int start, int count) {
invalidate();
addPropertyChangedCallbacks(layers, start, start + count);
}
@Override
public void onItemRangeMoved(ObservableList<Layer> layers, int i, int i1, int i2) {
invalidate();
}
@Override
public void onItemRangeRemoved(ObservableList<Layer> layers, int i, int i1) {
invalidate();
}
};
mOnPropertyChangedCallback = new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable observable, int i) {
invalidate();
}
};
}
示例13: ForwardingListener
import android.view.ViewConfiguration; //導入方法依賴的package包/類
public ForwardingListener(View src) {
this.mSrc = src;
this.mScaledTouchSlop = (float) ViewConfiguration.get(src.getContext()).getScaledTouchSlop();
this.mTapTimeout = ViewConfiguration.getTapTimeout();
this.mLongPressTimeout = (this.mTapTimeout + ViewConfiguration.getLongPressTimeout()) / 2;
}
示例14: getLongpressTimeoutForAction
import android.view.ViewConfiguration; //導入方法依賴的package包/類
private static int getLongpressTimeoutForAction(int action) {
return (action == GravityBoxSettings.HWKEY_ACTION_KILL) ?
mKillDelay : ViewConfiguration.getLongPressTimeout();
}
示例15: isLongPress
import android.view.ViewConfiguration; //導入方法依賴的package包/類
private boolean isLongPress() {
return (System.currentTimeMillis() - mTimePressed) >= ViewConfiguration.getLongPressTimeout();
}