1 /*
2  * Copyright (C) 2021 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.render
18 
19 import com.android.systemui.statusbar.notification.collection.GroupEntry
20 import com.android.systemui.statusbar.notification.collection.ListEntry
21 import com.android.systemui.statusbar.notification.collection.NotificationEntry
22 
23 /**
24  * This interface and the interfaces it returns define the main API surface that must be
25  * implemented by the view implementation.  The term "render" is used to indicate a handoff
26  * to the view system, whether that be to attach views to the hierarchy or to update independent
27  * view models, data stores, or adapters.
28  */
29 interface NotifViewRenderer {
30 
31     /**
32      * Hand off the list of notifications to the view implementation.  This may attach views to the
33      * hierarchy or simply update an independent datastore, but once called, the implementer myst
34      * also ensure that future calls to [getStackController], [getGroupController], and
35      * [getRowController] will provide valid results.
36      */
onRenderListnull37     fun onRenderList(notifList: List<ListEntry>)
38 
39     /**
40      * Provides an interface for the pipeline to update the overall shade.
41      * This will be called at most once for each time [onRenderList] is called.
42      */
43     fun getStackController(): NotifStackController
44 
45     /**
46      * Provides an interface for the pipeline to update individual groups.
47      * This will be called at most once for each group in the most recent call to [onRenderList].
48      */
49     fun getGroupController(group: GroupEntry): NotifGroupController
50 
51     /**
52      * Provides an interface for the pipeline to update individual entries.
53      * This will be called at most once for each entry in the most recent call to [onRenderList].
54      * This includes top level entries, group summaries, and group children.
55      */
56     fun getRowController(entry: NotificationEntry): NotifRowController
57 
58     /**
59      * Invoked after the render stage manager has finished dispatching to all of the listeners.
60      *
61      * This is an opportunity for the view system to do any cleanup or trigger any finalization
62      * logic now that all data from the pipeline is known to have been set for this execution.
63      *
64      * When this is called, the view system can expect that no more calls will be made to the
65      * getters on this interface until after the next call to [onRenderList].  Additionally, there
66      * should be no further calls made on the objects previously returned by those getters.
67      */
68     fun onDispatchComplete() {}
69 }