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