Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean onTouchEvent(MotionEvent event) {
- if (this.mSwipe2SleepActive && event.getAction() == 1 && this.mIsDown) {
- this.mIsDown = false;
- mySwipeDetector(this.mDownX, this.mDownY, this.mDownTime, event.getX(), event.getY(), System.currentTimeMillis());
- }
- if (this.mTaskSwitchHelper.onTouchEvent(event)) {
- return true;
- }
- if (this.mDeadZone != null && event.getAction() == 4) {
- this.mDeadZone.poke(event);
- }
- return super.onTouchEvent(event);
- }
- private void mySwipeDetector(float e1X, float e1Y, long e1Time, float e2X, float e2Y, long e2Time) {
- float distanceX = e2X - e1X;
- float distanceY = e2Y - e1Y;
- float velocityX = (distanceX / ((float) (e2Time - e1Time))) * 1000.0f;
- float velocityY = (distanceY / ((float) (e2Time - e1Time))) * 1000.0f;
- String summary = "";
- if (this.mContext.getResources().getConfiguration().orientation == 1) {
- if (Math.abs(distanceX) > Math.abs(distanceY) && Math.abs(distanceX) > 300.0f && e2Y > -50.0f && Math.abs(velocityX) > 1000.0f) {
- this.mPowerManager.goToSleep(SystemClock.uptimeMillis());
- }
- } else if (Math.abs(distanceY) > Math.abs(distanceX) && Math.abs(distanceY) > 300.0f && e2X > -50.0f && Math.abs(velocityY) > 1000.0f) {
- this.mPowerManager.goToSleep(SystemClock.uptimeMillis());
- }
- }
- public boolean onInterceptTouchEvent(MotionEvent event) {
- if (this.mSwipe2SleepActive && event.getAction() == 0) {
- this.mDownTime = System.currentTimeMillis();
- this.mDownX = event.getX();
- this.mDownY = event.getY();
- this.mIsDown = true;
- }
- return this.mTaskSwitchHelper.onInterceptTouchEvent(event);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement