Example usage for android.view ViewConfiguration getScaledTouchSlop

List of usage examples for android.view ViewConfiguration getScaledTouchSlop

Introduction

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

Prototype

public int getScaledTouchSlop() 

Source Link

Usage

From source file:com.github.ksoichiro.android.observablescrollview.sampler.ViewPagerTab2Activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewpagertab2);

    mToolbarView = findViewById(R.id.toolbar_translationY);
    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);//  w w w  .ja  v a2s  .  c o  m

    toolbar = findViewById(R.id.toolbar);
    view_toolbar = findViewById(R.id.view_toolbar);
    ViewHelper.setAlpha(toolbar, 0);
    // Padding for ViewPager must be set outside the ViewPager itself
    // because with padding, EdgeEffect of ViewPager become strange.
    tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
    startAmi = tabHeight * 2 - getTranslationY();
    findViewById(R.id.pager_wrapper).setPadding(0, getTranslationY() + tabHeight * 2, 0, 0);

    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);

    ViewConfiguration vc = ViewConfiguration.get(this);
    mSlop = vc.getScaledTouchSlop();
    mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);

    search = findViewById(R.id.search);
}

From source file:cn.meiqu.baseproject.view.superrecyclerview.swipe.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.
 *//*  w  w w  .  j av a 2 s.c  o  m*/
public SwipeDismissRecyclerViewTouchListener(RecyclerView recyclerView, 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;
    mCallbacks = callbacks;
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPParentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_parent, container, false);

    final MainActivity parentActivity = MainActivity.instance;
    mPagerAdapter = new NavigationAdapter(getChildFragmentManager());
    mPager = (ViewPager) view.findViewById(R.id.pager);
    ViewPager.SimpleOnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from  w  w  w . j  av a 2s . c om*/
        public void onPageSelected(int position) {
            Log.d(RHCareerFairLayout.RH_CFL, "Selected page:" + position);

            if (getCurrentFragment() != null) {
                // If position is layout fragment, and scale is at base, show the toolbar. Otherwise, hide it.
                if (position == 0) {
                    if (((VPLayoutContainerFragment) getCurrentFragment()).getLayoutView()
                            .getScaleFactor() == 1.0) {
                        showToolbar();
                    } else {
                        hideToolbar();
                    }
                }

                // Push to the backStack.
                parentActivity.pushToBackStack(mLastPage);
            }

            // Send tracking info
            RHCareerFairLayoutApplication application = (RHCareerFairLayoutApplication) parentActivity
                    .getApplication();
            Tracker tracker = application.getDefaultTracker();
            Log.i(RHCareerFairLayout.RH_CFL,
                    "Setting screen name: " + RHCareerFairLayout.tabs.get(position).getTitle());
            tracker.setScreenName(RHCareerFairLayout.tabs.get(position).getTitle());
            tracker.send(new HitBuilders.ScreenViewBuilder().build());

            // Set trailing marker.
            mLastPage = position;
        }
    };

    // Configure adapter.
    mPager.addOnPageChangeListener(pageChangeListener);
    mPager.setOffscreenPageLimit(2);
    mPager.setAdapter(mPagerAdapter);

    // Trigger first change, so that backStack and tracker code fires the first time.
    pageChangeListener.onPageSelected(0);

    // Create sliding tab layout for viewpager
    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.primaryLight));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);

    // Set touch boundary slopes to differentiate between vertical and horizontal swipes.
    // Set scrolling listeners.
    ViewConfiguration vc = ViewConfiguration.get(parentActivity);
    mSlop = vc.getScaledTouchSlop();
    mInterceptionLayout = (TouchInterceptionFrameLayout) view.findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);

    return view;
}

From source file:com.github.shareme.gwsswwipetodismiss.library.SwipeDismissListViewTouchListener.java

/**
 * Constructs a new swipe-to-dismiss touch listener for the given list view.
 *
 * @param listView 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.
 *///  w w w. j a  v a 2s  .c o m
