1 /* <lambda>null2 * Copyright (C) 2024 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.row 18 19 import android.content.Context 20 import android.util.AttributeSet 21 import android.view.View 22 import android.widget.ViewFlipper 23 import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.InflationFlag 24 import com.android.systemui.statusbar.notification.row.ui.viewbinder.NotificationViewFlipperBinder 25 import com.android.systemui.statusbar.notification.row.ui.viewmodel.NotificationViewFlipperViewModel 26 import com.android.systemui.statusbar.notification.shared.NotificationViewFlipperPausing 27 import javax.inject.Inject 28 29 /** 30 * A factory which owns the construction of any ViewFlipper inside of Notifications, and binds it 31 * with a view model. This ensures that ViewFlippers are paused when the keyguard is showing. 32 */ 33 class NotificationViewFlipperFactory 34 @Inject 35 constructor( 36 private val viewModel: NotificationViewFlipperViewModel, 37 ) : NotifRemoteViewsFactory { 38 init { 39 /* check if */ NotificationViewFlipperPausing.isUnexpectedlyInLegacyMode() 40 } 41 42 override fun instantiate( 43 row: ExpandableNotificationRow, 44 @InflationFlag layoutType: Int, 45 parent: View?, 46 name: String, 47 context: Context, 48 attrs: AttributeSet 49 ): View? { 50 return when (name) { 51 ViewFlipper::class.java.name, 52 ViewFlipper::class.java.simpleName -> 53 ViewFlipper(context, attrs).also { viewFlipper -> 54 NotificationViewFlipperBinder.bindWhileAttached(viewFlipper, viewModel) 55 } 56 else -> null 57 } 58 } 59 } 60