android.view.ViewConfiguration#getTapTimeout ( )源码实例Demo

下面列出了android.view.ViewConfiguration#getTapTimeout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: switchbutton   文件: FTouchHelper.java
/**
 * 是否是点击事件
 *
 * @param event
 * @param context
 * @return
 */
public boolean isClick(MotionEvent event, Context context)
{
    if (event.getAction() == MotionEvent.ACTION_UP)
    {
        final long clickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
        final int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

        final long duration = event.getEventTime() - event.getDownTime();
        final int dx = (int) getDeltaXFromDown();
        final int dy = (int) getDeltaYFromDown();

        if (duration < clickTimeout && dx < touchSlop && dy < touchSlop)
            return true;
    }
    return false;
}
 
源代码2 项目: budget-envelopes   文件: DeleteView.java
private void init(Context cntx) {
    mInnerView = null;
    mSwipeStart = -1;
    mSwipeStartTime = -1;
    mBackground = 0;
    ViewConfiguration config = ViewConfiguration.get(cntx);
    mTouchSlop = config.getScaledTouchSlop();
    mFlingSlop = config.getScaledMinimumFlingVelocity();
    mFlingCap = config.getScaledMaximumFlingVelocity();
    mPressTimeout = config.getTapTimeout();
    mPressRunnable = new Runnable() {
        public void run() {
            if (mSwipeState == STATE_PRESSED) {
                mInnerView.setPressed(true);
            }
        }
    };
    mLongPressTimeout = mPressTimeout + config.getLongPressTimeout();
    mLongPressRunnable = new Runnable() {
        public void run() {
            if (mSwipeState == STATE_PRESSED) {
                performLongClick();
                mInnerView.setPressed(false);
            }
        }
    };
    mUnpressRunnable = new Runnable() {
        public void run() {
            mInnerView.setPressed(false);
        }
    };
    mSwipeState = STATE_READY;
    mVelocityTracker = null;
    mAnim = null;
    mChecked = false;
    mListener = null;
    setClickable(true);
}
 
源代码3 项目: UltimateAndroid   文件: SwitchButton.java
private void initView() {
	mConf = Configuration.getDefault(getContext().getResources().getDisplayMetrics().density);
	mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
	mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
	mAnimationController = AnimationController.getDefault().init(mOnAnimateListener);
	mBounds = new Rect();
	if (SHOW_RECT) {
		mRectPaint = new Paint();
		mRectPaint.setStyle(Style.STROKE);
	}
}
 
源代码4 项目: pandora   文件: OperableView.java
public OperableView(Context context) {
    super(context);
    ViewConfiguration vc = ViewConfiguration.get(context);
    touchSlop = vc.getScaledTouchSlop();
    longPressTimeout = ViewConfiguration.getLongPressTimeout();
    tapTimeout = ViewConfiguration.getTapTimeout();
    selectCanvas = new SelectCanvas(this);
    relativeCanvas = new RelativeCanvas(this);
    gridCanvas = new GridCanvas(this);
    clickInfoCanvas = new ClickInfoCanvas(this);
}
 
源代码5 项目: MDPreference   文件: ListPopupWindow.java
public ForwardingListener(View src) {
    mSrc = src;
    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;
}
 
源代码6 项目: AndroidChromium   文件: AppMenuDragHelper.java
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();
}
 
源代码7 项目: BaseProject   文件: SwitchButton.java
private void initView(Context context) {
    mPaint = new Paint();
    mPaint.setColor(Color.WHITE);
    Resources resources = context.getResources();

    // get viewConfiguration
    mClickTimeout = ViewConfiguration.getPressedStateDuration()
            + ViewConfiguration.getTapTimeout();
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    // get Bitmap
    mBottom = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_bottom);
    mBtnPressed = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_pressed);
    mBtnNormal = BitmapFactory.decodeResource(resources, R.drawable.swithc_btn_unpressed);
    mFrame = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_frame);
    mMask = BitmapFactory.decodeResource(resources, R.drawable.switch_btn_mask);
    mCurBtnPic = mBtnNormal;

    mBtnWidth = mBtnPressed.getWidth();
    mMaskWidth = mMask.getWidth();
    mMaskHeight = mMask.getHeight();

    mBtnOffPos = mBtnWidth / 2;
    mBtnOnPos = mMaskWidth - mBtnWidth / 2;

    mBtnPos = mChecked ? mBtnOnPos : mBtnOffPos;
    mRealPos = getRealPos(mBtnPos);

    final float density = getResources().getDisplayMetrics().density;
    mVelocity = (int) (VELOCITY * density + 0.5f);
    mExtendOffsetY = (int) (EXTENDED_OFFSET_Y * density + 0.5f);

    mSaveLayerRectF = new RectF(0, mExtendOffsetY, mMask.getWidth(), mMask.getHeight()
            + mExtendOffsetY);
    mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
}
 
