Search in sources :

Example 56 with Scroller

use of android.widget.Scroller in project remusic by aa112901.

the class RoundViewPager 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();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = 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);
    }
    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {

        private final Rect mTempRect = new Rect();

        @Override
        public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat originalInsets) {
            // First let the ViewPager itself try and consume them...
            final WindowInsetsCompat applied = ViewCompat.onApplyWindowInsets(v, originalInsets);
            if (applied.isConsumed()) {
                // If the ViewPager consumed all insets, return now
                return applied;
            }
            // Now we'll manually dispatch the insets to our children. Since ViewPager
            // children are always full-height, we do not want to use the standard
            // ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
            // the rest of the children will not receive any insets. To workaround this
            // we manually dispatch the applied insets, not allowing children to
            // consume them from each other. We do however keep track of any insets
            // which are consumed, returning the union of our children's consumption
            final Rect res = mTempRect;
            res.left = applied.getSystemWindowInsetLeft();
            res.top = applied.getSystemWindowInsetTop();
            res.right = applied.getSystemWindowInsetRight();
            res.bottom = applied.getSystemWindowInsetBottom();
            for (int i = 0, count = getChildCount(); i < count; i++) {
                final WindowInsetsCompat childInsets = ViewCompat.dispatchApplyWindowInsets(getChildAt(i), applied);
                // Now keep track of any consumed by tracking each dimension's min
                // value
                res.left = Math.min(childInsets.getSystemWindowInsetLeft(), res.left);
                res.top = Math.min(childInsets.getSystemWindowInsetTop(), res.top);
                res.right = Math.min(childInsets.getSystemWindowInsetRight(), res.right);
                res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(), res.bottom);
            }
            // Now return a new WindowInsets, using the consumed window insets
            return applied.replaceSystemWindowInsets(res.left, res.top, res.right, res.bottom);
        }
    });
    isRotating = false;
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) View(android.view.View) WindowInsetsCompat(android.support.v4.view.WindowInsetsCompat) ViewConfiguration(android.view.ViewConfiguration) EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat) Scroller(android.widget.Scroller)

Example 57 with Scroller

use of android.widget.Scroller in project remusic by aa112901.

the class LrcView method init.

/**
     * 初始化画笔等
     */
@Override
public void init(Context context) {
    mScroller = new Scroller(getContext());
    mPaintForHighLightLrc = new Paint();
    mPaintForHighLightLrc.setColor(mCurColorForHightLightLrc);
    mPaintForHighLightLrc.setTextSize(mCurSizeForHightLightLrc);
    mPaintForHighLightLrc.setAntiAlias(true);
    mPaintForOtherLrc = new Paint();
    mPaintForOtherLrc.setColor(mCurColorForOtherLrc);
    mPaintForOtherLrc.setTextSize(mCurSizeForOtherLrc);
    mPaintForOtherLrc.setAntiAlias(true);
    mPaintForTimeLine = new Paint();
    mPaintForTimeLine.setColor(COLOR_FOR_TIME_LINE);
    mPaintForTimeLine.setTextSize(SIZE_FOR_TIME);
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inDensity = 30;
    options.inTargetDensity = 30;
    arrowBitmap = BitmapFactory.decodeResource(context.getResources(), R.raw.lrc_arrow, options);
}
Also used : Scroller(android.widget.Scroller) Paint(android.graphics.Paint) BitmapFactory(android.graphics.BitmapFactory)

Example 58 with Scroller

use of android.widget.Scroller in project android-common by Trinea.

the class HorizontalListView method initView.

private synchronized void initView() {
    mLeftViewIndex = -1;
    mRightViewIndex = 0;
    mDisplayOffset = 0;
    mCurrentX = 0;
    mNextX = 0;
    mMaxX = Integer.MAX_VALUE;
    mScroller = new Scroller(getContext());
    mGesture = new GestureDetector(getContext(), mOnGesture);
}
Also used : GestureDetector(android.view.GestureDetector) Scroller(android.widget.Scroller)

Example 59 with Scroller

use of android.widget.Scroller in project StereoView by ImmortalZ.

the class StereoView method init.

/**
     * 初始化数据
     */
private void init(Context context) {
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mCamera = new Camera();
    mMatrix = new Matrix();
    if (mScroller == null) {
        mScroller = new Scroller(context);
    }
}
Also used : Matrix(android.graphics.Matrix) Camera(android.graphics.Camera) Scroller(android.widget.Scroller)

Example 60 with Scroller

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

the class PagedView method init.

/**
     * Initializes various states for this workspace.
     */
protected void init() {
    mDirtyPageContent = new ArrayList<Boolean>();
    mDirtyPageContent.ensureCapacity(32);
    mScroller = new Scroller(getContext(), new ScrollInterpolator());
    mCurrentPage = 0;
    mCenterPagesVertically = true;
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mPagingTouchSlop = configuration.getScaledPagingTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mDensity = getResources().getDisplayMetrics().density;
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
    mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * mDensity);
    mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * mDensity);
    setOnHierarchyChangeListener(this);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) 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