Java Code Examples for android.widget.OverScroller

The following are top voted examples for showing how to use android.widget.OverScroller. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Bridge   File: ResolverDrawerLayout.java   View source code 7 votes vote down vote up
public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout,
            defStyleAttr, 0);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_android_maxWidth, -1);
    mMaxCollapsedHeight = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeight, 0);
    mMaxCollapsedHeightSmall = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall,
            mMaxCollapsedHeight);
    a.recycle();

    mScrollIndicatorDrawable = context.getDrawable(R.drawable.scroll_indicator_material);

    mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
            android.R.interpolator.decelerate_quint));
    mVelocityTracker = VelocityTracker.obtain();

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
 
Example 2
Project: PageScrollView   File: PageScrollView.java   View source code 6 votes vote down vote up
@Override
public void computeScroll() {
    boolean scrollerWorkNow = SCROLL_STATE_SETTLING == mScrollState;
    OverScroller scroller = scrollerWorkNow ? getScroller() : null;
    if (scroller != null && scroller.computeScrollOffset()) {
        int oldX = getScrollX();
        int oldY = getScrollY();
        int x = scroller.getCurrX();
        int y = scroller.getCurrY();
        if (oldX != x || oldY != y) {
            scrollTo(x, y);
        }
        ViewCompat.postInvalidateOnAnimation(this);
    } else {
        if (scrollerWorkNow) {
            markAsWillIdle();
        }
    }
}
 
Example 3
Project: Hitalk   File: SpringView.java   View source code 6 votes vote down vote up
public SpringView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    inflater = LayoutInflater.from(context);

    mScroller = new OverScroller(context);

    //获取自定义属性
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SpringView);
    if (ta.hasValue(R.styleable.SpringView_type)){
        int type_int = ta.getInt(R.styleable.SpringView_type, 0);
        type = Type.values()[type_int];
    }
    if (ta.hasValue(R.styleable.SpringView_give)){
        int give_int = ta.getInt(R.styleable.SpringView_give, 0);
        give = Give.values()[give_int];
    }
    if (ta.hasValue(R.styleable.SpringView_header)){
        headerResoureId = ta.getResourceId(R.styleable.SpringView_header, 0);
    }
    if (ta.hasValue(R.styleable.SpringView_footer)){
        footerResoureId = ta.getResourceId(R.styleable.SpringView_footer, 0);
    }
    ta.recycle();
}
 
Example 4
Project: Hitalk   File: OverScrollLayout.java   View source code 6 votes vote down vote up
private void init() {
        configuration = ViewConfiguration.get(getContext());
        mScroller = new Scroller(getContext(), new OvershootInterpolator(0.75f));
        flingRunnable = new FlingRunnable();
        overScrollRunnable = new OverScrollRunnable();
        flingScroller = new OverScroller(getContext());
        detector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                if (isOverScrollTop || isOverScrollBottom || isOverScrollLeft || isOverScrollRight) {
                    return false;
                }
//
                flingRunnable.start(velocityX, velocityY);
                return false;
            }
        });
    }
 
Example 5
Project: WLLayout   File: WLLayout.java   View source code 6 votes vote down vote up
private void reflectAbsListView() {
    try {
        Class<?> absListViewCls = Class.forName("android.widget.AbsListView");
        Field mFlingRunnableField = absListViewCls.getDeclaredField("mFlingRunnable");
        mFlingRunnableField.setAccessible(true);
        Object mFlingRunnable = mFlingRunnableField.get(mListView);


        Class<?> flingRunnableCls = Class.forName("android.widget.AbsListView$FlingRunnable");
        Field mScrollerFeild = flingRunnableCls.getDeclaredField("mScroller");
        mScrollerFeild.setAccessible(true);
        mScrollerReflectd = (OverScroller) mScrollerFeild.get(mFlingRunnable);
    } catch (Exception e) {
        mScrollerReflectd = null;
        Log.d(TAG, "###Exception Stack###", new Throwable(e));
    }
}
 
Example 6
Project: RLibrary   File: RRecyclerView.java   View source code 6 votes vote down vote up
/**
 * 滚动结束后时的速率
 */
public float getLastVelocity() {
    Object mViewFlinger = Reflect.getMember(RecyclerView.class, this, "mViewFlinger");
    Object mScroller = Reflect.getMember(mViewFlinger, "mScroller");
    float currVelocity = 0f;
    if (mScroller instanceof OverScroller) {
        currVelocity = ((OverScroller) mScroller).getCurrVelocity();
    } else if (mScroller instanceof ScrollerCompat) {
        currVelocity = ((ScrollerCompat) mScroller).getCurrVelocity();
    } else {
        throw new IllegalArgumentException("未兼容的mScroller类型:" + mScroller.getClass().getSimpleName());
    }

    if (Float.isNaN(currVelocity)) {
        currVelocity = mLastVelocity;
    } else {
        mLastVelocity = currVelocity;
    }
    return currVelocity;
}
 
