Example usage for android.view ViewConfiguration getScaledMaximumFlingVelocity

List of usage examples for android.view ViewConfiguration getScaledMaximumFlingVelocity

Introduction

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

Prototype

public int getScaledMaximumFlingVelocity() 

Source Link

Usage

From source file:com.intuit.lego.widget.swipeLibrary.SwipeListViewTouchListener.java

/**
 * Constructor// w w  w .j  ava 2  s. c  om
 *
 * @param swipeListView  SwipeListView
 * @param swipeFrontView front view Identifier
 * @param swipeBackView  back view Identifier
 */
public SwipeListViewTouchListener(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) {
    this.swipeFrontView = swipeFrontView;
    this.swipeBackView = swipeBackView;
    ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext());
    slop = vc.getScaledTouchSlop();
    minFlingVelocity = vc.getScaledMinimumFlingVelocity() * 40; // kbhalla: Increasing the minimum limit for velocity to stablize the intended actions of swipe.
    maxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    configShortAnimationTime = swipeListView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    animationTime = configShortAnimationTime;
    this.swipeListView = swipeListView;
}

From source file:com.lab47billion.appchooser.HorizontalPicker.java

public HorizontalPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    _context = context;//  w ww  .  j  av  a  2  s  .c  o m

    // create the selector wheel paint
    TextPaint paint = new TextPaint();
    paint.setAntiAlias(true);
    mTextPaint = paint;

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HorizontalPicker, defStyle, 0);

    CharSequence[] values;
    int ellipsize = 3; // END default value
    int sideItems = mSideItems;

    try {
        mTextColor = a.getColorStateList(R.styleable.HorizontalPicker_android_textColor);
        if (mTextColor == null) {
            mTextColor = ColorStateList.valueOf(0xFF000000);
        }

        values = a.getTextArray(R.styleable.HorizontalPicker_values);
        ellipsize = a.getInt(R.styleable.HorizontalPicker_android_ellipsize, ellipsize);
        mDividerSize = a.getDimension(R.styleable.HorizontalPicker_dividerSize, mDividerSize);
        mNormalTextSize = a.getDimension(R.styleable.HorizontalPicker_normalTextSize, 20);
        mSelectedTextSize = a.getDimension(R.styleable.HorizontalPicker_selectedTextSize, -1);
        sideItems = a.getInt(R.styleable.HorizontalPicker_sideItems, sideItems);

        if (mNormalTextSize > -1) {
            setTextSize(mNormalTextSize);
        }
        if (mSelectedTextSize == -1) {
            mSelectedTextSize = mNormalTextSize;
        }

    } finally {
        a.recycle();
    }

    switch (ellipsize) {
    case 1:
        setEllipsize(TextUtils.TruncateAt.START);
        break;
    case 2:
        setEllipsize(TextUtils.TruncateAt.MIDDLE);
        break;
    case 3:
        setEllipsize(TextUtils.TruncateAt.END);
        break;
    case 4:
        setEllipsize(TextUtils.TruncateAt.MARQUEE);
        break;
    }

    Paint.FontMetricsInt fontMetricsInt = mTextPaint.getFontMetricsInt();
    mBoringMetrics = new BoringLayout.Metrics();
    mBoringMetrics.ascent = fontMetricsInt.ascent;
    mBoringMetrics.bottom = fontMetricsInt.bottom;
    mBoringMetrics.descent = fontMetricsInt.descent;
    mBoringMetrics.leading = fontMetricsInt.leading;
    mBoringMetrics.top = fontMetricsInt.top;
    mBoringMetrics.width = mItemWidth;

    setWillNotDraw(false);

    mFlingScrollerX = new OverScroller(context);
    mAdjustScrollerX = new OverScroller(context, new DecelerateInterpolator(2.5f));

    // initialize constants
    ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity()
            / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mOverscrollDistance = configuration.getScaledOverscrollDistance();

    mPreviousScrollerX = Integer.MIN_VALUE;

    setValues(values);
    setSideItems(sideItems);

    /*mTouchHelper = new PickerTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);*/

}

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

/**
 * This method init all necessary variables and Views that our Calendar is going to use.
 *///ww w .j  a va 2 s  .  co  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:com.danilov.supermanga.core.view.SlidingLayer.java

private void init() {
    setWillNotDraw(false);/*from   ww w  .j  a va 2 s  .c om*/
    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.bullmobi.message.ui.fragments.EasyNotificationFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Resources res = getResources();
    mConfigWidgetPinDuration = res.getInteger(R.integer.config_maxPinTime);
    mConfigWidgetSelectDelay = res.getInteger(R.integer.config_iconSelectDelayMillis);
    ViewConfiguration vc = ViewConfiguration.get(getActivity());
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    // Clock widget
    mClockWidget = new ClockWidget(this, this);

    // Media widget
    mMediaController = MediaController2.newInstance(getActivity());
    mMediaWidget = new MediaWidget(this, this);

    // Transitions
    if (Device.hasKitKatApi()) {
        mTransitionJit = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER)
                .addTransition(new Fade()).addTransition(new ChangeBounds());
        mTransitionSwitchScene = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER)
                .addTransition(new Fade(Fade.OUT).setDuration(200))
                .addTransition(new Fade(Fade.IN).setStartDelay(80))
                .addTransition(new ChangeBounds().setStartDelay(80));
    }/*from   w  w  w .j a v a2 s .  co m*/

    // Timeout
    mTimeout = isNotDemo() ? mActivityAcd.getTimeout() : new Timeout();
}