源代码8 项目: BlunoAccessoryShieldDemo   文件: SwitchButton.java
private void initView(Context context) {
    mPaint = new Paint();
    mPaint.setColor(Color.WHITE);
    Resources resources = context.getResources();

    // get viewConfiguration
    mClickTimeout = ViewConfiguration.getPressedStateDuration()
            + ViewConfiguration.getTapTimeout();
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    // get Bitmap
    mBottom = BitmapFactory.decodeResource(resources, R.drawable.bottom);
    mBtnPressed = BitmapFactory.decodeResource(resources, R.drawable.btn_pressed);
    mBtnNormal = BitmapFactory.decodeResource(resources, R.drawable.btn_unpressed);
    mFrame = BitmapFactory.decodeResource(resources, R.drawable.frame);
    mMask = BitmapFactory.decodeResource(resources, R.drawable.mask);
    mCurBtnPic = mBtnNormal;

    mBtnWidth = mBtnPressed.getWidth();
    mMaskWidth = mMask.getWidth();
    mMaskHeight = mMask.getHeight();

    mBtnOffPos = mBtnWidth / 2;
    mBtnOnPos = mMaskWidth - mBtnWidth / 2;

    mBtnPos = mChecked ? mBtnOnPos : mBtnOffPos;
    mRealPos = getRealPos(mBtnPos);

    final float density = getResources().getDisplayMetrics().density;
    mVelocity = (int) (VELOCITY * density + 0.5f);
    mExtendOffsetY = (int) (EXTENDED_OFFSET_Y * density + 0.5f);

    mSaveLayerRectF = new RectF(0, mExtendOffsetY, mMask.getWidth(), mMask.getHeight()
            + mExtendOffsetY);
    mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
}
 
public PersianRadialPickerLayout(Context context, AttributeSet attrs) {
  super(context, attrs);

  setOnTouchListener(this);
  ViewConfiguration vc = ViewConfiguration.get(context);
  TOUCH_SLOP = vc.getScaledTouchSlop();
  TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
  mDoingMove = false;

  mCircleView = new CircleView(context);
  addView(mCircleView);

  mAmPmCirclesView = new AmPmCirclesView(context, fontName);
  addView(mAmPmCirclesView);

  mHourRadialSelectorView = new RadialSelectorView(context);
  addView(mHourRadialSelectorView);
  mMinuteRadialSelectorView = new RadialSelectorView(context);
  addView(mMinuteRadialSelectorView);

  mHourRadialTextsView = new RadialTextsView(context, fontName);
  addView(mHourRadialTextsView);
  mMinuteRadialTextsView = new RadialTextsView(context, fontName);
  addView(mMinuteRadialTextsView);

  // Prepare mapping to snap touchable degrees to selectable degrees.
  preparePrefer30sMap();

  mLastValueSelected = -1;

  mInputEnabled = true;

  mGrayBox = new View(context);
  mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(
    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  mGrayBox.setBackgroundColor(getResources().getColor(R.color.mdtp_transparent_black));
  mGrayBox.setVisibility(View.INVISIBLE);
  addView(mGrayBox);

  mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

  mTimeInitialized = false;
}
 
源代码10 项目: 365browser   文件: ViewConfigurationHelper.java
@CalledByNative
private static int getTapTimeout() {
    return ViewConfiguration.getTapTimeout();
}
 
public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mLastValueSelected = -1;

    mInputEnabled = true;
    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}
 
源代码12 项目: narrate-android   文件: RadialPickerLayout.java
public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mLastValueSelected = -1;

    mInputEnabled = true;
    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}
 
源代码13 项目: android-test   文件: MotionEvents.java
public static DownResultHolder sendDown(
    UiController uiController,
    float[] coordinates,
    float[] precision,
    int inputDevice,
    int buttonState) {
  checkNotNull(uiController);
  checkNotNull(coordinates);
  checkNotNull(precision);

  for (int retry = 0; retry < MAX_CLICK_ATTEMPTS; retry++) {
    MotionEvent motionEvent = null;
    try {
      motionEvent = obtainDownEvent(coordinates, precision, inputDevice, buttonState);
      // The down event should be considered a tap if it is long enough to be detected
      // but short enough not to be a long-press. Assume that TapTimeout is set at least
      // twice the detection time for a tap (no need to sleep for the whole TapTimeout since
      // we aren't concerned about scrolling here).
      long downTime = motionEvent.getDownTime();
      long isTapAt = downTime + (ViewConfiguration.getTapTimeout() / 2);

      boolean injectEventSucceeded = uiController.injectMotionEvent(motionEvent);

      while (true) {
        long delayToBeTap = isTapAt - SystemClock.uptimeMillis();
        if (delayToBeTap <= 10) {
          break;
        }
        // Sleep only a fraction of the time, since there may be other events in the UI queue
        // that could cause us to start sleeping late, and then oversleep.
        uiController.loopMainThreadForAtLeast(delayToBeTap / 4);
      }

      boolean longPress = false;
      if (SystemClock.uptimeMillis() > (downTime + ViewConfiguration.getLongPressTimeout())) {
        longPress = true;
        Log.w(TAG, "Overslept and turned a tap into a long press");
      }

      if (!injectEventSucceeded) {
        motionEvent.recycle();
        motionEvent = null;
        continue;
      }

      return new DownResultHolder(motionEvent, longPress);
    } catch (InjectEventSecurityException e) {
      throw new PerformException.Builder()
          .withActionDescription("Send down motion event")
          .withViewDescription("unknown") // likely to be replaced by FailureHandler
          .withCause(e)
          .build();
    }
  }
  throw new PerformException.Builder()
      .withActionDescription(
          String.format(Locale.ROOT, "click (after %s attempts)", MAX_CLICK_ATTEMPTS))
      .withViewDescription("unknown") // likely to be replaced by FailureHandler
      .build();
}
 
