Example usage for android.widget Scroller Scroller

List of usage examples for android.widget Scroller Scroller

Introduction

In this page you can find the example usage for android.widget Scroller Scroller.

Prototype

public Scroller(Context context, Interpolator interpolator) 

Source Link

Document

Create a Scroller with the specified interpolator.

Usage

From source file:com.oguzbabaoglu.cardpager.CardPager.java

void initCardPager() {

    setWillNotDraw(true);/*from  w w  w .  jav a  2s .  c  o m*/
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    setChildrenDrawingOrderEnabled(true);

    final Context context = getContext();
    final ViewConfiguration configuration = ViewConfiguration.get(context);

    density = context.getResources().getDisplayMetrics().density;
    scroller = new Scroller(context, INTERPOLATOR);

    touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    maximumVelocity = configuration.getScaledMaximumFlingVelocity();

    minimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    flingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    catchAllowance = (int) (CATCH_ALLOWANCE * density);
}

From source file:cn.edu.zafu.easemob.imagecoverflow.CoverFlowView.java

private void init() {
    setWillNotDraw(false);// w w  w  . j  ava  2  s  .  c  o m
    setClickable(true);

    mChildTransformer = new Matrix();
    mReflectionTransformer = new Matrix();

    mTouchRect = new RectF();

    mImageRecorder = new SparseArray<int[]>();

    mDrawChildPaint = new Paint();
    mDrawChildPaint.setAntiAlias(true);
    mDrawChildPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    mCoverFlowPadding = new Rect();

    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(getContext(), new AccelerateDecelerateInterpolator());
}

From source file:bk.vinhdo.taxiads.utils.view.SlidingLayer.java

private void init() {
    setWillNotDraw(false);/*from  www .jav  a  2  s . co m*/
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sMenuInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}

From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java

/**
 * Inits the custom view above./*from   w ww  .j  ava 2  s.co m*/
 */
void initCustomViewAbove() {
    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();
    setInternalPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            if (mViewBehind != null) {
                switch (position) {
                case 0:
                case 2:
                    mViewBehind.setChildrenEnabled(true);
                    break;
                case 1:
                    mViewBehind.setChildrenEnabled(false);
                    break;
                }
            }
        }
    });

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}

From source file:com.hb.hkm.slidinglayer.SlidLayer.java

private void init() {

    setWillNotDraw(false);//from  w  w  w  .  ja  v a2s .  co m
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);

    final Context context = getContext();
    mScroller = new Scroller(context, sMenuInterpolator);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);

    mRandom = new Random();
}

From source file:com.wunderlist.slidinglayer.SlidingLayer.java

private void init() {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(LAYER_TYPE_HARDWARE, null);
    }/*from  ww  w  .jav a 2s .co m*/

    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);

    final Context context = getContext();
    mScroller = new Scroller(context, sMenuInterpolator);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);

    mRandom = new Random();
}

From source file:com.yao.zhihudaily.tool.LazyViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*from   w  ww . j  a  v  a 2s . c  om*/
    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);
    float density = context.getResources().getDisplayMetrics().density;
    mBaseLineFlingVelocity = 2500.0f * density;
    mFlingVelocityInfluence = 0.4f;
}

From source file:com.samsistemas.calendarview.widget.CalendarView.java

/**
 * This method init all necessary variables and Views that our Calendar is going to use.
 *///from w w  w .ja v  a  2  s  .c  o m
private void init() {
    mScroller = new Scroller(mContext, null);

    //Variables associated to handle touch events..
    final ViewConfiguration configuration = ViewConfiguration.get(mContext);
    final float density = mContext.getResources().getDisplayMetrics().density;

    //Variables associated to Swipe..
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    //Inflate current view..
    mView = LayoutInflater.from(mContext).inflate(R.layout.material_calendar_with_title, this, true);

    //Get buttons for Calendar and set its listeners..
    mBackButton = (ImageView) mView.findViewById(R.id.left_button);
    mNextButton = (ImageView) mView.findViewById(R.id.right_button);

    mBackButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mCurrentMonthIndex--;
            mCalendar = Calendar.getInstance(Locale.getDefault());
            mCalendar.add(Calendar.MONTH, mCurrentMonthIndex);

            refreshCalendar(mCalendar);
            if (mOnMonthChangedListener != null) {
                mOnMonthChangedListener.onMonthChanged(mCalendar.getTime());
            }
        }
    });

    mNextButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mCurrentMonthIndex++;
            mCalendar = Calendar.getInstance(Locale.getDefault());
            mCalendar.add(Calendar.MONTH, mCurrentMonthIndex);
            refreshCalendar(mCalendar);

            if (mOnMonthChangedListener != null) {
                mOnMonthChangedListener.onMonthChanged(mCalendar.getTime());
            }
        }
    });

    setFirstDayOfWeek(Calendar.SUNDAY);
    refreshCalendar(Calendar.getInstance(getLocale()));
}

From source file:bw.com.yunifangstore.view.LazyViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*www  . j av  a 2 s.com*/
    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);

    float density = context.getResources().getDisplayMetrics().density;
    mBaseLineFlingVelocity = 2500.0f * density;
    mFlingVelocityInfluence = 0.4f;
}

From source file:com.microhealthllc.Slide.MultiShrinkScroller.java

/**
 * Create a new instance of MultiShrinkScroller.
 *
 * @param context//from   www  . j  ava 2s .  c om
 * @param attrs
 * @param defStyleAttr
 */
public MultiShrinkScroller(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    setFocusable(false);
    setWillNotDraw(false);

    edgeGlowBottom = new EdgeEffect(context);
    edgeGlowTop = new EdgeEffect(context);
    scroller = new Scroller(context, INTERPOLATOR);
    touchSlop = configuration.getScaledTouchSlop();
    minimumVelocity = configuration.getScaledMinimumFlingVelocity();
    maximumVelocity = configuration.getScaledMaximumFlingVelocity();
    transparentStartHeight = (int) getResources().getDimension(R.dimen.sliding_starting_empty_height);
    toolbarElevation = getResources().getDimension(R.dimen.sliding_toolbar_elevation);
    isTwoPanel = getResources().getBoolean(R.bool.sliding_two_panel);
    paddedLayout = getResources().getBoolean(R.bool.padded_layout);
    maximumTitleMargin = (int) getResources().getDimension(R.dimen.sliding_title_initial_margin);

    dismissDistanceOnScroll = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_scroll);
    dismissDistanceOnRelease = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_release);
    snapToTopSlopHeight = (int) getResources().getDimension(R.dimen.sliding_snap_to_top_slop_height);

    final TypedValue photoRatio = new TypedValue();
    getResources().getValue(R.dimen.sliding_landscape_photo_ratio, photoRatio, true);
    landscapePhotoRatio = photoRatio.getFloat();

    final TypedArray attributeArray = context
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    actionBarSize = attributeArray.getDimensionPixelSize(0, 0);
    minimumHeaderHeight = actionBarSize;
    attributeArray.recycle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        textSizePathInterpolator = new PathInterpolator(X1, Y1, X2, Y2);
    } else {
        textSizePathInterpolator = null;
    }
}