diff options
| author | Beth Thibodeau <ethibodeau@google.com> | 2019-07-25 16:42:51 -0400 |
|---|---|---|
| committer | Beth Thibodeau <ethibodeau@google.com> | 2019-07-26 11:33:18 -0400 |
| commit | 3c4a8e48d404649bd03ee8e6e377dcf9a65afee9 (patch) | |
| tree | 51a747cb8ae4ea1e1af30468a82ec1bb8b17ed01 /core/java | |
| parent | ed4820f0d08920b376bad1360c3b3cc2aa007feb (diff) | |
Stop timer when notification isn't visible
Fixes: 138261464
Test: manual, atest com.android.systemui.statusbar.notification.row.wrapper.NotificationMediaTemplateViewWrapperTest
Change-Id: Id7b1b586f3ab258fad8670070240ef951080c969
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/widget/MediaNotificationView.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/core/java/com/android/internal/widget/MediaNotificationView.java b/core/java/com/android/internal/widget/MediaNotificationView.java index e7d240a1035e..0d87afa42e3e 100644 --- a/core/java/com/android/internal/widget/MediaNotificationView.java +++ b/core/java/com/android/internal/widget/MediaNotificationView.java @@ -26,6 +26,8 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.RemoteViews; +import java.util.ArrayList; + /** * A TextView that can float around an image on the end. * @@ -42,6 +44,7 @@ public class MediaNotificationView extends FrameLayout { private View mMainColumn; private View mMediaContent; private int mImagePushIn; + private ArrayList<VisibilityChangeListener> mListeners; public MediaNotificationView(Context context) { this(context, null); @@ -168,4 +171,48 @@ public class MediaNotificationView extends FrameLayout { mMainColumn = findViewById(com.android.internal.R.id.notification_main_column); mMediaContent = findViewById(com.android.internal.R.id.notification_media_content); } + + @Override + public void onVisibilityAggregated(boolean isVisible) { + super.onVisibilityAggregated(isVisible); + for (int i = 0; i < mListeners.size(); i++) { + mListeners.get(i).onAggregatedVisibilityChanged(isVisible); + } + } + + /** + * Add a listener to receive updates on the visibility of this view + * + * @param listener The listener to add. + */ + public void addVisibilityListener(VisibilityChangeListener listener) { + if (mListeners == null) { + mListeners = new ArrayList<>(); + } + if (!mListeners.contains(listener)) { + mListeners.add(listener); + } + } + + /** + * Remove the specified listener + * + * @param listener The listener to remove. + */ + public void removeVisibilityListener(VisibilityChangeListener listener) { + if (mListeners != null) { + mListeners.remove(listener); + } + } + + /** + * Interface for receiving updates when the view's visibility changes + */ + public interface VisibilityChangeListener { + /** + * Method called when the visibility of this view has changed + * @param isVisible true if the view is now visible + */ + void onAggregatedVisibilityChanged(boolean isVisible); + } } |
