Example usage for android.view ViewConfiguration getScaledOverflingDistance

List of usage examples for android.view ViewConfiguration getScaledOverflingDistance

Introduction

In this page you can find the example usage for android.view ViewConfiguration getScaledOverflingDistance.

Prototype

public int getScaledOverflingDistance() 

Source Link

Usage

From source file:com.baoyz.dribble.widget.SuperRecyclerView.java

public SuperRecyclerView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    super.setOnScrollListener(new OnScrollListener() {
        @Override/*from   www  .  j ava 2  s  .  com*/
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
                if (layoutManager.findLastVisibleItemPosition() == (layoutManager.getItemCount() - 1)) {
                    setLoadMore(true);
                }
            }

            if (mScrollListener != null)
                mScrollListener.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (mScrollListener != null)
                mScrollListener.onScrolled(recyclerView, dx, dy);
        }
    });

    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mTouchDistance = viewConfiguration.getScaledOverflingDistance();
    mFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();

    mGesutureDetector = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (mOnQuickScrollListener != null && Math.abs(velocityY) > mFlingVelocity) {
                if (velocityY > 0)
                    mOnQuickScrollListener.onQuickDown();
                else
                    mOnQuickScrollListener.onQuickUp();
            }
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    });
}

From source file:com.iangclifton.auid.horizontaliconview.HorizontalIconView.java

/**
 * Perform one-time initialization/*  w w w  . ja v a2s. co  m*/
 * 
 * @param context Context to load Resources and ViewConfiguration data
 */
private void init(Context context) {
    final Resources res = context.getResources();
    mIconSize = res.getDimensionPixelSize(R.dimen.icon_size);
    mIconSpacing = res.getDimensionPixelSize(R.dimen.icon_spacing);

    // Cache ViewConfiguration values
    final ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();
    mMinimumVelocity = config.getScaledMinimumFlingVelocity();
    mMaximumVelocity = config.getScaledMaximumFlingVelocity();
    mOverflingDistance = config.getScaledOverflingDistance();
    mOverscrollDistance = config.getScaledOverscrollDistance();

    // Verify this View will be drawn
    setWillNotDraw(false);

    // Other setup
    mEdgeEffectLeft = new EdgeEffectCompat(context);
    mEdgeEffectRight = new EdgeEffectCompat(context);
    mScroller = new OverScroller(context);
    setFocusable(true);
}

From source file:com.comcast.freeflow.core.FreeFlowContainer.java

@Override
protected void init(Context context) {
    // usedViews = new HashMap<Object, FreeFlowItem>();
    // usedHeaderViews = new HashMap<Object, FreeFlowItem>();

    setWillNotDraw(false);/*from   w w w.  jav  a  2  s. co m*/

    viewpool = new ViewPool();
    frames = new HashMap<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);
    mLeftEdge = new EdgeEffect(context);
    mRightEdge = new EdgeEffect(context);
    mTopEdge = new EdgeEffect(context);
    mBottomEdge = new EdgeEffect(context);

}

From source file:freeflow.core.FreeFlowContainer.java

@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);/*from   w  ww .  j a  v a  2  s .  com*/

}

From source file:com.marshalchen.common.uimodule.freeflow.core.FreeFlowContainer.java

@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);//from   www  .j a va  2  s  .c  o  m

}

From source file:com.xuejian.client.lxp.common.widget.freeflow.core.FreeFlowContainer.java

@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();
    overflingDistance = 0;/* ww w .j a v a  2 s  . c o  m*/
    /*overscrollDistance = configuration.getScaledOverscrollDistance();*/

    touchSlop = configuration.getScaledTouchSlop();

    scroller = new OverScroller(context);

    setEdgeEffectsEnabled(true);

}

From source file:com.hippo.widget.BothScrollView.java

