am 838e2cfc: am 51530a28: Merge "[FM] FM recording time will display incorrectly when recording time is beyond 60 minutes" into lmp-mr1-dev

* commit '838e2cfcf3ce583328f62668c44baa3e6525d629':
  [FM] FM recording time will display incorrectly when recording time is beyond 60 minutes
diff --git a/src/com/android/fmradio/FmRecordActivity.java b/src/com/android/fmradio/FmRecordActivity.java
index 8a6614a..4df42ec 100644
--- a/src/com/android/fmradio/FmRecordActivity.java
+++ b/src/com/android/fmradio/FmRecordActivity.java
@@ -61,6 +61,7 @@
     private static final String FM_ENTER_RECORD_SCREEN = "fmradio.enter.record.screen";
     private static final String TAG_SAVE_RECORDINGD = "SaveRecording";
     private static final int MSG_UPDATE_NOTIFICATION = 1000;
+    private static final int TIME_BASE = 60;
     private Context mContext;
     private TextView mMintues;
     private TextView mSeconds;
@@ -226,6 +227,7 @@
         }
         // Trigger to refreshing timer text if still in record
         if (!isStopRecording()) {
+            mHandler.removeMessages(FmListener.MSGID_REFRESH);
             mHandler.sendEmptyMessage(FmListener.MSGID_REFRESH);
         }
         // Clear notification, it only need show when in background
@@ -331,6 +333,7 @@
             }
             mPlayIndicator.startAnimation();
             mStopRecordButton.setEnabled(true);
+            mHandler.removeMessages(FmListener.MSGID_REFRESH);
             mHandler.sendEmptyMessage(FmListener.MSGID_REFRESH);
         };
 
@@ -340,6 +343,14 @@
         };
     };
 
+    private String addPaddingForString(long time) {
+        StringBuilder builder = new StringBuilder();
+        if (time >= 0 && time < 10) {
+            builder.append("0");
+        }
+        return builder.append(time).toString();
+    }
+
     private final Handler mHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
@@ -347,11 +358,9 @@
                 case FmListener.MSGID_REFRESH:
                     if (mService != null) {
                         long recordTime = mService.getRecordTime();
-                        Date date = new Date(recordTime);
-                        SimpleDateFormat format = new SimpleDateFormat("mm:ss");
-                        String[] timeText = format.format(date).split(":");
-                        mMintues.setText(timeText[0]);
-                        mSeconds.setText(timeText[1]);
+                        recordTime = recordTime / 1000L;
+                        mMintues.setText(addPaddingForString(recordTime / TIME_BASE));
+                        mSeconds.setText(addPaddingForString(recordTime % TIME_BASE));
 
                         // Check storage free space
                         String recordingSdcard = FmUtils.getDefaultStoragePath();