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:com.itude.mobile.mobbl.blueprint.app.view.listeners.SwipeDismissRecyclerViewTouchListener.java

public SwipeDismissRecyclerViewTouchListener(Builder builder) {
    ViewConfiguration vc = ViewConfiguration.get(builder.mRecyclerView.getContext());
    mSlop = vc.getScaledTouchSlop();//from  www  .  j  a v a 2 s.  c o m
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = builder.mRecyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    mRecyclerView = builder.mRecyclerView;
    mCallbacks = builder.mCallbacks;
    mIsVertical = builder.mIsVertical;
    mItemTouchCallback = builder.mItemTouchCallback;
}

From source file:br.com.halph.agendafeliz.util.SwipeableRecyclerViewTouchListener.java

/**
 * Constructs a new swipe touch listener for the given {@link android.support.v7.widget.RecyclerView}
 *
 * @param recyclerView The recycler view whose items should be dismissable by swiping.
 * @param listener     The listener for the swipe events.
 *//*from  www . j ava  2  s  .c o  m*/
public SwipeableRecyclerViewTouchListener(RecyclerView recyclerView, SwipeListener listener) {
    ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = recyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    mRecyclerView = recyclerView;
    mSwipeListener = listener;

    /**
     * This will ensure that this SwipeableRecyclerViewTouchListener is paused during list view scrolling.
     * If a scroll listener is already assigned, the caller should still pass scroll changes through
     * to this listener.
     */
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            setEnabled(newState != RecyclerView.SCROLL_STATE_DRAGGING);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        }
    });
}

From source file:org.creativecommons.thelist.swipedismiss.SwipeDismissRecyclerViewTouchListener.java

/**
 * Constructs a new swipe-to-dismiss touch listener for the given list view.
 *
 * @param recyclerView  The list view whose items should be dismissable.
 * @param callbacks The callback to trigger when the user has indicated that she would like to
 *                  dismiss one or more list items.
 *///from w ww. ja  v  a 2s  .com
public SwipeDismissRecyclerViewTouchListener(RecyclerView recyclerView, final SwipeRefreshLayout layout,
        DismissCallbacks callbacks) {
    ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = recyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    mRecyclerView = recyclerView;
    mRefreshLayout = layout;
    mCallbacks = callbacks;
}

From source file:com.ichi2.anki.AnkiDroidApp.java

/**
 * On application creation.//from  w  w  w.  ja  va  2 s. co  m
 */
@Override
public void onCreate() {
    super.onCreate();
    // Get preferences
    SharedPreferences preferences = getSharedPrefs(this);

    // Initialize crash reporting module
    ACRA.init(this);

    // Setup logging and crash reporting
    if (BuildConfig.DEBUG) {
        // Enable verbose error logging and do method tracing to put the Class name as log tag
        Timber.plant(new Timber.DebugTree());
        // Disable crash reporting
        setAcraReportingMode(FEEDBACK_REPORT_NEVER);
        preferences.edit().putString("reportErrorMode", FEEDBACK_REPORT_NEVER).commit();
        // Use a wider logcat filter incase crash reporting manually re-enabled
        String[] logcatArgs = { "-t", "300", "-v", "long", "ACRA:S" };
        ACRA.getConfig().setLogcatArguments(logcatArgs);
    } else {
        // Disable verbose error logging and use fixed log tag "AnkiDroid"
        Timber.plant(new ProductionCrashReportingTree());
        // Enable or disable crash reporting based on user setting
        setAcraReportingMode(preferences.getString("reportErrorMode", FEEDBACK_REPORT_ASK));
    }
    Timber.tag(TAG);

    sInstance = this;
    setLanguage(preferences.getString(Preferences.LANGUAGE, ""));

    // Configure WebView to allow file scheme pages to access cookies.
    CompatHelper.getCompat().enableCookiesForFileSchemePages();

    // Prepare Cookies to be synchronized between RAM and permanent storage.
    CompatHelper.getCompat().prepareWebViewCookies(this.getApplicationContext());

    // Set good default values for swipe detection
    final ViewConfiguration vc = ViewConfiguration.get(this);
    DEFAULT_SWIPE_MIN_DISTANCE = vc.getScaledPagingTouchSlop();
    DEFAULT_SWIPE_THRESHOLD_VELOCITY = vc.getScaledMinimumFlingVelocity();

    // Create the AnkiDroid directory if missing. Send exception report if inaccessible.
    if (CollectionHelper.hasStorageAccessPermission(this)) {
        try {
            String dir = CollectionHelper.getCurrentAnkiDroidDirectory(this);
            CollectionHelper.initializeAnkiDroidDirectory(dir);
        } catch (StorageAccessException e) {
            Timber.e(e, "Could not initialize AnkiDroid directory");
            String defaultDir = CollectionHelper.getDefaultAnkiDroidDirectory();
            if (isSdCardMounted() && CollectionHelper.getCurrentAnkiDroidDirectory(this).equals(defaultDir)) {
                // Don't send report if the user is using a custom directory as SD cards trip up here a lot
                sendExceptionReport(e, "AnkiDroidApp.onCreate");
            }
        }
    }
}

