[Android] Util: factorize speed formatting

Edward Wang git at videolan.org
Sat Dec 8 23:31:06 CET 2012


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Dec  8 17:31:13 2012 -0500| [06f49ae00cf934a4564ff3a2ff950792520a6e9c] | committer: Edward Wang

Util: factorize speed formatting

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=06f49ae00cf934a4564ff3a2ff950792520a6e9c
---

 vlc-android/src/org/videolan/vlc/Util.java                      |    7 +++++++
 .../src/org/videolan/vlc/gui/audio/AudioPlayerActivity.java     |    2 +-
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java     |    2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index f33d5c3..8c7b20e 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -446,4 +446,11 @@ public class Util {
         }
         return dirs;
     }
+
+    /**
+     * Get the formatted current playback speed in the form of 1.00x
+     */
+    public static String formatRateString(float rate) {
+        return String.format(java.util.Locale.US, "%.2fx", rate);
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerActivity.java
index 854959a..95b950f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayerActivity.java
@@ -223,7 +223,7 @@ public class AudioPlayerActivity extends Activity implements IAudioPlayer {
             mPrevious.setVisibility(ImageButton.VISIBLE);
         else
             mPrevious.setVisibility(ImageButton.INVISIBLE);
-        mSpeed.setText(String.format(java.util.Locale.US, "%.2fx", mAudioController.getRate()));
+        mSpeed.setText(Util.formatRateString(mAudioController.getRate()));
         mTimeline.setOnSeekBarChangeListener(mTimelineListner);
     }
 
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 1bf7326..c6ac669 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1053,7 +1053,7 @@ public class VideoPlayerActivity extends Activity {
 
                 @Override
                 public void onDismiss(DialogInterface dialog) {
-                    mSpeedLabel.setText(String.format(java.util.Locale.US, "%.2fx", mLibVLC.getRate()));
+                    mSpeedLabel.setText(Util.formatRateString(mLibVLC.getRate()));
                 }
             });
             d.show();



More information about the Android mailing list