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 24 * NotifInflater is asked to (re)inflated and prepare their views. This inflation occurs off the 25 * main thread. When 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 */ 33 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 45 * removed and no longer needs to be inflated. Returns whether anything may have been aborted. 46 */ 47 fun abortInflation(entry: NotificationEntry): Boolean 48 49 /** 50 * Called to let the system remove the content views from the notification row. 51 */ 52 fun releaseViews(entry: NotificationEntry) 53 54 /** 55 * Callback once all the views are inflated and bound for a given NotificationEntry. 56 */ 57 interface InflationCallback { 58 fun onInflationFinished(entry: NotificationEntry, controller: NotifViewController) 59 } 60 61 /** 62 * A class holding parameters used when inflating the notification row 63 */ 64 class Params(val isLowPriority: Boolean, val reason: String, val showSnooze: Boolean) 65 } 66