From source file:com.conduit.plastic.widget.NestedWebView.java

private void init() {
    this.mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);//from w  w w  .  j av a  2 s. co  m
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    this.mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    this.mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    this.mTouchSlop = configuration.getScaledTouchSlop();
    this.directionDetector = new DirectionDetector();
    this.density = getScale();
    setOverScrollMode(View.OVER_SCROLL_NEVER);
    this.settings = getSettings();
    //        addJavascriptInterface(new JSGetContentHeight(), "InjectedObject");
    Log.i(TAG, "max -- min Velocity = " + this.mMaximumVelocity + " -- " + this.mMinimumVelocity
            + " touchSlop = " + this.mTouchSlop);
}

From source file:com.haarman.listviewanimations.itemmanipulation.SwipeDismissListViewTouchListener.java

/**
 * Constructs a new swipe-to-dismiss touch listener for the given list view.
 *
 * @param listView//  w  ww. ja  va  2s . c o  m
 *            The list view whose items should be dismissable.
 * @param callback
 *            The callback to trigger when the user has indicated that she
 *            would like to dismiss one or more list items.
 */
public SwipeDismissListViewTouchListener(AbsListView listView, OnDismissCallback callback,
        SwipeOnScrollListener onScroll) {
    ViewConfiguration vc = ViewConfiguration.get(listView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
    mListView = listView;
    mCallback = callback;

    onScroll.setTouchListener(this);
    mListView.setOnScrollListener(onScroll);
}

From source file:com.example.administrator.myapplication.recycler_swipe.swpie.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 w w w  .  j  ava  2 s. c  om*/

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

    mScroller = new OverScroller(getContext());
}

From source file:io.nuclei.cyto.ui.view.BottomSheetView.java

private void init(Context context) {
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mMinFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    mTouchSlop = viewConfiguration.getScaledTouchSlop();

    setClickable(true);/*from  w w w.  j  a  va  2s. com*/

    mBackground = new View(context);
    mBackground.setBackgroundColor(mBackgroundColor = DEFAULT_BACKGROUND_COLOR);
    mBackground.setLayoutParams(
            new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mBackground.setVisibility(GONE);
    mBackground.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if ((mState & STATE_MOVING) != STATE_MOVING) {
                if ((mState & STATE_LOCKED) == STATE_LOCKED)
                    removeState(STATE_LOCKED);
                setState(STATE_CLOSED);
            }
        }
    });
    addView(mBackground);

    FrameLayout content = new FrameLayout(context);
    content.setLayoutParams(
            new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    content.setMinimumHeight(1);
    content.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    content.setClickable(true);
    addView(content);
    mContent = content;
    mOffsetHelper = new ViewOffsetHelper(mContent);

    onPrepare();
}

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

/**
 * Perform one-time initialization//from w ww.  ja  v a 2 s. c  o 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.xandy.calendar.month.SimpleDayPickerFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mContext = activity;//  w w w.  j a  va2s  .  c  o m
    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);
    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);
}