final ViewConfiguration vc = ViewConfiguration.get(getContext()); final int swipeMinDistance = vc.getScaledPagingTouchSlop(); final int swipeThresholdVelocity = vc.getScaledMinimumFlingVelocity(); final int swipeMaxOffPath = vc.getScaledTouchSlop(); // (there is also vc.getScaledMaximumFlingVelocity() one could check against)
public CupcakeDetector(Context context) { final ViewConfiguration configuration = ViewConfiguration.get(context); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mTouchSlop = configuration.getScaledTouchSlop(); }
public CupcakeDetector(Context context) { final ViewConfiguration configuration = ViewConfiguration.get(context); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mTouchSlop = configuration.getScaledTouchSlop(); }
/** * initialize method, called inside the Chart.init() method. * * @param context */ @SuppressWarnings("deprecation") public static void init(Context context) { if (context == null) { // noinspection deprecation mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity(); // noinspection deprecation mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity(); Log.e("MPChartLib-Utils" , "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL"); } else { ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity(); Resources res = context.getResources(); mMetrics = res.getDisplayMetrics(); } }
CustomGestureDetector(Context context, OnGestureListener listener) { final ViewConfiguration configuration = ViewConfiguration .get(context); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mTouchSlop = configuration.getScaledTouchSlop(); mListener = listener; ScaleGestureDetector.OnScaleGestureListener mScaleListener = new ScaleGestureDetector.OnScaleGestureListener() { @Override public boolean onScale(ScaleGestureDetector detector) { float scaleFactor = detector.getScaleFactor(); if (Float.isNaN(scaleFactor) || Float.isInfinite(scaleFactor)) return false; if (scaleFactor >= 0) { mListener.onScale(scaleFactor, detector.getFocusX(), detector.getFocusY()); } return true; } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { return true; } @Override public void onScaleEnd(ScaleGestureDetector detector) { // NO-OP } }; mDetector = new ScaleGestureDetector(context, mScaleListener); }
/** * Apps should use ViewDragHelper.create() to get a new instance. * This will allow VDH to use internal compatibility implementations for different * platform versions. * If the interpolator is null, the default interpolator will be used. * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor * @param interpolator interpolator for scroller */ private ViewDragHelper(Context context, ViewGroup forParent, Interpolator interpolator, Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } if (cb == null) { throw new IllegalArgumentException("Callback may not be null"); } mParentView = forParent; mCallback = cb; final ViewConfiguration vc = ViewConfiguration.get(context); final float density = context.getResources().getDisplayMetrics().density; mEdgeSize = (int) (EDGE_SIZE * density + 0.5f); mTouchSlop = vc.getScaledTouchSlop(); mMaxVelocity = vc.getScaledMaximumFlingVelocity(); mMinVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = ScrollerCompat.create(context, interpolator != null ? interpolator : sInterpolator); }
protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){ mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mDrawRect = new RectF(); mTempRect = new RectF(); mTrackPath = new Path(); mFlingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity(); applyStyle(context, attrs, defStyleAttr, defStyleRes); if(!isInEditMode()) mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes); }
/** * Apps should use ViewDragHelper.create() to get a new instance. * This will allow VDH to use internal compatibility implementations for different * platform versions. * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } if (cb == null) { throw new IllegalArgumentException("Callback may not be null"); } mParentView = forParent; mCallback = cb; final ViewConfiguration vc = ViewConfiguration.get(context); final float density = context.getResources().getDisplayMetrics().density; mEdgeSize = (int) (EDGE_SIZE * density + 0.5f); mTouchSlop = vc.getScaledTouchSlop(); mMaxVelocity = vc.getScaledMaximumFlingVelocity(); mMinVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = ScrollerCompat.create(context, sInterpolator); }
public SlidingRootNavLayout(Context context) { super(context); dragListeners = new ArrayList<>(); dragStateListeners = new ArrayList<>(); FLING_MIN_VELOCITY = ViewConfiguration.get(context).getScaledMinimumFlingVelocity(); dragHelper = ViewDragHelper.create(this, new ViewDragCallback()); dragProgress = 0f; isMenuHidden = true; }
protected void init(Context context, AttributeSet attrs, int defStyle) { ViewConfiguration configuration = ViewConfiguration.get(context); mMinFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = configuration.getScaledMaximumFlingVelocity(); mDefaultAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); setScaleType(ScaleType.MATRIX); }
/** * Apps should use ViewDragHelper.create() to get a new instance. This will * allow VDH to use internal compatibility implementations for different * platform versions. * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) { if (forParent == null) { throw new IllegalArgumentException("Parent view may not be null"); } if (cb == null) { throw new IllegalArgumentException("Callback may not be null"); } mParentView = forParent; mCallback = cb; final ViewConfiguration vc = ViewConfiguration.get(context); final float density = context.getResources().getDisplayMetrics().density; mEdgeSize = (int) (EDGE_SIZE * density + 0.5f); mTouchSlop = vc.getScaledTouchSlop(); mMaxVelocity = vc.getScaledMaximumFlingVelocity(); mMinVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = ScrollerCompat.create(context, sInterpolator); }
public ViewConfigurationAssert hasScaledMinimumFlingVelocity(int velocity) { isNotNull(); int actualVelocity = actual.getScaledMinimumFlingVelocity(); assertThat(actualVelocity) // .overridingErrorMessage("Expected scaled minimum fling velocity <%s> but was <%s>", velocity, actualVelocity) // .isEqualTo(velocity); return this; }
public PullBackLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); dragger = ViewDragHelper.create(this, 1f / 8f, new ViewDragCallback()); // 1f / 8f是敏感度参数参数越大越敏感 minimumFlingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity(); }
private void init() { ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext()); minFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); touchSlop = viewConfiguration.getScaledTouchSlop(); dimView = new View(getContext()); dimView.setBackgroundColor(Color.BLACK); dimView.setAlpha(0); dimView.setVisibility(INVISIBLE); setFocusableInTouchMode(true); Point point = new Point(); ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getSize(point); screenWidth = point.x; sheetEndX = screenWidth; peek = 0; //getHeight() return 0 at start! peekKeyline = point.y - (screenWidth / (16.0f / 9.0f)); }
private void initAbsListView() { // Setting focusable in touch mode will set the focusable property to true setClickable(true); setFocusableInTouchMode(true); setWillNotDraw(false); setAlwaysDrawnWithCacheEnabled(false); setScrollingCacheEnabled(true); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mSwipeThresholdDistance = mTouchSlop * MIN_DISTANCE_TOUCH_SLOP_MUL;
public LargeImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mScroller = ScrollerCompat.create(getContext(), null); scaleHelper = new ScaleHelper(); setFocusable(true); setWillNotDraw(false); gestureDetector = new GestureDetector(context, simpleOnGestureListener); scaleGestureDetector = new ScaleGestureDetector(context, onScaleGestureListener); imageBlockImageLoader = new BlockImageLoader(context); imageBlockImageLoader.setOnImageLoadListener(this); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); paint = new Paint(); paint.setColor(Color.GRAY); paint.setAntiAlias(true); }
public GestureController(@NonNull View view) { final Context context = view.getContext(); targetView = view; settings = new Settings(); stateController = new StateController(settings); animationEngine = new LocalAnimationEngine(view); InternalGesturesListener internalListener = new InternalGesturesListener(); gestureDetector = new GestureDetector(context, internalListener); scaleDetector = new ScaleGestureDetectorFixed(context, internalListener); rotateDetector = new RotationGestureDetector(context, internalListener); exitController = new ExitController(view, this); flingScroller = new OverScroller(context); stateScroller = new FloatScroller(); flingBounds = new MovementBounds(settings); final ViewConfiguration configuration = ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); minVelocity = configuration.getScaledMinimumFlingVelocity(); maxVelocity = configuration.getScaledMaximumFlingVelocity(); }
@Test public void methodsShouldReturnScaledAndroidConstantsDependingOnPixelDensity() { context.getResources().getDisplayMetrics().density = 1.5f; ViewConfiguration viewConfiguration = ViewConfiguration.get(context); assertEquals(15, viewConfiguration.getScaledScrollBarSize()); assertEquals(18, viewConfiguration.getScaledFadingEdgeLength()); assertEquals(18, viewConfiguration.getScaledEdgeSlop()); assertEquals(24, viewConfiguration.getScaledTouchSlop()); assertEquals(48, viewConfiguration.getScaledPagingTouchSlop()); assertEquals(150, viewConfiguration.getScaledDoubleTapSlop()); assertEquals(24, viewConfiguration.getScaledWindowTouchSlop()); assertEquals(75, viewConfiguration.getScaledMinimumFlingVelocity()); assertEquals(6000, viewConfiguration.getScaledMaximumFlingVelocity()); }
assertEquals(100, viewConfiguration.getScaledDoubleTapSlop()); assertEquals(16, viewConfiguration.getScaledWindowTouchSlop()); assertEquals(50, viewConfiguration.getScaledMinimumFlingVelocity()); assertEquals(4000, viewConfiguration.getScaledMaximumFlingVelocity());