Search in sources :

Example 41 with Scroller

use of android.widget.Scroller in project JustAndroid by chinaltz.

the class AbWheelView method initData.

/**
	 * Initializes class data.
	 *
	 * @param context the context
	 */
private void initData(Context context) {
    mContext = context;
    gestureDetector = new GestureDetector(context, gestureListener);
    gestureDetector.setIsLongpressEnabled(false);
    scroller = new Scroller(context);
}
Also used : GestureDetector(android.view.GestureDetector) Scroller(android.widget.Scroller)

Example 42 with Scroller

use of android.widget.Scroller in project SmartAndroidSource by jaychou2012.

the class DragGridViewPager method initDraggableGridViewPager.

private void initDraggableGridViewPager() {
    setWillNotDraw(false);
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    setChildrenDrawingOrderEnabled(true);
    final Context context = getContext();
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mGridGap = (int) (DEFAULT_GRID_GAP * density);
    // internal paddings
    mPaddingLeft = getPaddingLeft();
    mPaddingTop = getPaddingTop();
    mPaddingRight = getPaddingRight();
    mPaddingButtom = getPaddingBottom();
    super.setPadding(0, 0, 0, 0);
    mScroller = new Scroller(context, sInterpolator);
    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);
}
Also used : Context(android.content.Context) ViewConfiguration(android.view.ViewConfiguration) Scroller(android.widget.Scroller)

Example 43 with Scroller

use of android.widget.Scroller in project Lazy by l123456789jy.

the class NoPreloadViewPager 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);
    float density = context.getResources().getDisplayMetrics().density;
    mBaseLineFlingVelocity = 2500.0f * density;
    mFlingVelocityInfluence = 0.4f;
}
Also used : Context(android.content.Context) ViewConfiguration(android.view.ViewConfiguration) EdgeEffectCompat(android.support.v4.widget.EdgeEffectCompat) Scroller(android.widget.Scroller)

Example 44 with Scroller

use of android.widget.Scroller in project SlidingMenu by jfeinstein10.

the class CustomViewAbove method initCustomViewAbove.

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);
}
Also used : Context(android.content.Context) ViewConfiguration(android.view.ViewConfiguration) Scroller(android.widget.Scroller)

Example 45 with Scroller

use of android.widget.Scroller in project MyDiary by erttyy8821.

the class PageEffectView method init.

private void init(Context context, Calendar calendar) {
    //In the Android 4.2 , LAYER_TYPE_SOFTWARE will cause some question
    int year = YearClass.get(context.getApplicationContext());
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1 || year < 2012) {
        this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    //View
    setScreen(context);
    createBitmaps();
    //Set calendar , this object should be created after w,h was set.
    calendarFactory = new CalendarFactory(context, calendar, mWidth, mHeight);
    //Page effect
    mPath0 = new Path();
    mPath1 = new Path();
    createDrawable();
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);
    ColorMatrix cm = new ColorMatrix();
    float[] array = { 0.55f, 0, 0, 0, 80.0f, 0, 0.55f, 0, 0, 80.0f, 0, 0, 0.55f, 0, 80.0f, 0, 0, 0, 0.2f, 0 };
    cm.set(array);
    mColorMatrixFilter = new ColorMatrixColorFilter(cm);
    mMatrix = new Matrix();
    mScroller = new Scroller(getContext());
    // 不让x,y为0,否则在点计算时会有问题
    mTouch.x = 0.01f;
    mTouch.y = 0.01f;
    //Set today text
    calendarFactory.onDraw(mCurrentPageCanvas);
}
Also used : Path(android.graphics.Path) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorMatrix(android.graphics.ColorMatrix) Matrix(android.graphics.Matrix) ColorMatrix(android.graphics.ColorMatrix) Paint(android.graphics.Paint) Scroller(android.widget.Scroller) Paint(android.graphics.Paint)

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