From 96194b6e8377c65d658b0ef689d2828cc6bc793a Mon Sep 17 00:00:00 2001 From: cretin45 Date: Fri, 18 Mar 2016 10:29:39 -0700 Subject: FMRadio: Fix station switch from list for certain locales Issue-id: CYNGNOS-2234 Change-Id: Ic96e770da17753cd72544312a2397507b6279927 --- src/com/android/fmradio/FmFavoriteActivity.java | 27 ++++++++++++++----------- 1 file 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; + } } /** -- cgit v1.2.3