Example usage for android.view ViewConfiguration get

List of usage examples for android.view ViewConfiguration get

Introduction

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

Prototype

public static ViewConfiguration get(Context context) 

Source Link

Document

Returns a configuration for the specified context.

Usage

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

public ConversationListSwipeHelper(final RecyclerView recyclerView) {
    mRecyclerView = recyclerView;// www  .j a  v  a2s .  co 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.baoyz.dribble.widget.SwipeHoverLayout.java

private void init() {

    ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
    mScrollDistance = DimenUtil.dp2px(getContext(), 60);
    mCanScrollDistance = viewConfiguration.getScaledOverscrollDistance();
    mFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    mTouchSlop = viewConfiguration.getScaledTouchSlop();

    mGestureDetector = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {

        @Override//from  w w w.  j  a v  a2 s .  c om
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            mFlingShow = Math.abs(velocityX) >= mFlingVelocity;
            return false;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            int distance = Math.abs((int) (e2.getX() - mDownX));
            mDistanceShow = distance >= 10;
            dispatchSwipe(distance);
            return false;
        }

        @Override
        public boolean onDown(MotionEvent e) {
            mDownX = (int) e.getX();
            mFlingShow = false;
            mDistanceShow = false;
            return true;
        }
    });
}

From source file:com.example.tt.pullrefresh.widget.CurveLayout.java

public CurveLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    MIN_FLING_VELOCITY = viewConfiguration.getScaledMinimumFlingVelocity();
}

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

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

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

    mToolbarView = findViewById(R.id.toolbar);
    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);/*from  w w w  .j ava2  s.  c  o m*/
    // Padding for ViewPager must be set outside the ViewPager itself
    // because with padding, EdgeEffect of ViewPager become strange.
    final int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
    findViewById(R.id.pager_wrapper).setPadding(0, getActionBarSize() + tabHeight, 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);
}

From source file:com.krayzk9s.imgurholo.activities.ImgurHoloActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    apiCall = new ApiCall();
    apiCall.setSettings(settings);//w  w w .  ja v a  2 s .  c  o  m
    theme = settings.getString("theme", MainActivity.HOLO_LIGHT);
    if (theme.equals(MainActivity.HOLO_LIGHT))
        setTheme(R.style.AppTheme);
    else
        setTheme(R.style.AppThemeDark);
    super.onCreate(savedInstanceState);
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (NoSuchFieldException e) {
        // Ignore
        Log.e("Error!", e.toString());
    } catch (IllegalAccessException e) {
        // Ignore
        Log.e("Error!", e.toString());
    }

    if (Integer
            .parseInt(settings.getString(getString(R.string.icon_size), getString(R.string.onetwenty))) < 120) { //getting rid of 90 because it may crash the app for large screens
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(getString(R.string.icon_size), getString(R.string.onetwenty));
        editor.commit();
    }
    setContentView(R.layout.activity_other);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
}

From source file:com.baoyz.bigbang.BigBangLayout.java

private void readAttribute(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.BigBangLayout);
        mItemSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_itemSpace,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_item_space));
        mLineSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_lineSpace,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_line_space));
        typedArray.recycle();/* ww  w.  j  av a2 s  .co  m*/
        mActionBarBottomHeight = mLineSpace;
        mActionBarTopHeight = getResources().getDimensionPixelSize(R.dimen.big_bang_action_bar_height);
    }

    // TODO 
    mActionBar = new BigBangActionBar(getContext());
    mActionBar.setVisibility(View.GONE);
    mActionBar.setActionListener(this);

    addView(mActionBar, 0);

    setClipChildren(false);

    mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}

From source file:com.cocarechina.pullrefreshview.layout.FlingLayout.java

public void init(Context context) {
    version = android.os.Build.VERSION.SDK_INT;
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mScroller = new Scroller(context, new AccelerateDecelerateInterpolator());
    mParentHelper = new NestedScrollingParentHelper(this);
    mChildHelper = new NestedScrollingChildHelper(this);
}

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 w  w w .  j a  v  a2 s . c o  m*/
        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: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.
 *//*from  w  w w .ja  va  2s . c om*/
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:com.baoyz.bigbang.core.BigBangLayout.java

private void readAttribute(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.BigBangLayout);
        mItemSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_itemSpace,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_item_space));
        mLineSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_lineSpace,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_line_space));
        mItemTextSize = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_textSize,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_text_size));
        typedArray.recycle();/* w w w .j  a  v  a 2s  .  com*/
        mActionBarBottomHeight = mLineSpace;
        mActionBarTopHeight = getResources().getDimensionPixelSize(R.dimen.big_bang_action_bar_height);
    }

    // TODO 
    mActionBar = new BigBangActionBar(getContext());
    mActionBar.setVisibility(View.GONE);
    mActionBar.setActionListener(this);

    addView(mActionBar, 0);

    setClipChildren(false);

    mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

    if (isInEditMode()) {
        // ?
        addTextItem("BigBang");
        addTextItem("");
        addTextItem("");
        addTextItem("?");
        addTextItem("");
        addTextItem("");
        addTextItem("");
        addTextItem("?");
    }
}