Example usage for android.view ViewConfiguration getScaledMinimumFlingVelocity

List of usage examples for android.view ViewConfiguration getScaledMinimumFlingVelocity

Introduction

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

Prototype

public int getScaledMinimumFlingVelocity() 

Source Link

Usage

From source file:cn.bingoogolapple.refreshlayout.BGAStickyNavLayout.java

private void init(Context context) {
    setOrientation(VERTICAL);/*from   ww  w. j  a  v a 2s.  co m*/

    mOverScroller = new OverScroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
}

From source file:com.android.calendar.month.SimpleDayPickerFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mContext = activity;//from ww  w  . j a  va  2s .c  om
    String tz = Time.getCurrentTimezone();
    ViewConfiguration viewConfig = ViewConfiguration.get(activity);
    mMinimumFlingVelocity = viewConfig.getScaledMinimumFlingVelocity();

    // Ensure we're in the correct time zone
    mSelectedDay.switchTimezone(tz);
    mSelectedDay.normalize(true);
    mFirstDayOfMonth.timezone = tz;
    mFirstDayOfMonth.normalize(true);
    mFirstVisibleDay.timezone = tz;
    mFirstVisibleDay.normalize(true);
    mTempTime.timezone = tz;

    Resources res = activity.getResources();
    mSaturdayColor = res.getColor(R.color.month_saturday);
    mSundayColor = res.getColor(R.color.month_sunday);
    mFridayColor = res.getColor(R.color.month_friday);
    mDayNameColor = res.getColor(R.color.month_day_names_color);

    // Adjust sizes for screen density
    if (mScale == 0) {
        mScale = activity.getResources().getDisplayMetrics().density;
        if (mScale != 1) {
            WEEK_MIN_VISIBLE_HEIGHT *= mScale;
            BOTTOM_BUFFER *= mScale;
            LIST_TOP_OFFSET *= mScale;
        }
    }
    setUpAdapter();
    setListAdapter(mAdapter);
}

From source file:com.shizhefei.view.largeimage.LargeImageView.java

public LargeImageView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mScroller = ScrollerCompat.create(getContext(), null);
    scaleHelper = new ScaleHelper();
    setFocusable(true);//from  w  ww  . j  av a2 s.  c om
    setWillNotDraw(false);
    gestureDetector = new GestureDetector(context, simpleOnGestureListener);
    scaleGestureDetector = new ScaleGestureDetector(context, onScaleGestureListener);

    imageBlockLoader = new BlockImageLoader(context);
    imageBlockLoader.setOnImageLoadListener(this);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:com.android.messaging.ui.conversationlist.ConversationListSwipeHelper.java

public ConversationListSwipeHelper(final RecyclerView recyclerView) {
    mRecyclerView = recyclerView;//  w w w .  j  a v a  2  s. c o m

    final Context context = mRecyclerView.getContext();
    final Resources res = context.getResources();
    mDefaultRestoreAnimationDuration = res.getInteger(R.integer.swipe_duration_ms);
    mDefaultDismissAnimationDuration = res.getInteger(R.integer.swipe_duration_ms);
    mMaxTranslationAnimationDuration = res.getInteger(R.integer.swipe_duration_ms);

    final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mTouchSlop = viewConfiguration.getScaledPagingTouchSlop();
    mMaximumFlingVelocity = Math.min(viewConfiguration.getScaledMaximumFlingVelocity(),
            res.getInteger(R.integer.swipe_max_fling_velocity_px_per_s));
    mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
}

From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java

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

    ViewConfiguration mViewConfig = ViewConfiguration.get(getContext());
    mScaledTouchSlop = mViewConfig.getScaledTouchSlop();
    mScroller = new OverScroller(getContext());
    mScaledMinimumFlingVelocity = mViewConfig.getScaledMinimumFlingVelocity();
    mScaledMaximumFlingVelocity = mViewConfig.getScaledMaximumFlingVelocity();
}

From source file:com.antew.redditinpictures.library.widget.SwipeListView.java

private void initialize(AttributeSet attrs) {

    // If we are in an IDE Preview, don't initialize.
    if (isInEditMode()) {
        return;//www  .jav  a 2  s .  c  o m
    }

    if (attrs != null) {
        TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView);
        mFrontViewId = styled.getResourceId(R.styleable.SwipeListView_frontViewId, 0);
        mBackViewId = styled.getResourceId(R.styleable.SwipeListView_backViewId, 0);
        mCloseAllWhenScrolling = styled.getBoolean(R.styleable.SwipeListView_closeAllWhenScrolling, true);
        mOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_openOnLongPress, true);
        setSwipeDirection(styled.getInt(R.styleable.SwipeListView_swipeDirection, SWIPE_DIRECTION_BOTH));
    }

    if (mFrontViewId == 0 || mBackViewId == 0) {
        throw new RuntimeException("You must specify a Front View and Back View");
    }

    ViewConfiguration viewConfig = ViewConfiguration.get(getContext());
    mTouchSlop = viewConfig.getScaledTouchSlop();
    mMinFlingVelocity = viewConfig.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = viewConfig.getScaledMaximumFlingVelocity();
    mAnimationTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

    super.setOnScrollListener(mInternalOnScrollListener);
    super.setOnItemLongClickListener(mInternalOnItemLongClickListener);
}

From source file:org.telegram.ui.Components.Switch.java

public Switch(Context context) {
    super(context);

    mThumbDrawable = context.getResources().getDrawable(R.drawable.switch_thumb);
    if (mThumbDrawable != null) {
        mThumbDrawable.setCallback(this);
        mThumbDrawable.setTintList(AppCompatResources.getColorStateList(context, R.color.tint_switch_thumb));
    }/*  w ww  .jav a2  s.c o m*/
    mTrackDrawable = context.getResources().getDrawable(R.drawable.switch_track);
    if (mTrackDrawable != null) {
        mTrackDrawable.setCallback(this);
        mTrackDrawable.setTintList(AppCompatResources.getColorStateList(context, R.color.tint_switch_track));
    }

    if (AndroidUtilities.density < 1) {
        mSwitchMinWidth = AndroidUtilities.dp(30);
    } else {
        mSwitchMinWidth = 0;
    }

    mSwitchPadding = 0;
    mSplitTrack = false;

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

    refreshDrawableState();
    setChecked(isChecked());
}

From source file:com.douban.rexxar.view.NestedWebView.java

public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);//from  w ww.  ja  v a 2  s  . c  om
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    WebSettings webSettings = getSettings();
    webSettings.setJavaScriptEnabled(true);
    // 
    addJavascriptInterface(new NestScrollHelper(), "Android_NestScrollHelper");
    // ?
    setOverScrollMode(OVER_SCROLL_NEVER);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mScroller = new OverScroller(getContext());
}

From source file:ch.tutti.android.bottomsheet.ResolverDrawerLayout.java

public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout, defStyleAttr,
            0);/*from  w  w  w  .  j  av a2 s.c  o  m*/
    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();

    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();
}

From source file:com.fortysevendeg.android.swipelistview.SwipeListViewTouchListener.java

/**
 * Constructor/*from   ww  w  .j a va  2s  .  co m*/
 * @param swipeListView SwipeListView
 * @param swipeFrontView front view Identifier
 * @param swipeBackView back view Identifier
 */
public SwipeListViewTouchListener(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) {
    mSwipeFrontView = swipeFrontView;
    mSwipeBackView = swipeBackView;
    ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = swipeListView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    this.mSwipeListView = swipeListView;
}