[FM] FM radio "Plug in headphones" view will flash twice after plugging out headphones while searching
First time launch FM and play a station -> Tap Radio
Station button -> Plug out headphone while searching
station -> Check the display, "Plug in headphones" view
will flash twice.
When plugging out earphone in Radio Station screen, it's
no need to start animation to show no earphone view. Just
show no earphone view.
Bug 18780139
Review: https://partner-android-review.git.corp.google.com/#/c/189538
Signed-off-by: Benson Huang <benson.huang@mediatek.com>
Change-Id: I4cad7ca328f40057a14823db04d53868fe3867f3
diff --git a/src/com/android/fmradio/FmMainActivity.java b/src/com/android/fmradio/FmMainActivity.java
index 5eadedf..ec7baf0 100644
--- a/src/com/android/fmradio/FmMainActivity.java
+++ b/src/com/android/fmradio/FmMainActivity.java
@@ -245,10 +245,18 @@
boolean hasAntenna = bundle.getBoolean(FmListener.KEY_IS_SWITCH_ANTENNA);
// if receive headset plug out, need set headset mode on ui
if (hasAntenna) {
- playMainAnimation();
+ if (mIsActivityForeground) {
+ playMainAnimation();
+ } else {
+ changeToMainLayout();
+ }
} else {
mMenuItemHeadset.setIcon(R.drawable.btn_fm_headset_selector);
- playNoHeadsetAnimation();
+ if (mIsActivityForeground) {
+ playNoHeadsetAnimation();
+ } else {
+ changeToNoHeadsetLayout();
+ }
}
break;
@@ -1144,10 +1152,6 @@
Log.e(TAG, "playMainAnimation, mService is null");
return;
}
- if (!mService.isActivityForeground()) {
- Log.e(TAG, "playMainAnimation, activity is background");
- return;
- }
if (mMainLayout.isShown()) {
Log.w(TAG, "playMainAnimation, main layout has already shown");
return;
@@ -1171,10 +1175,6 @@
Log.e(TAG, "playNoHeadsetAnimation, mService is null");
return;
}
- if (!mService.isActivityForeground()) {
- Log.e(TAG, "playNoHeadsetAnimation, activity is background");
- return;
- }
if (mNoHeadsetLayout.isShown()) {
Log.w(TAG,"playNoHeadsetAnimation, no headset layout has already shown");
return;