Example 7
Project: UiLib   File: SwipeMenuLayout.java   View source code 6 votes vote down vote up
public SwipeMenuLayout(Context context, AttributeSet attrs,
                       int defStyle) {
    super(context, attrs, defStyle);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout);
    mLeftViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_leftViewId, mLeftViewId);
    mContentViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_contentViewId, mContentViewId);
    mRightViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_rightViewId, mRightViewId);
    typedArray.recycle();

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mScaledTouchSlop = configuration.getScaledTouchSlop();
    mScaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mScaledMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();

    mScroller = new OverScroller(getContext());
}
 
Example 8
Project: OpenWithX   File: ResolverDrawerLayout.java   View source code 6 votes vote down vote up
public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout,
            defStyleAttr, 0);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_android_maxWidth, -1);
    mMaxCollapsedHeight = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeight, 0);
    mMaxCollapsedHeightSmall = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall,
            mMaxCollapsedHeight);
    a.recycle();

    mScrollIndicatorDrawable = context.getDrawable(R.drawable.scroll_indicator_material);

    mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
            android.R.interpolator.decelerate_quint));
    mVelocityTracker = VelocityTracker.obtain();

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
 
Example 9
Project: RLibrary   File: StickLayout2.java   View source code 6 votes vote down vote up
private void initLayout() {
    mOverScroller = new OverScroller(getContext());
    mGestureDetectorCompat = new GestureDetectorCompat(getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, final float velocityY) {
                    if (Math.abs(velocityX) > Math.abs(velocityY)) {
                        return false;
                    }

                    if (isFloat() /*&& velocityY < 0*/) {
                        return false;
                    }
                    fling(velocityY);
                    return true;
                }
            });
}
 
Example 10
Project: GitHub   File: BGAStickyNavLayout.java   View source code 5 votes vote down vote up
private void init(Context context) {
    setOrientation(VERTICAL);

    mOverScroller = new OverScroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
}
 
Example 11
Project: Bailan   File: PullToRefreshView.java   View source code 5 votes vote down vote up
public PullToRefreshView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mInflater = LayoutInflater.from(context);
    mScroller = new OverScroller(context);

    //获取自定义属性
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);
    if (ta.hasValue(R.styleable.PullToRefresh_header_indicator)) {
        mHeaderIndicatorClassName = ta.getString(R.styleable.PullToRefresh_header_indicator);
    }
    if (ta.hasValue(R.styleable.PullToRefresh_footer_indicator)) {
        mFooterIndicatorClassName = ta.getString(R.styleable.PullToRefresh_footer_indicator);
    }
    ta.recycle();
}
 
Example 12
Project: yphoto   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 13
Project: TestChat   File: SwipeMenuLayout.java   View source code 5 votes vote down vote up
public SwipeMenuLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout);
        mLeftViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_leftViewId, mLeftViewId);
        mContentViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_contentViewId, mContentViewId);
        mRightViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_rightViewId, mRightViewId);
        typedArray.recycle();

        ViewConfiguration mViewConfig = ViewConfiguration.get(getContext());
        mScaledTouchSlop = mViewConfig.getScaledTouchSlop();
        mScroller = new OverScroller(getContext());
        mScaledMinimumFlingVelocity = mViewConfig.getScaledMinimumFlingVelocity();
        mScaledMaximumFlingVelocity = mViewConfig.getScaledMaximumFlingVelocity();
}
 
Example 14
Project: Hitalk   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
  if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
    isPreGingerbread = true;
    scroller = new Scroller(context);
  } else {
    isPreGingerbread = false;
    overScroller = new OverScroller(context);
  }
}
 
Example 15
Project: AndroidBackendlessChat   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
	if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
		isPreGingerbread = true;
		scroller = new Scroller(context);
		
	} else {
		isPreGingerbread = false;
		overScroller = new OverScroller(context);
	}
}
 
Example 16
Project: xRecycleView   File: XRefreshLayout.java   View source code 5 votes vote down vote up
public XRefreshLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    MIN_LOADING_LAYOUG_HEIGHT = DensityUtil.dip2px(context, MIN_LOADING_LAYOUG_HEIGHT);
    OVERSCROLL_RANGE = DensityUtil.dip2px(context, OVERSCROLL_RANGE);

    scroller = new OverScroller(getContext());
    loadingLayout = new DefaultLoadingLayout();
}
 
Example 17
Project: RLibrary   File: RefreshLayout.java   View source code 5 votes vote down vote up
protected void initRefreshView() {
    mScroller = new OverScroller(getContext(), new DecelerateInterpolator());

    if (isInEditMode()) {
        return;
    }
    if (mTopView == null) {
        mTopView = new BasePointRefreshView(getContext());
        mTopView.setTag(TOP_VIEW);
    }
    if (mBottomView == null) {
        mBottomView = new BasePointRefreshView(getContext());
        mBottomView.setTag(TOP_VIEW);
    }
    if (mTipView == null) {
        RTextView textView = new RTextView(getContext());
        textView.setGravity(Gravity.CENTER);
        textView.setTextColor(Color.WHITE);
        textView.setRBackgroundColor(SkinHelper.getSkin().getThemeSubColor());
        textView.setBackgroundResource(R.drawable.base_bg_selector);
        textView.setText("测试专用...");
        textView.setTag(TIP_VIEW);
        int left = getResources().getDimensionPixelOffset(R.dimen.base_xhdpi);
        int top = getResources().getDimensionPixelOffset(R.dimen.base_ldpi);
        textView.setPadding(left, top, left, top);
        mTipView = textView;

        mTipView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                T_.show("Test");
            }
        });
    }
}
 
