Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java

Issue 1915083002: [Android,MediaFling] Create and register the notification object early (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix notification not hiding Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/media/remote/DefaultMediaRouteController.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java
index 2dfc2dff9ade336ba265fd8543aa424140260cc7..5e09e0935e578ca7998430b66f2d811326d922db 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java
@@ -60,7 +60,7 @@ public class CastNotificationControl implements MediaRouteController.UiListener,
if (sInstance == null) {
sInstance = new CastNotificationControl(context);
}
- sInstance.mMediaRouteController = mediaRouteController;
+ sInstance.setRouteController(mediaRouteController);
return sInstance;
}
}
@@ -117,10 +117,15 @@ public class CastNotificationControl implements MediaRouteController.UiListener,
}
public void setRouteController(MediaRouteController controller) {
+ if (mMediaRouteController != null) mMediaRouteController.removeUiListener(this);
mMediaRouteController = controller;
+ if (controller != null) controller.addUiListener(this);
}
private void updateNotification() {
+ // Nothing shown yet, nothing to update.
+ if (mNotificationBuilder == null) return;
+
mNotificationBuilder.setMetadata(new MediaMetadata(mTitle, "", ""));
if (mState == PlayerState.PAUSED || mState == PlayerState.PLAYING) {
mNotificationBuilder.setPaused(mState != PlayerState.PLAYING);
@@ -146,6 +151,8 @@ public class CastNotificationControl implements MediaRouteController.UiListener,
// MediaRouteController.UiListener implementation.
@Override
public void onPlaybackStateChanged(PlayerState newState) {
+ if (mState == newState) return;
+
mState = newState;
updateNotification();
}
@@ -177,7 +184,9 @@ public class CastNotificationControl implements MediaRouteController.UiListener,
@Override
public void onTitleChanged(String title) {
- mTitle = (title == null) ? "" : title;
+ if (title == null || title.equals(mTitle)) return;
+
+ mTitle = title;
updateNotification();
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/media/remote/DefaultMediaRouteController.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698