Skip to content

Instantly share code, notes, and snippets.

@cuub
Created July 18, 2013 14:28
Show Gist options
  • Save cuub/6029784 to your computer and use it in GitHub Desktop.
Save cuub/6029784 to your computer and use it in GitHub Desktop.
private static final int PEEK_DRAWER_TIME_SECONDS = 2;
private long downTime;
private long eventTime;
private float x = 0.0f;
private float y = 100.0f;
private int metaState = 0;
protected void peekDrawer() {
downTime = SystemClock.uptimeMillis();
eventTime = SystemClock.uptimeMillis() + 100;
MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, metaState);
mDrawerLayout.dispatchTouchEvent(motionEvent);
motionEvent.recycle();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
downTime = SystemClock.uptimeMillis();
eventTime = SystemClock.uptimeMillis() + 100;
MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, metaState);
mDrawerLayout.dispatchTouchEvent(motionEvent);
motionEvent.recycle();
}
}, (long) (PEEK_DRAWER_TIME_SECONDS * DateUtils.SECOND_IN_MILLIS));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment