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