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 com.android.systemui.statusbar.notification.collection.NotificationEntry
20 import com.android.systemui.statusbar.notification.collection.render.NotifViewController
21 
22 /**
23  * Used by the [PreparationCoordinator]. When notifications are added or updated, the NotifInflater
24  * is asked to (re)inflated and prepare their views. This inflation occurs off the main thread. When
25  * the inflation is finished, NotifInflater will trigger its InflationCallback.
26  */
27 interface NotifInflater {
28     /**
29      * Called to rebind the entry's views.
30      *
31      * @param callback callback called after inflation finishes
32      */
rebindViewsnull33     fun rebindViews(entry: NotificationEntry, params: Params, callback: InflationCallback)
34 
35     /**
36      * Called to inflate the views of an entry. Views are not considered inflated until all of its
37      * views are bound. Once all views are inflated, the InflationCallback is triggered.
38      *
39      * @param callback callback called after inflation finishes
40      */
41     fun inflateViews(entry: NotificationEntry, params: Params, callback: InflationCallback)
42 
43     /**
44      * Request to stop the inflation of an entry. For example, called when a notification is removed
45      * and no longer needs to be inflated. Returns whether anything may have been aborted.
46      */
47     fun abortInflation(entry: NotificationEntry): Boolean
48 
49     /** Called to let the system remove the content views from the notification row. */
50     fun releaseViews(entry: NotificationEntry)
51 
52     /** Callback once all the views are inflated and bound for a given NotificationEntry. */
53     interface InflationCallback {
54         fun onInflationFinished(entry: NotificationEntry, controller: NotifViewController)
55     }
56 
57     /** A class holding parameters used when inflating the notification row */
58     class Params(
59         val isMinimized: Boolean,
60         val reason: String,
61         val showSnooze: Boolean,
62         val isChildInGroup: Boolean = false,
63         val isGroupSummary: Boolean = false,
64         val needsRedaction: Boolean,
65     )
66 }
67