Search in sources :

Example 61 with Scroller

use of android.widget.Scroller in project android_packages_apps_Launcher2 by CyanogenMod.

the class SmoothPagedView method init.

/**
     * Initializes various states for this workspace.
     */
@Override
protected void init() {
    super.init();
    mScrollMode = getScrollMode();
    if (mScrollMode == DEFAULT_MODE) {
        mBaseLineFlingVelocity = 2500.0f;
        mFlingVelocityInfluence = 0.4f;
        mScrollInterpolator = new OvershootInterpolator();
        mScroller = new Scroller(getContext(), mScrollInterpolator);
    }
}
Also used : Scroller(android.widget.Scroller)

Example 62 with Scroller

use of android.widget.Scroller in project InfiniteCycleViewPager by Devlight.

the class VerticalViewPager 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);
    final float density = context.getResources().getDisplayMetrics().density;
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    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 63 with Scroller

use of android.widget.Scroller in project Reader by TheKeeperOfPie.

the class ImageViewZoom method initialize.

private void initialize() {
    setClickable(true);
    scroller = new Scroller(getContext());
    scaleGestureDetector = new ScaleGestureDetector(getContext(), new ScaleGestureDetector.SimpleOnScaleGestureListener() {

        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            //                Log.d(TAG, "onScale() called with: " + "detector = [" + detector + "]");
            //
            //                Log.d(TAG, "onScale() called with: " + "focusX = [" + detector.getFocusX() + "], focusY = [" + detector.getFocusY() + "], width = [" + getWidth() + "], height = [" + getHeight() + "]");
            //                float translationX = detector.getFocusX() * (translationMaxX - translationMinX) / getWidth() + translationMinX;
            //                float translationY = detector.getFocusY() * (translationMaxY - translationMinY) / getHeight() + translationMinY;
            //                setTranslation(translationX, translationY);
            applyScaleFactor(detector.getFocusX(), detector.getFocusY(), detector.getScaleFactor());
            return true;
        }
    });
    gestureDetector = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {

        private int pointerCount;

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            //                Log.d(TAG, "onScroll() called with: " + "translationX = [" + translationX + "], translationMinX = [" + translationMinX + "], translationMaxX = [" + translationMaxX + "], scaleStart = [" + scaleStart + "], scaleCurrent = [" + scaleCurrent + "], contentWidth = [" + contentWidth + "]");
            //                Log.d(TAG, "onScroll() called with relative: " + "x = [" + getRelativeX() + "], y = [" + getRelativeY() + "]");
            scroller.forceFinished(true);
            if (pointerCount == 1) {
                applyTranslation(-distanceX, -distanceY);
            }
            return super.onScroll(e1, e2, distanceX, distanceY);
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            scroller.forceFinished(true);
            if (pointerCount == 1) {
                Log.d(TAG, "onFling() called with: " + "e1 = [" + e1 + "], e2 = [" + e2 + "], velocityX = [" + velocityX + "], velocityY = [" + velocityY + "]");
                scroller.fling((int) translationX, (int) translationY, (int) velocityX, (int) velocityY, (int) translationMinX, (int) translationMaxX, (int) translationMinY, (int) translationMaxY);
                post(runnableScroll);
            }
            return super.onFling(e1, e2, velocityX, velocityY);
        }

        @Override
        public boolean onDown(MotionEvent e) {
            pointerCount = e.getPointerCount();
            return super.onDown(e);
        }
    });
}
Also used : Scroller(android.widget.Scroller) ScaleGestureDetector(android.view.ScaleGestureDetector) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) MotionEvent(android.view.MotionEvent)

Example 64 with Scroller

use of android.widget.Scroller in project Fairphone by Kwamecorp.

the class SmoothPagedView method init.

/**
     * Initializes various states for this workspace.
     */
@Override
protected void init() {
    super.init();
    mScrollMode = getScrollMode();
    if (mScrollMode == DEFAULT_MODE) {
        mBaseLineFlingVelocity = 2500.0f;
        mFlingVelocityInfluence = 0.4f;
        mScrollInterpolator = new OvershootInterpolator();
        mScroller = new Scroller(getContext(), mScrollInterpolator);
    }
}
Also used : Scroller(android.widget.Scroller)

Example 65 with Scroller

use of android.widget.Scroller in project StickyHeaderListView by sfsheng0322.

the class SmoothListView method initWithContext.

private void initWithContext(Context context) {
    mScroller = new Scroller(context, new DecelerateInterpolator());
    // XListView need the scroll event, and it will dispatch the event to
    // user's listener (as a proxy).
    super.setOnScrollListener(this);
    // init header view
    mHeaderView = new SmoothListViewHeader(context);
    mHeaderViewContent = (RelativeLayout) mHeaderView.findViewById(R.id.smoothlistview_header_content);
    mHeaderTimeView = (TextView) mHeaderView.findViewById(R.id.smoothlistview_header_time);
    addHeaderView(mHeaderView);
    // init footer view
    mFooterView = new SmoothListViewFooter(context);
    // init header height
    mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            mHeaderViewHeight = mHeaderViewContent.getHeight();
            getViewTreeObserver().removeGlobalOnLayoutListener(this);
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) Scroller(android.widget.Scroller)

Aggregations

Scroller (android.widget.Scroller)89 ViewConfiguration (android.view.ViewConfiguration)41 Context (android.content.Context)29 Paint (android.graphics.Paint)14 EdgeEffectCompat (android.support.v4.widget.EdgeEffectCompat)14 GestureDetector (android.view.GestureDetector)13 Rect (android.graphics.Rect)12 Point (android.graphics.Point)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 DisplayMetrics (android.util.DisplayMetrics)6 View (android.view.View)4 OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)4 BounceInterpolator (android.view.animation.BounceInterpolator)4 Interpolator (android.view.animation.Interpolator)4 SuppressLint (android.annotation.SuppressLint)3 TypedArray (android.content.res.TypedArray)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 ImageView (android.widget.ImageView)3 OverScroller (android.widget.OverScroller)3 Animator (com.nineoldandroids.animation.Animator)3