[FM] The channel name will not disappear on the main screen after deleting a channel from the Favorites
Enter FM radio -> Tap star icon to add the channel in
the Favorites -> Rename the channel -> Tap star icon
to delete a channel from the Favorites -> Check the name
on the main screen, the channel name will not disappear.
The CL is to fix this issue.
Bug 18847141
from: https://partner-android-review.googlesource.com/#/c/192388/1
Change-Id: Ia8331caa460f3bf0036c3470705e37d8aaf14e5a
Signed-off-by: Benson Huang <benson.huang@mediatek.com>
diff --git a/src/com/android/fmradio/FmMainActivity.java b/src/com/android/fmradio/FmMainActivity.java
index ec7baf0..043a540 100644
--- a/src/com/android/fmradio/FmMainActivity.java
+++ b/src/com/android/fmradio/FmMainActivity.java
@@ -505,6 +505,9 @@
// TODO it's on UI thread, change to sub thread
if (FmStation.isFavoriteStation(mContext, frequency)) {
FmStation.removeFromFavorite(mContext, frequency);
+ if (mCurrentStation == frequency) {
+ mTextStationName.setText(FmStation.getStationName(mContext, frequency));
+ }
mButtonAddToFavorite.setImageResource(R.drawable.btn_fm_favorite_off_selector);
// Notify scroller
mScroller.onRemoveFavorite();
diff --git a/src/com/android/fmradio/FmStation.java b/src/com/android/fmradio/FmStation.java
index 00609e4..5924281 100644
--- a/src/com/android/fmradio/FmStation.java
+++ b/src/com/android/fmradio/FmStation.java
@@ -316,6 +316,7 @@
public static void removeFromFavorite(Context context, int frequency) {
ContentValues values = new ContentValues(1);
values.put(Station.IS_FAVORITE, false);
+ values.put(Station.STATION_NAME, "");
context.getContentResolver().update(
Station.CONTENT_URI,
values,