List of usage examples for android.view ViewConfiguration getScaledTouchSlop
public int getScaledTouchSlop()
From source file:martin.app.bitunion.widget.PhotoView.java
/** * Initializes the header and any static values *///from w ww.j av a 2 s . c om private void initialize() { Context context = getContext(); if (!sInitialized) { sInitialized = true; Resources resources = context.getApplicationContext().getResources(); // sCropSize = TypedValue.complexToDimensionPixelSize(120, resources.getDisplayMetrics()); sCropDimPaint = new Paint(); sCropDimPaint.setAntiAlias(true); // sCropDimPaint.setColor(0xcc000000); sCropDimPaint.setStyle(Paint.Style.FILL); sCropPaint = new Paint(); sCropPaint.setAntiAlias(true); // sCropPaint.setColor(Color.WHITE); sCropPaint.setStyle(Paint.Style.STROKE); // sCropPaint.setStrokeWidth(TypedValue.complexToDimensionPixelSize(1, resources.getDisplayMetrics())); final ViewConfiguration configuration = ViewConfiguration.get(context); final int touchSlop = configuration.getScaledTouchSlop(); sTouchSlopSquare = touchSlop * touchSlop; } mGestureDetector = new GestureDetectorCompat(context, this, null); mScaleGetureDetector = new ScaleGestureDetector(context, this); mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(mScaleGetureDetector); mScaleRunnable = new ScaleRunnable(this); mTranslateRunnable = new TranslateRunnable(this); mSnapRunnable = new SnapRunnable(this); mRotateRunnable = new RotateRunnable(this); }
From source file:android.wuliqing.com.lendphonesystemapp.swipeBack.ViewDragHelper.java
/** * Sets the sensitivity of the dragger.//w w w . j ava 2 s . c o m * * @param context The application context. * @param sensitivity value between 0 and 1, the final value for touchSlop = * ViewConfiguration.getScaledTouchSlop * (1 / s); */ public void setSensitivity(Context context, float sensitivity) { float s = Math.max(0f, Math.min(1.0f, sensitivity)); ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mTouchSlop = (int) (viewConfiguration.getScaledTouchSlop() * (1 / s)); }
From source file:com.iterlog.swipbackhelper.ViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. This will * allow VDH to use internal compatibility implementations for different * platform versions./* ww w .ja v a 2 s. c o m*/ * * @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); }
From source file:com.cyanogenmod.filemanager.ui.widgets.ViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. * This will allow VDH to use internal compatibility implementations for different * platform versions.// w w w . ja v a 2 s. c o m * * @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 = new Scroller(context, sInterpolator); }
From source file:com.albedinsky.android.support.ui.widget.ViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. * This will allow VDH to use internal compatibility implementations for different * platform versions./*from ww w. j ava 2 s . c o m*/ * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ 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); mScroller = new Scroller(context, sInterpolator); }
From source file:com.android.ex.widget.StaggeredGridView.java
public StaggeredGridView(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 = ScrollerCompat.from(context); mTopEdge = new EdgeEffectCompat(context); mBottomEdge = new EdgeEffectCompat(context); setWillNotDraw(false);/* ww w. j a v a2s . c om*/ setClipToPadding(false); }
From source file:cn.ieclipse.af.view.StaggeredGridView.java
public StaggeredGridView(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 = ScrollerCompat.create(context); mTopEdge = new EdgeEffectCompat(context); mBottomEdge = new EdgeEffectCompat(context); setWillNotDraw(false);//w w w. jav a2 s.c o m setClipToPadding(false); }
From source file:com.android.volley.ui.PhotoView.java
/** * Initializes the header and any static values *///from ww w .jav a2 s .c o m private void initialize() { Context context = getContext(); if (!sInitialized) { sInitialized = true; Resources resources = context.getApplicationContext().getResources(); sCropSize = resources.getDimensionPixelSize(R.dimen.photo_crop_width); sCropDimPaint = new Paint(); sCropDimPaint.setAntiAlias(true); sCropDimPaint.setColor(resources.getColor(R.color.photo_crop_dim_color)); sCropDimPaint.setStyle(Style.FILL); sCropPaint = new Paint(); sCropPaint.setAntiAlias(true); sCropPaint.setColor(resources.getColor(R.color.photo_crop_highlight_color)); sCropPaint.setStyle(Style.STROKE); sCropPaint.setStrokeWidth(resources.getDimension(R.dimen.photo_crop_stroke_width)); final ViewConfiguration configuration = ViewConfiguration.get(context); final int touchSlop = configuration.getScaledTouchSlop(); sTouchSlopSquare = touchSlop * touchSlop; } mGestureDetector = new GestureDetectorCompat(context, this, null); mScaleGetureDetector = new ScaleGestureDetector(context, this); mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(mScaleGetureDetector); mScaleRunnable = new ScaleRunnable(this); mTranslateRunnable = new TranslateRunnable(this); mSnapRunnable = new SnapRunnable(this); mRotateRunnable = new RotateRunnable(this); }
From source file:com.andr.studio.proj.swipetab.slidingpanellayout.SlidingViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. * This will allow VDH to use internal compatibility implementations for different * platform versions.// w w w . ja v a 2s. c o m * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private SlidingViewDragHelper(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); }
From source file:com.example.administrator.mouseapp.M5ViewDragHelper.java
/** * Apps should use ViewDragHelper.create() to get a new instance. * This will allow VDH to use internal compatibility implementations for different * platform versions.//from w w w . j a va 2 s . c om * * @param context Context to initialize config-dependent params from * @param forParent Parent view to monitor */ private M5ViewDragHelper(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); }