From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Resources res = getResources();
    mConfigWidgetPinDuration = res.getInteger(R.integer.config_maxPinTime);
    mConfigWidgetSelectDelay = res.getInteger(R.integer.config_iconSelectDelayMillis);
    ViewConfiguration vc = ViewConfiguration.get(getActivity());
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    // Clock widget
    mClockWidget = getConfig().isCustomWidgetEnabled() ? new HostWidget(this, this)
            : new ClockWidget(this, this);

    // Media widget
    mMediaController = MediaController2.newInstance(getActivity()).asyncWrap();
    mMediaWidget = new MediaWidget(this, this);

    // Transitions
    if (Device.hasKitKatApi()) {
        mTransitionJit = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER)
                .addTransition(new Fade()).addTransition(new ChangeBounds());
        mTransitionSwitchScene = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER)
                .addTransition(new Fade(Fade.OUT).setDuration(200))
                .addTransition(new Fade(Fade.IN).setStartDelay(80))
                .addTransition(new ChangeBounds().setStartDelay(80));
    }/*from w  ww.  ja v a  2  s.  c o m*/

    // Timeout
    mTimeout = isNotDemo() ? mActivityAcd.getTimeout() : new Timeout();
}

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

/**
 * Inits the custom view above.//  w w  w .j  a  v  a2 s.c  om
 */
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:jackson.com.slidingmenulib.MyViewDragHelper.java

/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.// www . j  a  va2 s  . com
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private MyViewDragHelper(Context context, ViewGroup forParent, ViewDragHelper.Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = new OverScroller(context, sInterpolator);
}

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

private void init() {
    setWillNotDraw(false);// ww  w .ja v a 2s .  c  om
    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:com.bitflake.counter.HorizontalPicker.java

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

    // create the selector wheel paint
    TextPaint paint = new TextPaint();
    paint.setAntiAlias(true);//w  ww. j a va2 s .  c o  m
    textPaint = paint;

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HorizontalPicker, defStyle, 0);

    CharSequence[] values;
    int ellipsize = 3; // END default value
    int sideItems = this.sideItems;

    try {
        textColor = a.getColorStateList(R.styleable.HorizontalPicker_android_textColor);
        if (textColor == null) {
            textColor = ColorStateList.valueOf(0xFF000000);
        }

        values = a.getTextArray(R.styleable.HorizontalPicker_values);
        ellipsize = a.getInt(R.styleable.HorizontalPicker_android_ellipsize, ellipsize);
        marqueeRepeatLimit = a.getInt(R.styleable.HorizontalPicker_android_marqueeRepeatLimit,
                marqueeRepeatLimit);
        dividerSize = a.getDimension(R.styleable.HorizontalPicker_dividerSize, dividerSize);
        sideItems = a.getInt(R.styleable.HorizontalPicker_sideItems, sideItems);

        float textSize = a.getDimension(R.styleable.HorizontalPicker_android_textSize, -1);
        if (textSize > -1) {
            setTextSize(textSize);
        }
    } finally {
        a.recycle();
    }

    switch (ellipsize) {
    case 1:
        setEllipsize(TextUtils.TruncateAt.START);
        break;
    case 2:
        setEllipsize(TextUtils.TruncateAt.MIDDLE);
        break;
    case 3:
        setEllipsize(TextUtils.TruncateAt.END);
        break;
    case 4:
        setEllipsize(TextUtils.TruncateAt.MARQUEE);
        break;
    }

    Paint.FontMetricsInt fontMetricsInt = textPaint.getFontMetricsInt();
    boringMetrics = new BoringLayout.Metrics();
    boringMetrics.ascent = fontMetricsInt.ascent;
    boringMetrics.bottom = fontMetricsInt.bottom;
    boringMetrics.descent = fontMetricsInt.descent;
    boringMetrics.leading = fontMetricsInt.leading;
    boringMetrics.top = fontMetricsInt.top;
    boringMetrics.width = itemWidth;

    setWillNotDraw(false);

    flingScrollerX = new OverScroller(context);
    adjustScrollerX = new OverScroller(context, new DecelerateInterpolator(2.5f));

    // initialize constants
    ViewConfiguration configuration = ViewConfiguration.get(context);
    touchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    maximumFlingVelocity = configuration.getScaledMaximumFlingVelocity()
            / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    overscrollDistance = configuration.getScaledOverscrollDistance();

    previousScrollerX = Integer.MIN_VALUE;

    setValues(values);
    setSideItems(sideItems);

    touchHelper = new PickerTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, touchHelper);

}