源代码14 项目: AlarmOn   文件: RadialPickerLayout.java
public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);
    mSecondRadialSelectorView = new RadialSelectorView(context);
    addView(mSecondRadialSelectorView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);
    mSecondRadialTextsView = new RadialTextsView(context);
    addView(mSecondRadialTextsView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mLastValueSelected = null;

    mInputEnabled = true;

    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(ContextCompat.getColor(context, R.color.mdtp_transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}
 
源代码15 项目: android-chromium   文件: HandleView.java
@Override
public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN: {
            mDownPositionX = ev.getRawX();
            mDownPositionY = ev.getRawY();
            mTouchToWindowOffsetX = mDownPositionX - mPositionX;
            mTouchToWindowOffsetY = mDownPositionY - mPositionY;
            mIsDragging = true;
            mController.beforeStartUpdatingPosition(this);
            mTouchTimer = SystemClock.uptimeMillis();
            break;
        }

        case MotionEvent.ACTION_MOVE: {
            updatePosition(ev.getRawX(), ev.getRawY());
            break;
        }

        case MotionEvent.ACTION_UP:
            if (mIsInsertionHandle) {
                long delay = SystemClock.uptimeMillis() - mTouchTimer;
                if (delay < ViewConfiguration.getTapTimeout()) {
                    if (mPastePopupWindow != null && mPastePopupWindow.isShowing()) {
                        // Tapping on the handle dismisses the displayed paste view,
                        mPastePopupWindow.hide();
                    } else {
                        showPastePopupWindow();
                    }
                }
            }
            mIsDragging = false;
            break;

        case MotionEvent.ACTION_CANCEL:
            mIsDragging = false;
            break;

        default:
            return false;
    }
    return true;
}
 
源代码16 项目: under-the-hood   文件: ArbitraryTapListener.java
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (onClickListener == null) {
        return false;
    }
    boolean consume = false;
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            Log.d(TAG, "down");
            touchDownMs = System.currentTimeMillis();
            break;
        case MotionEvent.ACTION_UP:
            Log.d(TAG, "up");
            if ((System.currentTimeMillis() - touchDownMs) > ViewConfiguration.getTapTimeout()) {
                //it was not a tap
                numberOfTaps = 0;
                lastTapTimeMs = 0;
                Log.d(TAG, "reset");
                break;
            }

            if (numberOfTaps > 0
                    && (System.currentTimeMillis() - lastTapTimeMs) < ViewConfiguration.getDoubleTapTimeout()) {
                numberOfTaps += 1;
                Log.d(TAG, "+1");
                consume = true;
            } else {
                Log.d(TAG, "1");
                numberOfTaps = 1;
            }

            lastTapTimeMs = System.currentTimeMillis();

            if (numberOfTaps >= targetNumberOfTaps) {
                Log.d(TAG, "goal");
                onClickListener.onClick(v);
                numberOfTaps = 0;
                lastTapTimeMs = 0;
                consume = true;
            }
    }
    return consume;
}
 
源代码17 项目: Blackbulb   文件: RadialPickerLayout.java
public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);
    mSecondRadialSelectorView = new RadialSelectorView(context);
    addView(mSecondRadialSelectorView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);
    mSecondRadialTextsView = new RadialTextsView(context);
    addView(mSecondRadialTextsView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mLastValueSelected = null;

    mInputEnabled = true;

    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(context.getResources().getColor(R.color.mdtp_transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}
 
源代码18 项目: date_picker_converter   文件: RadialPickerLayout.java
public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);
    mSecondRadialSelectorView = new RadialSelectorView(context);
    addView(mSecondRadialSelectorView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);
    mSecondRadialTextsView = new RadialTextsView(context);
    addView(mSecondRadialTextsView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mLastValueSelected = null;

    mInputEnabled = true;

    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(ContextCompat.getColor(context, R.color.mdtp_transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}
 
源代码19 项目: Conquer   文件: RadialPickerLayout.java
public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mVibrator = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
    mLastVibrate = 0;
    mLastValueSelected = -1;

    mInputEnabled = true;
    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}
 
源代码20 项目: talkback   文件: GestureUtils.java
/**
 * Create a description for a tap gesture. Gestures outside the screen will be offset to fit in
 * the screen.
 *
 * @param context The context in which the gesture is being created
 * @param x The x coordinate of the tap
 * @param y The y coordinate of the tap
 * @return A description of a tap at ({@code x}, {@code y})
 */
public static GestureDescription createTap(Context context, int x, int y) {
  Path path = new Path();
  path.moveTo(x, y);
  int durationMs = ViewConfiguration.getTapTimeout();
  return createGestureDescription(new StrokeDescription(path, 0, durationMs));
}