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:cn.ieclipse.af.view.ScrollLayout.java

public ScrollLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mCurScreen = mDefaultScreen;//  w ww.  j av  a2 s.  c  o m
    mScroller = new Scroller(context);
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    init(context, attrs);
}

From source file:com.commonsware.cwac.crossport.design.widget.HeaderBehavior.java

@Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev) {
    if (mTouchSlop < 0) {
        mTouchSlop = ViewConfiguration.get(parent.getContext()).getScaledTouchSlop();
    }/*from w w  w .j  a v  a2s.c  o  m*/

    final int action = ev.getAction();

    // Shortcut since we're being dragged
    if (action == MotionEvent.ACTION_MOVE && mIsBeingDragged) {
        return true;
    }

    switch (ev.getActionMasked()) {
    case MotionEvent.ACTION_DOWN: {
        mIsBeingDragged = false;
        final int x = (int) ev.getX();
        final int y = (int) ev.getY();
        if (canDragView(child) && parent.isPointInChildBounds(child, x, y)) {
            mLastMotionY = y;
            mActivePointerId = ev.getPointerId(0);
            ensureVelocityTracker();
        }
        break;
    }

    case MotionEvent.ACTION_MOVE: {
        final int activePointerId = mActivePointerId;
        if (activePointerId == INVALID_POINTER) {
            // If we don't have a valid id, the touch down wasn't on content.
            break;
        }
        final int pointerIndex = ev.findPointerIndex(activePointerId);
        if (pointerIndex == -1) {
            break;
        }

        final int y = (int) ev.getY(pointerIndex);
        final int yDiff = Math.abs(y - mLastMotionY);
        if (yDiff > mTouchSlop) {
            mIsBeingDragged = true;
            mLastMotionY = y;
        }
        break;
    }

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP: {
        mIsBeingDragged = false;
        mActivePointerId = INVALID_POINTER;
        if (mVelocityTracker != null) {
            mVelocityTracker.recycle();
            mVelocityTracker = null;
        }
        break;
    }
    }

    if (mVelocityTracker != null) {
        mVelocityTracker.addMovement(ev);
    }

    return mIsBeingDragged;
}

From source file:android.support.v7.widget.ForwardingListener.java

public ForwardingListener(View src) {
    mSrc = src;//  ww  w .j a  va  2  s  .c o  m
    mScaledTouchSlop = ViewConfiguration.get(src.getContext()).getScaledTouchSlop();
    mTapTimeout = ViewConfiguration.getTapTimeout();
    // Use a medium-press timeout. Halfway between tap and long-press.
    mLongPressTimeout = (mTapTimeout + ViewConfiguration.getLongPressTimeout()) / 2;
}

From source file:com.example.feedback.ActivityMain.java

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

    // Set action bar title to Main.
    actionBar = getActionBar();/*from www.  j a va 2  s.  c  om*/
    actionBar.setTitle(getResources().getString(R.string.title_main));

    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");

        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception e) {
    }
}

From source file:io.mattcarroll.hover.defaulthovermenu.view.ViewHoverMenu.java

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    mDragger = new InViewGroupDragger(this, ViewConfiguration.get(getContext()).getScaledTouchSlop());
    mDragger.setDebugMode(BuildConfig.DEBUG);
    mHoverMenuView = new HoverMenuView(getContext(), null, mDragger, loadSavedAnchorState());
    //        mHoverMenuView = new HoverMenuBuilder(getContext())
    //                .displayWithinView(this)
    //                .build();
    addView(mHoverMenuView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (null != mAdapter) {
        mHoverMenuView.setAdapter(mAdapter);
    }//  www  .ja  v  a2 s . c o  m
}

From source file:com.android.deskclock.VerticalViewPager.java

public VerticalViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    init();//from  w  w w . j  a  va  2 s.  co  m
}

From source file:com.android.hareime.accessibility.AccessibleKeyboardViewProxy.java

private void initInternal(InputMethodService inputMethod) {
    mInputMethod = inputMethod;
    mEdgeSlop = ViewConfiguration.get(inputMethod).getScaledEdgeSlop();
}

From source file:com.djoin.parking.parking.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setBooleanProperty("showTitle", true);
    setIntegerProperty("splashscreen", R.drawable.boot);
    super.onCreate(savedInstanceState);

    try {//from  w  w w.j a v a2 s.  c o  m
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    super.loadUrl(Config.getStartUrl(), 10000);
}

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

public SwipItemLayout(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.cylee.dragcontentviewpager.GestureLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    mViewGuestureHelper = ViewDragHelper.create(this, new ViewDragCallback());
    mViewGuestureHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM | ViewDragHelper.EDGE_TOP);
    final float density = getResources().getDisplayMetrics().density;
    final float minVel = MIN_FLING_VELOCITY * density;
    mInitChildHeight = (int) (density * mInitChildHeight);
    mMinFlippingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity();
    mViewGuestureHelper.setMinVelocity(minVel);
    mTrackingEdge = ViewDragHelper.EDGE_BOTTOM;
    mChildShowHeight = mInitChildHeight;
}