Android ViewConfiguration - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ViewConfiguration class.

This code example shows how to use the following methods:getResources, get
    public int getMaxActionButtons() { 
        return mContext.getResources().getInteger(R.integer.max_action_buttons);
    } 
 
    public boolean showsOverflowMenuButton() { 
        return !ViewConfiguration.get(mContext).hasPermanentMenuKey() ||
                ((mContext.getResources().getConfiguration().uiMode &
                        Configuration.UI_MODE_TYPE_TELEVISION) ==
                        Configuration.UI_MODE_TYPE_TELEVISION);
    } 
 
    public int getEmbeddedMenuWidthLimit() { 
        return mContext.getResources().getDisplayMetrics().widthPixels / 2;
    } 
 
    public boolean hasEmbeddedTabs() { 
        final int targetSdk = mContext.getApplicationInfo().targetSdkVersion;
        if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) {
            return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs);
        } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaledPagingTouchSlop
	/** 
	 * Calls {@link ViewConfiguration#getScaledPagingTouchSlop()}. 
	 */ 
	public static int getScaledPagingTouchSlop(ViewConfiguration config)
	{ 
		return config.getScaledPagingTouchSlop();
	} 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaledTouchSlop
    } 
     
 
    private int getScrollThreshold() 
    { 
        return view_config.getScaledTouchSlop();
    } 
 
    private native void touchHandler(boolean down, int x, int y);
    public native static boolean buttonHandler(int keycode, boolean state);
 
    public native void surfaceCreated(SurfaceHolder holder);
    public native void surfaceDestroyed(SurfaceHolder holder);
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
    { 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaledTouchSlop
    } 
     
 
    private int getScrollThreshold() 
    { 
        return view_config.getScaledTouchSlop();
    } 
 
    private native void touchHandler(boolean down, int x, int y);
    public native static boolean buttonHandler(int keycode, boolean state);
 
    public native void surfaceCreated(SurfaceHolder holder);
    public native void surfaceDestroyed(SurfaceHolder holder);
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
    { 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaledMinimumFlingVelocity, getScaledTouchSlop
import android.widget.Toast; 
 
public class SelectFilterActivity extends Activity{
	final ViewConfiguration vc = ViewConfiguration.get(this);
	final int SWIPE_MIN_DISTANCE = vc.getTouchSlop();
	final int SWIPE_MAX_OFF_PATH = vc.getScaledTouchSlop();
	final int SWIPE_THRESHOLD_VELOCITY = vc.getScaledMinimumFlingVelocity();
	private GestureDetector gestureDetector;
	View.OnTouchListener gestureListener;
	/** 
	 * @see android.app.Activity#onCreate(Bundle) 
	 */ 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// TODO Put your code here 
	      // Gesture detection 
        gestureDetector = new GestureDetector(new MyGestureDetector());
        gestureListener = new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaledMinimumFlingVelocity, getScaledTouchSlop
    private final int swipeMinDistance;
    private final int swipeThresholdVelocity;
 
    public HotelGestureDetector(Context context) {
        vc = ViewConfiguration.get(context);
        swipeMinDistance = vc.getScaledTouchSlop();
        swipeThresholdVelocity = vc.getScaledMinimumFlingVelocity();
    } 
 
    @Override 
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        try { 
            if (e1.getX() - e2.getX() > swipeMinDistance && Math.abs(velocityX) > swipeThresholdVelocity)
                return false; 
        } catch (Exception e) {
        } 
        return false; 
    } 
 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaledMaximumFlingVelocity
				scrollTo((int) scrollX, getScrollY());
			} 
			break; 
		case MotionEvent.ACTION_UP:
			if(beingDragged(event)){
				velocityTracker.computeCurrentVelocity(1000, viewConfiguration.getScaledMaximumFlingVelocity());
				smoothScrollTo(event.getX(), velocityTracker.getXVelocity());
				velocityTracker.recycle();
			} 
			break; 
		} 
		return true; 
	} 
	 
	private boolean beingDragged(MotionEvent event) {
		float dx = initialPosition - event.getX();
		return menuSlideAllowed(dx);
	} 
 
	private boolean menuSlideAllowed(float dx) {
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	public ToggleView(Context context) {
		this(context, null);
	} 
 
	private void initialize(Context context) {
		mTouchSlop = new ViewConfiguration().getScaledTouchSlop();
		mHandleFrame = new Rect();
		mScroller = new Scroller(context, new LinearInterpolator());
	} 
 
	@Override 
	public void draw(Canvas canvas) {
		Path clipPath = new Path();
		RectF rect = new RectF(getScrollX(), 0, getScrollX() + getWidth(),
				getHeight());
		clipPath.addRoundRect(rect, mClipRadius, mClipRadius, Path.Direction.CW);
		canvas.clipPath(clipPath);
		super.draw(canvas);
	} 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:hasPermanentMenuKey
@TargetApi(14) 
public class Utility14 extends Utility11 { 
 
    @Override 
    public boolean hasPermanentMenuKey(ViewConfiguration vcfg) {
        return vcfg.hasPermanentMenuKey();
    } 
     
 
    @Override 
    public void setLinearLayoutDividerPadding(LinearLayout l, int padding) {
        l.setDividerPadding(padding);
        super.setLinearLayoutDividerPadding(l, padding);
    } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getScaledTouchSlop
				} 
 
			case MotionEvent.ACTION_MOVE:
				// Check if user actually intends to scroll 
				final int deltaX = (int) Math.abs(touchX - ev.getX());
				if (deltaX > viewConfiguration.getScaledTouchSlop())
				{ 
					cancelCurrentAnimation(); 
					if (state == STATE_CLOSED)
						onStartOpening(); 
					else if (state == STATE_OPEN)
						onStartClosing(); 
					state = STATE_MOVING;
 
					return true; 
				} 
				break; 
		} 
		return super.onInterceptTouchEvent(ev);
	} 
3
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android ViewConfiguration Questions & Answers:

See Code Examples for Android ViewConfiguration Methods: