List of usage examples for android.view ViewConfiguration getScaledTouchSlop
public int getScaledTouchSlop()
From source file:com.android.datetimepicker.time.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;//w w w . j a va 2 s . c om 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; installAccessibilityDelegate(); }
From source file:org.holoeverywhere.widget.datetimepicker.time.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;/*from w w w. j a v a 2s . co m*/ 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(); if (context.getPackageManager().checkPermission(Manifest.permission.VIBRATE, context.getPackageName()) == PackageManager.PERMISSION_GRANTED) { 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(0x7F000000); mGrayBox.setVisibility(View.INVISIBLE); addView(mGrayBox); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); mTimeInitialized = false; }
From source file:com.android.photos.views.GalleryThumbnailView.java
public GalleryThumbnailView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = new OverScroller(context); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = new EdgeEffectCompat(context); setWillNotDraw(false);/*from w ww .jav a 2 s .c om*/ setClipToPadding(false); }
From source file:com.a.mirko.android.datetimepicker.time.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;// ww w . j av a 2s. c om 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; }
From source file:com.redinput.datetimepickercompat.time.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;/*from w ww .j a v a 2s . c o m*/ 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; installAccessibilityDelegate(); }
From source file:net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.java
/** * Constructs a new swipe-to-dismiss touch listener for the given list view. * * @param listView The list view whose items should be dismissable. * @param callbacks The callback to trigger when the user has indicated that she would like to * dismiss one or more list items. */// w ww . j av a 2 s . co m public SwipeDismissListViewTouchListener(ListView listView, DismissCallbacks callbacks) { ViewConfiguration vc = ViewConfiguration.get(listView.getContext()); mSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime); mListView = listView; mCallbacks = callbacks; // Initialize undo popup LayoutInflater inflater = (LayoutInflater) listView.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View undoView = inflater.inflate(R.layout.undo_popup, null); mUndoButton = (Button) undoView.findViewById(R.id.undo); mUndoButton.setOnClickListener(new UndoClickListener()); mUndoButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // If the user touches the screen invalidate the current running delay by incrementing // the valid message id. So this delay won't hide the undo popup anymore mValidDelayedMsgId++; return false; } }); mUndoPopupTextView = (TextView) undoView.findViewById(R.id.text); mUndoPopup = new PopupWindow(undoView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false); mUndoPopup.setAnimationStyle(R.style.Animations_PopUpMenu_Fade); mScreenDensity = listView.getResources().getDisplayMetrics().density; // END initialize undo popup mListView.setOnTouchListener(this); // Setting this scroll listener is required to ensure that during ListView scrolling, // we don't look for swipes. mListView.setOnScrollListener(makeScrollListener()); }
From source file:com.libs.golomb.extendedrecyclerview.Scroller.FastScroller2.java
/** * Handles the touch event and determines whether to show the fast scroller (or updates it if * it is already showing).//w w w. j a v a2 s.c o m */ public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY, OnFastScrollStateChangeListener stateChangeListener) { ViewConfiguration config = ViewConfiguration.get(mRecyclerView.getContext()); int action = ev.getAction(); int y = (int) ev.getY(); switch (action) { case MotionEvent.ACTION_DOWN: if (isNearPoint(downX, downY)) { mTouchOffset = downY - mThumbPosition.y; mTouchOffsetB = mThumbPosition.y - downY; } break; case MotionEvent.ACTION_MOVE: // Check if we should start scrolling if (!mIsDragging && isNearPoint(downX, downY) && Math.abs(y - downY) > config.getScaledTouchSlop()) { mRecyclerView.getParent().requestDisallowInterceptTouchEvent(true); mIsDragging = true; mTouchOffset += (lastY - downY); mPopup.animateVisibility(true); if (stateChangeListener != null) { stateChangeListener.onFastScrollStart(); } } if (mIsDragging) { // Update the fast scroller section name at this touch position int top = 0; int bottom = mRecyclerView.getHeight() - mThumbHeight; int value = (((lastY) * mRecyclerView.getAvailableYScrolling()) / (getHeight())) - scrollY.get(); Log.d("LOG", "offset: " + (((mTouchOffsetB + lastY) * mRecyclerView.getAvailableYScrolling()) / (mRecyclerView.getHeight()))); mRecyclerView.scrollBy(0, value); // Log.d("TGolomb", "onScrolled2: " + value); //scrollY.set(value); //Log.d("TGolomb", "onScrolled5: " + (mTmpRect.top - y)); //Log.d("TGolomb", "onScrolled2: " + value); float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffset)); String sectionName = mRecyclerView.scrollToPositionAtProgress((boundedY - top) / (bottom - top)); mPopup.setSectionName(sectionName); mPopup.animateVisibility(!sectionName.isEmpty()); mRecyclerView.invalidate(mPopup.updateFastScrollerBounds(mRecyclerView, mThumbPosition.y)); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mTouchOffset = 0; if (mIsDragging) { mIsDragging = false; mPopup.animateVisibility(false); if (stateChangeListener != null) { stateChangeListener.onFastScrollStop(); } } break; } }
From source file:com.gu.swiperefresh.SwipeRefreshPlush.java
public SwipeRefreshPlush(Context context, AttributeSet attrs) { super(context, attrs); mLoadViewController = new LoadViewController(context, this); mRefreshController = new RefreshViewController(context, this); // mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mScroller = ScrollerCompat.create(getContext()); createProgressView();/*from www . j a v a2 s . c o m*/ ViewCompat.setChildrenDrawingOrderEnabled(this, true); }
From source file:com.blestep.sportsbracelet.view.TimelineChartViewSleep.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr) { mUiHandler = new Handler(Looper.getMainLooper(), mMessenger); final Resources res = getResources(); final ViewConfiguration vc = ViewConfiguration.get(ctx); mTouchSlop = vc.getScaledTouchSlop() / 2; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(ctx); int footerLabelColor = ContextCompat.getColor(getContext(), R.color.tlcSleepFooterLabelColor); int barItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepBarItemBg); int highlightBarItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepHighlightBarItemBg); int barDeepItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepBarDeepItemBg); int highlightBarDeepItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepHighlightBarDeepItemBg); mBarItemBgPaint = new Paint(); mBarItemBgPaint.setColor(barItemBg); mHighlightBarItemBgPaint = new Paint(); mHighlightBarItemBgPaint.setColor(highlightBarItemBg); mBarDeepItemBgPaint = new Paint(); mBarDeepItemBgPaint.setColor(barDeepItemBg); mHighlightBarDeepItemBgPaint = new Paint(); mHighlightBarDeepItemBgPaint.setColor(highlightBarDeepItemBg); mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight); mViewAreaBgPaint = new Paint(); mGraphAreaBgPaint = new Paint(); mGraphAreaBgPaint.setColor(Color.TRANSPARENT); mFooterAreaBgPaint = new Paint(); mFooterAreaBgPaint.setColor(Color.TRANSPARENT); mGraphBottomLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGraphBottomLinePaint.setColor(Color.WHITE); mGraphBottomLinePaint.setStrokeWidth(1); // labelPaint?? mLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mLabelFgPaint.setColor(footerLabelColor); // DisplayMetrics dp = getResources().getDisplayMetrics(); // float labelSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, res.getDimension(R.dimen.tlcDefFooterLabelSize), dp); mLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mHighlightLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mHighlightLabelFgPaint.setColor(Color.WHITE); mHighlightLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth); mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace); mTopSpaceHeight = res.getDimension(R.dimen.tlcDefTopSpace); // SurfaceView requires a background if (getBackground() == null) { setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); }//from w w w . j av a2 s . c om // Initialize stuff setupBackgroundHandler(); setupTickLabels(); // Initialize the drawing refs (this will be update when we have // the real size of the canvas) computeBoundAreas(); }
From source file:com.blestep.sportsbracelet.view.TimelineChartView.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr) { mUiHandler = new Handler(Looper.getMainLooper(), mMessenger); final Resources res = getResources(); final ViewConfiguration vc = ViewConfiguration.get(ctx); mTouchSlop = vc.getScaledTouchSlop() / 2; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(ctx); int footerLabelColor = ContextCompat.getColor(getContext(), R.color.tlcStepsFooterLabelColor); int barItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsBarItemBg); int highlightBarItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsHighlightBarItemBg); mBarItemBgPaint = new Paint(); mBarItemBgPaint.setColor(barItemBg); mHighlightBarItemBgPaint = new Paint(); mHighlightBarItemBgPaint.setColor(highlightBarItemBg); mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight); mViewAreaBgPaint = new Paint(); mGraphAreaBgPaint = new Paint(); mGraphAreaBgPaint.setColor(Color.TRANSPARENT); mFooterAreaBgPaint = new Paint(); mFooterAreaBgPaint.setColor(Color.TRANSPARENT); mGraphBottomLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGraphBottomLinePaint.setColor(Color.WHITE); mGraphBottomLinePaint.setStrokeWidth(1); // /* w w w .j a v a 2 s. co m*/ mGraphTargetDashedLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGraphTargetDashedLinePaint.setStyle(Paint.Style.STROKE); mGraphTargetDashedLinePaint.setColor(Color.WHITE); mGraphTargetDashedLinePaint.setStrokeWidth(1); PathEffect pathEffect = new DashPathEffect(new float[] { 9, 3 }, 1); mGraphTargetDashedLinePaint.setPathEffect(pathEffect); // labelPaint?? mLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mLabelFgPaint.setColor(footerLabelColor); // DisplayMetrics dp = getResources().getDisplayMetrics(); // float labelSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, res.getDimension(R.dimen.tlcDefFooterLabelSize), dp); mLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mHighlightLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mHighlightLabelFgPaint.setColor(Color.WHITE); mHighlightLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth); mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace); mTopSpaceHeight = res.getDimension(R.dimen.tlcDefTopSpace); // SurfaceView requires a background if (getBackground() == null) { setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); } // Initialize stuff setupBackgroundHandler(); setupTickLabels(); // Initialize the drawing refs (this will be update when we have // the real size of the canvas) computeBoundAreas(); }