Example 18
Project: ImageMagnifier   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < 9) {
        this.isPreGingerbread = true;
        this.scroller = new Scroller(context);
        return;
    }
    this.isPreGingerbread = false;
    this.overScroller = new OverScroller(context);
}
 
Example 19
Project: chat-sdk-android-push-firebase   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
	if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
		isPreGingerbread = true;
		scroller = new Scroller(context);
		
	} else {
		isPreGingerbread = false;
		overScroller = new OverScroller(context);
	}
}
 
Example 20
Project: event-me   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 21
Project: Monolith   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 22
Project: Android_ImagePicker   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 23
Project: social-app-android   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 24
Project: CXJPadProject   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);
    }
    else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 25
Project: CXJPadProject   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);
    }
    else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 26
Project: LueansRead   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 27
Project: BlogBookApp   File: ZoomImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 28
Project: PhotoPicker-master   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
  if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
    isPreGingerbread = true;
    scroller = new Scroller(context);
  } else {
    isPreGingerbread = false;
    overScroller = new OverScroller(context);
  }
}
 
Example 29
Project: JZAndroidChart   File: OverScrollerCompat.java   View source code 5 votes vote down vote up
/**
 * @see android.view.ScaleGestureDetector#getCurrentSpanY()
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static float getCurrVelocity(OverScroller overScroller) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        return overScroller.getCurrVelocity();
    } else {
        return 0;
    }
}
 
Example 30
Project: Jiuchi   File: JiuChi.java   View source code 5 votes vote down vote up
private void init() {
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);
    mScroller = new OverScroller(getContext());
    mVelocityTracker = VelocityTracker.obtain();

    maximumFlingVelocity = ViewConfiguration.get(getContext()).getScaledMaximumFlingVelocity();
    minimumFlingVelocity = ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity();


}
 
Example 31
Project: BooheeRuler   File: InnerRuler.java   View source code 5 votes vote down vote up
public void init(Context context){
        mContext = context;

        mMaxLength = mParent.getMaxScale() - mParent.getMinScale();
        mCurrentScale = mParent.getCurrentScale();
        mCount = mParent.getCount();
        mDrawOffset = mCount * mParent.getInterval() / 2;

        initPaints();

        mOverScroller = new OverScroller(mContext);

//        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        //配置速度
        mVelocityTracker = VelocityTracker.obtain();
        mMaximumVelocity = ViewConfiguration.get(context)
                .getScaledMaximumFlingVelocity();
        mMinimumVelocity = ViewConfiguration.get(context)
                .getScaledMinimumFlingVelocity();

        initEdgeEffects();

        //第一次进入,跳转到设定刻度
        getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
                goToScale(mCurrentScale);
            }
        });
        checkAPILevel();
    }
 
Example 32
Project: spinify_android   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 33
Project: Expert-Android-Programming   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 34
Project: boohee_v5.6   File: BooheeRulerView.java   View source code 5 votes vote down vote up
public BooheeRulerView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.df = new DecimalFormat("#.##");
    this.isActionUp = false;
    this.isCancel = false;
    this.f = true;
    this.scroller = new OverScroller(context);
    init(attrs);
}
 
Example 35
Project: boohee_v5.6   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < 9) {
        this.isPreGingerbread = true;
        this.scroller = new Scroller(context);
        return;
    }
    this.isPreGingerbread = false;
    this.overScroller = new OverScroller(context);
}
 
Example 36
Project: Programmers   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 37
Project: ClouldReader   File: GingerScroller.java   View source code 4 votes vote down vote up
public GingerScroller(Context context) {
    mScroller = new OverScroller(context);
}
 
Example 38
Project: AndroidOpen   File: DropDownLinearLayout.java   View source code 4 votes vote down vote up
protected void initView(Context context) {
    fScroller = new OverScroller(context);
    this.setOverScrollMode(OVER_SCROLL_ALWAYS);
}
 
Example 39
Project: GitHub   File: FreeFlowContainer.java   View source code 4 votes vote down vote up
@Override
protected void init(Context context) {

	viewpool = new ViewPool();
	frames = new LinkedHashMap<Object, FreeFlowItem>();

	ViewConfiguration configuration = ViewConfiguration.get(context);
	maxFlingVelocity = configuration.getScaledMaximumFlingVelocity();
	minFlingVelocity = configuration.getScaledMinimumFlingVelocity();
	overflingDistance = configuration.getScaledOverflingDistance();
	/*overscrollDistance = configuration.getScaledOverscrollDistance();*/

	touchSlop = configuration.getScaledTouchSlop();

	scroller = new OverScroller(context);

	setEdgeEffectsEnabled(true);

}
 
Example 40
Project: GitHub   File: ScrollerProxy.java   View source code 4 votes vote down vote up
public GingerScroller(Context context) {
	mScroller = new OverScroller(context);
}