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.render 18 19 import android.view.View 20 import com.android.systemui.statusbar.notification.row.ExpandableView 21 import com.android.systemui.statusbar.notification.stack.NotificationListContainer 22 23 /** 24 * Temporary wrapper around [NotificationListContainer], for use by [ShadeViewDiffer]. Long term, 25 * we should just modify NLC to implement the NodeController interface. 26 */ 27 class RootNodeController( 28 private val listContainer: NotificationListContainer, 29 override val view: View 30 ) : NodeController { 31 override val nodeLabel: String = "<root>" 32 33 override fun getChildAt(index: Int): View? { 34 return listContainer.getContainerChildAt(index) 35 } 36 37 override fun getChildCount(): Int { 38 return listContainer.containerChildCount 39 } 40 41 override fun addChildAt(child: NodeController, index: Int) { 42 listContainer.addContainerViewAt(child.view, index) 43 } 44 45 override fun moveChildTo(child: NodeController, index: Int) { 46 listContainer.changeViewPosition(child.view as ExpandableView, index) 47 } 48 49 override fun removeChild(child: NodeController, isTransfer: Boolean) { 50 if (isTransfer) { 51 listContainer.setChildTransferInProgress(true) 52 } 53 listContainer.removeContainerView(child.view) 54 if (isTransfer) { 55 listContainer.setChildTransferInProgress(false) 56 } 57 } 58 } 59