Search in sources :

Example 86 with ViewConfiguration

use of android.view.ViewConfiguration in project RefreshableListView by woozzu.

the class RefreshableListView method dispatchTouchEvent.

@Override
public boolean dispatchTouchEvent(final MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_MOVE && getFirstVisiblePosition() == 0) {
        float direction = ev.getY() - mHistoricalY;
        int height = (int) (ev.getY() - mY) / 2 + mInitialHeight;
        if (height < 0) {
            height = 0;
        }
        float deltaY = Math.abs(mY - ev.getY());
        ViewConfiguration config = ViewConfiguration.get(getContext());
        if (deltaY > config.getScaledTouchSlop()) {
            // Scrolling downward
            if (direction > 0) {
                // visible
                if (getChildAt(0).getTop() == 0) {
                    if (mHistoricalTop < 0) {
                    // mY = ev.getY(); // TODO works without
                    // this?mHistoricalTop = 0;
                    }
                    // Extends refresh bar
                    setHeaderHeight(height);
                    // Stop list scroll to prevent the list from
                    // overscrolling
                    ev.setAction(MotionEvent.ACTION_CANCEL);
                    mFlag = false;
                }
            } else if (direction < 0) {
                // visible
                if (getChildAt(0).getTop() == 0) {
                    setHeaderHeight(height);
                    // enabled
                    if (getChildAt(1) != null && getChildAt(1).getTop() <= 1 && !mFlag) {
                        ev.setAction(MotionEvent.ACTION_DOWN);
                        mFlag = true;
                    }
                }
            }
        }
        mHistoricalY = ev.getY();
    }
    try {
        return super.dispatchTouchEvent(ev);
    } catch (Exception e) {
        return false;
    }
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Example 87 with ViewConfiguration

use of android.view.ViewConfiguration in project Remindy by abicelis.

the class BetterNestedScrollView method init.

private void init(Context context) {
    ViewConfiguration config = ViewConfiguration.get(context);
    slop = config.getScaledEdgeSlop();
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Example 88 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class AbsListView method initAbsListView.

private void initAbsListView() {
    // Setting focusable in touch mode will set the focusable property to true
    setClickable(true);
    setFocusableInTouchMode(true);
    setWillNotDraw(false);
    setAlwaysDrawnWithCacheEnabled(false);
    boolean scrollingCacheEnabled = (mScrollingCacheProperty < 2);
    setScrollingCacheEnabled(scrollingCacheEnabled);
    final ViewConfiguration configuration = ViewConfiguration.get(mContext);
    mTouchSlop = configuration.getScaledTouchSlop();
    mScrollFactor = configuration.getScaledScrollFactor();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mDecacheThreshold = mMaximumVelocity / 2;
    mOverscrollDistance = configuration.getScaledOverscrollDistance();
    mOverflingDistance = configuration.getScaledOverflingDistance();
    mDensityScale = getContext().getResources().getDisplayMetrics().density;
    setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE | ViewGroup.PERSISTENT_SCROLLING_CACHE);
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Example 89 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class StackView method initStackView.

private void initStackView() {
    configureViewAnimator(NUM_ACTIVE_VIEWS, 1);
    setStaticTransformationsEnabled(true);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mActivePointerId = INVALID_POINTER;
    mHighlight = new ImageView(getContext());
    mHighlight.setLayoutParams(new LayoutParams(mHighlight));
    addViewInLayout(mHighlight, -1, new LayoutParams(mHighlight));
    mClickFeedback = new ImageView(getContext());
    mClickFeedback.setLayoutParams(new LayoutParams(mClickFeedback));
    addViewInLayout(mClickFeedback, -1, new LayoutParams(mClickFeedback));
    mClickFeedback.setVisibility(INVISIBLE);
    mStackSlider = new StackSlider();
    if (sHolographicHelper == null) {
        sHolographicHelper = new HolographicHelper(mContext);
    }
    setClipChildren(false);
    setClipToPadding(false);
    // This sets the form of the StackView, which is currently to have the perspective-shifted
    // views above the active view, and have items slide down when sliding out. The opposite is
    // available by using ITEMS_SLIDE_UP.
    mStackMode = ITEMS_SLIDE_DOWN;
    // This is a flag to indicate the the stack is loading for the first time
    mWhichChild = -1;
    // Adjust the frame padding based on the density, since the highlight changes based
    // on the density
    final float density = mContext.getResources().getDisplayMetrics().density;
    mFramePadding = (int) Math.ceil(density * FRAME_PADDING);
}
Also used : ViewConfiguration(android.view.ViewConfiguration)

Example 90 with ViewConfiguration

use of android.view.ViewConfiguration in project android_frameworks_base by crdroidandroid.

the class SwipeDismissLayout method init.

private void init(Context context) {
    ViewConfiguration vc = ViewConfiguration.get(context);
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    TypedArray a = context.getTheme().obtainStyledAttributes(com.android.internal.R.styleable.Theme);
    mIsWindowNativelyTranslucent = a.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent, false);
    a.recycle();
}
Also used : ViewConfiguration(android.view.ViewConfiguration) TypedArray(android.content.res.TypedArray)

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