[Android] Seek gesture : factorize usage of getWindowManager().getDefaultDisplay()
Sébastien Toque
git at videolan.org
Tue Aug 14 22:58:59 CEST 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Tue Aug 14 21:06:26 2012 +0200| [e32c364e265156fd1e40e7772bfaad554def76a6] | committer: Sébastien Toque
Seek gesture : factorize usage of getWindowManager().getDefaultDisplay()
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=e32c364e265156fd1e40e7772bfaad554def76a6
---
.../org/videolan/vlc/gui/video/VideoPlayerActivity.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index ec7e91f..97e7f74 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -637,14 +637,13 @@ public class VideoPlayerActivity extends Activity {
* show/hide the overlay
*/
- @SuppressWarnings("deprecation")
@Override
public boolean onTouchEvent(MotionEvent event) {
+ DisplayMetrics screen = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(screen);
if (mAudioDisplayRange == 0)
- mAudioDisplayRange = Math.min(
- getWindowManager().getDefaultDisplay().getWidth(),
- getWindowManager().getDefaultDisplay().getHeight());
+ mAudioDisplayRange = Math.min(screen.widthPixels, screen.heightPixels);
float y_changed = event.getRawY() - mTouchY;
float x_changed = event.getRawX() - mTouchX;
@@ -689,11 +688,8 @@ public class VideoPlayerActivity extends Activity {
OVERLAY_TIMEOUT);
}
}
- // Seek
- // Tools to get the xdpi resolution for the cubic progression
- DisplayMetrics screen = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(screen);
+ // Seek
float gesturesize = (float) ((x_changed / screen.xdpi) * 2.54);
// No seek action if coef > 0.5 and gesturesize < 1cm
if ((Math.abs(y_changed) < Math.abs(x_changed))
More information about the Android
mailing list