1 /*
2  * Copyright (C) 2020 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.systemui.statusbar.notification.collection.inflation;
18 
19 import android.annotation.Nullable;
20 
21 import com.android.systemui.statusbar.NotificationUiAdjustment;
22 import com.android.systemui.statusbar.notification.InflationException;
23 import com.android.systemui.statusbar.notification.NotificationEntryManager;
24 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
25 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder;
26 
27 /**
28  * Used by the {@link NotificationEntryManager}. When notifications are added or updated, the binder
29  * is asked to (re)inflate and prepare their views. This inflation must occur off the main thread.
30  */
31 public interface NotificationRowBinder {
32     /**
33      * Called when a notification has been added or updated. The binder must asynchronously inflate
34      * and bind the views associated with the notification.
35      *
36      * TODO: The caller is notified when the inflation completes, but this is currently a very
37      * roundabout business. Add an explicit completion/failure callback to this method.
38      */
inflateViews( NotificationEntry entry, NotificationRowContentBinder.InflationCallback callback)39     void inflateViews(
40             NotificationEntry entry,
41             NotificationRowContentBinder.InflationCallback callback)
42             throws InflationException;
43 
44     /**
45      * Called when the ranking has been updated (but not add or remove has been done). The binder
46      * should inspect the old and new adjustments and re-inflate the entry's views if necessary
47      * (e.g. if something important changed).
48      */
onNotificationRankingUpdated( NotificationEntry entry, @Nullable Integer oldImportance, NotificationUiAdjustment oldAdjustment, NotificationUiAdjustment newAdjustment, NotificationRowContentBinder.InflationCallback callback)49     void onNotificationRankingUpdated(
50             NotificationEntry entry,
51             @Nullable Integer oldImportance,
52             NotificationUiAdjustment oldAdjustment,
53             NotificationUiAdjustment newAdjustment,
54             NotificationRowContentBinder.InflationCallback callback);
55 }
56