Debian Codegraph @

core/java/com/android/internal/widget/MediaNotificationView.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17 package com.android.internal.widget;
18
19 import android.annotation.Nullable;
20 import android.content.Context;
21 import android.util.AttributeSet;
22 import android.widget.FrameLayout;
23 import android.widget.RemoteViews;
24
25 import java.util.ArrayList;
26
27 /**
28 * The Layout class which handles template details for the Notification.MediaStyle
29 *
30 * @hide
31 */
32 @RemoteViews.RemoteView
33 public class MediaNotificationView extends FrameLayout {
34
35 private ArrayList<VisibilityChangeListener> mListeners;
36
37 public MediaNotificationView(Context context) {
38 this(context, null);
39 }
40
41 public MediaNotificationView(Context context, @Nullable AttributeSet attrs) {
42 this(context, attrs, 0);
43 }
44
45 public MediaNotificationView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
46 this(context, attrs, defStyleAttr, 0);
47 }
48
49 public MediaNotificationView(Context context, AttributeSet attrs, int defStyleAttr,
50 int defStyleRes) {
51 super(context, attrs, defStyleAttr, defStyleRes);
52 }
53
54 @Override
55 protected void onFinishInflate() {
56 super.onFinishInflate();
57 }
58
59 @Override
60 public void onVisibilityAggregated(boolean isVisible) {
61 super.onVisibilityAggregated(isVisible);
62 if (mListeners != null) {
63 for (int i = 0; i < mListeners.size(); i++) {
64 mListeners.get(i).onAggregatedVisibilityChanged(isVisible);
65 }
66 }
67 }
68
69 /**
70 * Add a listener to receive updates on the visibility of this view
71 *
72 * @param listener The listener to add.
73 */
74 public void addVisibilityListener(VisibilityChangeListener listener) {
75 if (mListeners == null) {
76 mListeners = new ArrayList<>();
77 }
78 if (!mListeners.contains(listener)) {
79 mListeners.add(listener);
80 }
81 }
82
83 /**
84 * Remove the specified listener
85 *
86 * @param listener The listener to remove.
87 */
88 public void removeVisibilityListener(VisibilityChangeListener listener) {
89 if (mListeners != null) {
90 mListeners.remove(listener);
91 }
92 }
93
94 /**
95 * Interface for receiving updates when the view's visibility changes
96 */
97 public interface VisibilityChangeListener {
98 /**
99 * Method called when the visibility of this view has changed
100 * @param isVisible true if the view is now visible
101 */
102 void onAggregatedVisibilityChanged(boolean isVisible);
103 }
104 }