1 /* <lambda>null2 * 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.render 18 19 import android.view.LayoutInflater 20 import android.view.View 21 import android.view.ViewGroup 22 import com.android.systemui.dagger.SysUISingleton 23 import com.android.systemui.res.R 24 import com.android.systemui.shade.ShadeDisplayAware 25 import com.android.systemui.statusbar.notification.stack.MediaContainerView 26 import javax.inject.Inject 27 28 @SysUISingleton 29 class MediaContainerController 30 @Inject 31 constructor(@ShadeDisplayAware private val layoutInflater: LayoutInflater) : NodeController { 32 33 override val nodeLabel = "MediaContainer" 34 var mediaContainerView: MediaContainerView? = null 35 private set 36 37 fun reinflateView(parent: ViewGroup) { 38 var oldPos = -1 39 mediaContainerView?.let { _view -> 40 _view.removeFromTransientContainer() 41 if (_view.parent === parent) { 42 oldPos = parent.indexOfChild(_view) 43 parent.removeView(_view) 44 } 45 } 46 val inflated = 47 layoutInflater.inflate( 48 R.layout.keyguard_media_container, 49 parent, 50 false, /* attachToRoot */ 51 ) as MediaContainerView 52 if (oldPos != -1) { 53 parent.addView(inflated, oldPos) 54 } 55 mediaContainerView = inflated 56 } 57 58 override val view: View 59 get() = mediaContainerView!! 60 61 override fun offerToKeepInParentForAnimation(): Boolean = false 62 63 override fun removeFromParentIfKeptForAnimation(): Boolean = false 64 65 override fun resetKeepInParentForAnimation() {} 66 } 67