FMRadio: Fix station switch from list for certain locales

Issue-id: CYNGNOS-2234

Change-Id: Ic96e770da17753cd72544312a2397507b6279927
diff --git a/src/com/android/fmradio/FmFavoriteActivity.java b/src/com/android/fmradio/FmFavoriteActivity.java
index 6abef98..07c8515 100644
--- a/src/com/android/fmradio/FmFavoriteActivity.java
+++ b/src/com/android/fmradio/FmFavoriteActivity.java
@@ -127,19 +127,13 @@
              */
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                // Set the selected frequency to main UI and finish the
-                // favorite manager.
-                TextView textView = (TextView) view.findViewById(R.id.lv_station_freq);
-                float frequency = 0;
-                try {
-                    frequency = Float.parseFloat(textView.getText().toString());
-                } catch (NumberFormatException e) {
-                    e.printStackTrace();
+                int frequency = mMyAdapter.getStationFreq(position);
+                if (frequency != -1) {
+                    Intent intentResult = new Intent();
+                    intentResult.putExtra(ACTIVITY_RESULT, frequency);
+                    setResult(RESULT_OK, intentResult);
+                    finish();
                 }
-                Intent intentResult = new Intent();
-                intentResult.putExtra(ACTIVITY_RESULT, FmUtils.computeStation(frequency));
-                setResult(RESULT_OK, intentResult);
-                finish();
             }
         });
 
@@ -368,6 +362,15 @@
             }
             return convertView;
         }
+
+        private int getStationFreq(int position) {
+            if (mCursor != null && mCursor.moveToPosition(position)) {
+                final int stationFreq = mCursor.getInt(mCursor
+                        .getColumnIndex(FmStation.Station.FREQUENCY));
+                return stationFreq;
+            }
+            return -1;
+        }
     }
 
     /**