private void initBothScrollView(Context context) {
    mScroller = new SmoothOverScroller(context);
    setFocusable(true);//from www  .  jav  a  2 s.c  om
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setWillNotDraw(false);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mOverscrollDistance = configuration.getScaledOverscrollDistance();
    mOverflingDistance = configuration.getScaledOverflingDistance();
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

public DayView(Context context, CalendarController controller, ViewSwitcher viewSwitcher,
        EventLoader eventLoader, int numDays) {
    super(context);
    mContext = context;//from w  w  w. j  a  v a 2  s.c o m

    mResources = context.getResources();
    mNumDays = numDays;

    DATE_HEADER_FONT_SIZE = (int) mResources.getDimension(R.dimen.date_header_text_size);
    DAY_HEADER_FONT_SIZE = (int) mResources.getDimension(R.dimen.day_label_text_size);
    DAY_HEADER_HEIGHT = (int) mResources.getDimension(R.dimen.day_header_height);
    DAY_HEADER_BOTTOM_MARGIN = (int) mResources.getDimension(R.dimen.day_header_bottom_margin);
    HOURS_TEXT_SIZE = (int) mResources.getDimension(R.dimen.hours_text_size);
    AMPM_TEXT_SIZE = (int) mResources.getDimension(R.dimen.ampm_text_size);
    MIN_HOURS_WIDTH = (int) mResources.getDimension(R.dimen.min_hours_width);
    HOURS_LEFT_MARGIN = (int) mResources.getDimension(R.dimen.hours_left_margin);
    HOURS_RIGHT_MARGIN = (int) mResources.getDimension(R.dimen.hours_right_margin);
    int eventTextSizeId;
    if (mNumDays == 1) {
        eventTextSizeId = R.dimen.day_view_event_text_size;
    } else {
        eventTextSizeId = R.dimen.week_view_event_text_size;
    }
    EVENT_TEXT_FONT_SIZE = (int) mResources.getDimension(eventTextSizeId);
    MIN_EVENT_HEIGHT = mResources.getDimension(R.dimen.event_min_height);
    EVENT_TEXT_TOP_MARGIN = (int) mResources.getDimension(R.dimen.event_text_vertical_margin);
    EVENT_TEXT_BOTTOM_MARGIN = EVENT_TEXT_TOP_MARGIN;

    EVENT_TEXT_LEFT_MARGIN = (int) mResources.getDimension(R.dimen.event_text_horizontal_margin);
    EVENT_TEXT_RIGHT_MARGIN = EVENT_TEXT_LEFT_MARGIN;

    if (mScale == 0) {

        mScale = mResources.getDisplayMetrics().density;
        if (mScale != 1) {

            GRID_LINE_LEFT_MARGIN *= mScale;
            HOURS_TOP_MARGIN *= mScale;
            MIN_CELL_WIDTH_FOR_TEXT *= mScale;

            CURRENT_TIME_LINE_SIDE_BUFFER *= mScale;
            CURRENT_TIME_LINE_TOP_OFFSET *= mScale;

            MIN_Y_SPAN *= mScale;
            MAX_CELL_HEIGHT *= mScale;
            DEFAULT_CELL_HEIGHT *= mScale;
            DAY_HEADER_RIGHT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_LEFT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_RIGHT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_BOTTOM_MARGIN *= mScale;
            EVENT_RECT_TOP_MARGIN *= mScale;
            EVENT_RECT_BOTTOM_MARGIN *= mScale;
            EVENT_RECT_LEFT_MARGIN *= mScale;
            EVENT_RECT_RIGHT_MARGIN *= mScale;
            EVENT_RECT_STROKE_WIDTH *= mScale;
        }
    }
    HOURS_MARGIN = HOURS_LEFT_MARGIN + HOURS_RIGHT_MARGIN;

    mCurrentTimeLine = mResources.getDrawable(R.drawable.timeline_indicator_holo_light);
    mCurrentTimeAnimateLine = mResources.getDrawable(R.drawable.timeline_indicator_activated_holo_light);
    mTodayHeaderDrawable = mResources.getDrawable(R.drawable.today_blue_week_holo_light);
    mAcceptedOrTentativeEventBoxDrawable = mResources.getDrawable(R.drawable.panel_month_event_holo_light);

    mEventLoader = eventLoader;
    mEventGeometry = new EventGeometry();
    mEventGeometry.setMinEventHeight(MIN_EVENT_HEIGHT);
    mEventGeometry.setHourGap(HOUR_GAP);
    mEventGeometry.setCellMargin(DAY_GAP);
    mController = controller;
    mViewSwitcher = viewSwitcher;
    mGestureDetector = new GestureDetector(context, new CalendarGestureListener());
    mScaleGestureDetector = new ScaleGestureDetector(getContext(), this);
    if (mCellHeight == 0) {
        mCellHeight = DEFAULT_CELL_HEIGHT;
    }
    mScroller = new OverScroller(context);
    mHScrollInterpolator = new ScrollInterpolator();
    mEdgeEffectTop = new EdgeEffectCompat(context);
    mEdgeEffectBottom = new EdgeEffectCompat(context);
    ViewConfiguration vc = ViewConfiguration.get(context);
    mScaledPagingTouchSlop = vc.getScaledPagingTouchSlop();
    mOnDownDelay = ViewConfiguration.getTapTimeout();
    OVERFLING_DISTANCE = vc.getScaledOverflingDistance();

    init(context);
}

From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java

public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = new OverScrollerSGV(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);/*from w  w  w.java  2  s .c  o m*/
    setClipToPadding(false);

    SgvAnimationHelper.initialize(context);

    mDragState = ReorderUtils.DRAG_STATE_NONE;
    mIsDragReorderingEnabled = true;
    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mOverscrollDistance = configuration.getScaledOverflingDistance();
    // Disable splitting event. Only one of the children can handle motion event.
    setMotionEventSplittingEnabled(false);
}

From source file:com.bulletnoid.android.widget.StaggeredGridView.StaggeredGridView2.java

public StaggeredGridView2(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.StgStaggeredGridView);
        mColCount = a.getInteger(R.styleable.StgStaggeredGridView_stgNumColumns, 2);
        mDrawSelectorOnTop = a.getBoolean(R.styleable.StgStaggeredGridView_stgDrawSelectorOnTop, false);
    } else {/*from  w w w  .  ja  v a 2s . co  m*/
        mColCount = 2;
        mDrawSelectorOnTop = false;
    }

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    //mScroller=ScrollerCompat.from(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);
    setClipToPadding(false);
    this.setFocusableInTouchMode(false);

    if (mSelector == null) {
        useDefaultSelector();
    }

    mMinimumVelocity = vc.getScaledMinimumFlingVelocity();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mOverscrollDistance = vc.getScaledOverscrollDistance(); //TODO
    mOverflingDistance = vc.getScaledOverflingDistance();
}