Search in sources :

Example 46 with ViewConfiguration

use of android.view.ViewConfiguration in project UltimateAndroid by cymcsg.

the class ViewDragHelper method setSensitivity.

/**
     * Sets the sensitivity of the dragger.
     *
     * @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));
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Example 47 with ViewConfiguration

use of android.view.ViewConfiguration in project GreenDroid by cyrilmottier.

the class PagedView method initPagedView.

private void initPagedView() {
    final Context context = getContext();
    mScroller = new Scroller(context, new DecelerateInterpolator());
    final ViewConfiguration conf = ViewConfiguration.get(context);
    // getScaledPagingTouchSlop() only available in API Level 8
    mPagingTouchSlop = conf.getScaledTouchSlop() * 2;
    mMaximumVelocity = conf.getScaledMaximumFlingVelocity();
    final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    mMinimumVelocity = (int) (metrics.density * MINIMUM_PAGE_CHANGE_VELOCITY + 0.5f);
}
Also used : Context(android.content.Context) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ViewConfiguration(android.view.ViewConfiguration) Scroller(android.widget.Scroller) DisplayMetrics(android.util.DisplayMetrics)

Example 48 with ViewConfiguration

use of android.view.ViewConfiguration in project mobile-android by photo.

the class HorizontalFixedListView method initView.

/**
	 * Inits the view.
	 */
private synchronized void initView() {
    if (Build.VERSION.SDK_INT > 8) {
        try {
            mFlingRunnable = (IFlingRunnable) ReflectionUtils.newInstance("com.aviary.android.feather.widget.Fling9Runnable", new Class<?>[] { FlingRunnableView.class, int.class }, this, mAnimationDuration);
        } catch (ReflectionException e) {
            mFlingRunnable = new Fling8Runnable(this, mAnimationDuration);
        }
    } else {
        mFlingRunnable = new Fling8Runnable(this, mAnimationDuration);
    }
    mLeftViewIndex = -1;
    mRightViewIndex = 0;
    mMaxX = 0;
    mMinX = 0;
    mChildWidth = 0;
    mChildHeight = 0;
    mRightEdge = 0;
    mLeftEdge = 0;
    mGesture = new GestureDetector(getContext(), mGestureListener);
    mGesture.setIsLongpressEnabled(true);
    setFocusable(true);
    setFocusableInTouchMode(true);
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mDragTolerance = mTouchSlop;
    mOverscrollDistance = 10;
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
}
Also used : ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) ViewConfiguration(android.view.ViewConfiguration) GestureDetector(android.view.GestureDetector)

Example 49 with ViewConfiguration

use of android.view.ViewConfiguration in project android-support-v4-googlemaps by petedoyle.

the class ViewPager method initViewPager.

void initViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);
    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}
Also used : Context(android.content.Context) ViewConfiguration(android.view.ViewConfiguration) EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat) Scroller(android.widget.Scroller)

Example 50 with ViewConfiguration

use of android.view.ViewConfiguration in project superCleanMaster by joyoyao.

the class ViewDragHelper method setSensitivity.

/**
     * Sets the sensitivity of the dragger.
     *
     * @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));
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Aggregations

ViewConfiguration (android.view.ViewConfiguration)186 Scroller (android.widget.Scroller)41 Context (android.content.Context)28 TypedArray (android.content.res.TypedArray)23 EdgeEffectCompat (android.support.v4.widget.EdgeEffectCompat)16 Point (android.graphics.Point)12 View (android.view.View)12 OverScroller (android.widget.OverScroller)10 Field (java.lang.reflect.Field)9 Resources (android.content.res.Resources)8 Paint (android.graphics.Paint)7 RectF (android.graphics.RectF)7 DisplayMetrics (android.util.DisplayMetrics)7 Drawable (android.graphics.drawable.Drawable)6 GestureDetector (android.view.GestureDetector)6 PointF (android.graphics.PointF)5 ImageView (android.widget.ImageView)5 FlingAnimationUtils (com.android.systemui.statusbar.FlingAnimationUtils)5 SlidingTabLayout (com.google.samples.apps.iosched.ui.widget.SlidingTabLayout)4 TimeInterpolator (android.animation.TimeInterpolator)3