diff options
author | cretin45 <cretin45@gmail.com> | 2016-03-18 10:29:39 -0700 |
---|---|---|
committer | cretin45 <cretin45@gmail.com> | 2016-03-18 10:59:19 -0700 |
commit | 96194b6e8377c65d658b0ef689d2828cc6bc793a (patch) | |
tree | 1696fda29c594d3e656f3fda7acd5848d59ce905 | |
parent | 96d3e2b0c2392f1f41d705a3e5d5ef319c27876d (diff) | |
download | android_packages_apps_FMRadio-96194b6e8377c65d658b0ef689d2828cc6bc793a.tar.gz android_packages_apps_FMRadio-96194b6e8377c65d658b0ef689d2828cc6bc793a.tar.bz2 android_packages_apps_FMRadio-96194b6e8377c65d658b0ef689d2828cc6bc793a.zip |
FMRadio: Fix station switch from list for certain locales
Issue-id: CYNGNOS-2234
Change-Id: Ic96e770da17753cd72544312a2397507b6279927
-rw-r--r-- | src/com/android/fmradio/FmFavoriteActivity.java | 27 |
1 files changed, 15 insertions, 12 deletions
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 @@ public class FmFavoriteActivity extends Activity { */ @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 @@ public class FmFavoriteActivity extends Activity { } 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; + } } /** |