public SwipeDismissListViewTouchListener(AbsListView listView, OnDismissCallback callback) {
    ViewConfiguration vc = ViewConfiguration.get(listView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
    mListView = listView;
    mCallback = callback;
}

From source file:org.floens.chan.controller.ui.NavigationControllerContainerLayout.java

private void init() {
    ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
    slopPixels = viewConfiguration.getScaledTouchSlop();
    minimalMovedPixels = dp(3);//from   ww  w  .jav a 2  s.  c  o  m
    flingPixels = viewConfiguration.getScaledMinimumFlingVelocity();
    maxFlingPixels = viewConfiguration.getScaledMaximumFlingVelocity();

    scroller = new Scroller(getContext());

    shadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
}

From source file:com.app.gongza.libs.view.scrollablelayout.ScrollableLayout.java

private void init(Context context) {
    mHelper = new ScrollableHelper();
    mScroller = new Scroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:com.example.client.activity.imported.FlexibleSpaceWithImageWithViewPagerTab2Activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flexiblespacewithimagewithviewpagertab2);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    ViewCompat.setElevation(findViewById(R.id.header), getResources().getDimension(R.dimen.toolbar_elevation));
    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);/*  w ww .j a v  a2  s . c  o  m*/
    mImageView = findViewById(R.id.image);
    mOverlayView = findViewById(R.id.overlay);
    // Padding for ViewPager must be set outside the ViewPager itself
    // because with padding, EdgeEffect of ViewPager become strange.
    mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mTabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
    findViewById(R.id.pager_wrapper).setPadding(0, mFlexibleSpaceHeight, 0, 0);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);

    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);
    ((FrameLayout.LayoutParams) slidingTabLayout.getLayoutParams()).topMargin = mFlexibleSpaceHeight
            - mTabHeight;

    ViewConfiguration vc = ViewConfiguration.get(this);
    mSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
    mScroller = new OverScroller(getApplicationContext());
    ScrollUtils.addOnGlobalLayoutListener(mInterceptionLayout, new Runnable() {
        @Override
        public void run() {
            // Extra space is required to move mInterceptionLayout when it's scrolled.
            // It's better to adjust its height when it's laid out
            // than to adjust the height when scroll events (onMoveMotionEvent) occur
            // because it causes lagging.
            // See #87: https://github.com/ksoichiro/Android-ObservableScrollView/issues/87
            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
            lp.height = getScreenHeight() + mFlexibleSpaceHeight;
            mInterceptionLayout.requestLayout();

            updateFlexibleSpace();
        }
    });
}

From source file:com.marshalchen.common.uimodule.superlistview.SwipeDismissListViewTouchListener.java

/**
 * Constructs a new swipe-to-dismiss touch listener for the given list view.
 *
 * @param listView  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.
 *///w  w w .j  av a 2  s .co  m
public SwipeDismissListViewTouchListener(ListView listView, DismissCallbacks callbacks) {
    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;
    mCallbacks = callbacks;
}

From source file:com.umeitime.common.views.ScrollableLayout.java

private void init(Context context, AttributeSet attrs) {
    float scale = context.getResources().getDisplayMetrics().density;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    // ???//  w w w . j a  v  a  2 s.c om
    int statusBarHeight = getResources().getDimensionPixelSize(resourceId);
    TypedArray actionbarSizeTypedArray = context
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    float actionbarHeight = actionbarSizeTypedArray.getDimension(0, 0);
    headerDistance = actionbarHeight + statusBarHeight;
    mHelper = new ScrollableHelper();
    mScroller = new Scroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:es.ugr.swad.swadroid.gui.SwipeListViewTouchListener.java

/**
 * Constructs a new swipe-to-action touch listener for the given list view.
 *
 * @param listView 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.
 *///from   w  w  w.j  a va2  s. c  o  m
public SwipeListViewTouchListener(ListView listView, OnSwipeCallback callback) {
    ViewConfiguration vc = ViewConfiguration.get(listView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = listView.getContext().getResources().getInteger(android.R.integer.config_shortAnimTime);
    mListView = listView;
    mCallback = callback;
}