Created
July 18, 2013 14:28
-
-
Save cuub/6029784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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