1 /* 2 * Copyright (C) 2019 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; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 22 import com.android.systemui.statusbar.notification.collection.coordinator.PreparationCoordinator; 23 24 import java.util.ArrayList; 25 import java.util.Collections; 26 import java.util.Comparator; 27 import java.util.List; 28 29 /** 30 * Represents a set of grouped notifications. The final notification list is usually a mix of 31 * GroupEntries and NotificationEntries. 32 */ 33 public class GroupEntry extends ListEntry { 34 @Nullable private NotificationEntry mSummary; 35 private final List<NotificationEntry> mChildren = new ArrayList<>(); 36 37 private final List<NotificationEntry> mUnmodifiableChildren = 38 Collections.unmodifiableList(mChildren); 39 private int mUntruncatedChildCount; 40 GroupEntry(String key, long creationTime)41 GroupEntry(String key, long creationTime) { 42 super(key, creationTime); 43 } 44 45 @Override getRepresentativeEntry()46 public NotificationEntry getRepresentativeEntry() { 47 return mSummary; 48 } 49 50 @Nullable getSummary()51 public NotificationEntry getSummary() { 52 return mSummary; 53 } 54 55 @NonNull getChildren()56 public List<NotificationEntry> getChildren() { 57 return mUnmodifiableChildren; 58 } 59 setSummary(@ullable NotificationEntry summary)60 void setSummary(@Nullable NotificationEntry summary) { 61 mSummary = summary; 62 } 63 64 /** 65 * @see #getUntruncatedChildCount() 66 */ setUntruncatedChildCount(int childCount)67 public void setUntruncatedChildCount(int childCount) { 68 mUntruncatedChildCount = childCount; 69 } 70 71 /** 72 * Get the untruncated number of children from the data model, including those that will not 73 * have views bound. This includes children that {@link PreparationCoordinator} will filter out 74 * entirely when they are beyond the last visible child. 75 * 76 * TODO: This should move to some shared class between the model and view hierarchy 77 */ getUntruncatedChildCount()78 public int getUntruncatedChildCount() { 79 return mUntruncatedChildCount; 80 } 81 clearChildren()82 void clearChildren() { 83 mChildren.clear(); 84 } 85 addChild(NotificationEntry child)86 void addChild(NotificationEntry child) { 87 mChildren.add(child); 88 } 89 sortChildren(Comparator<? super NotificationEntry> c)90 void sortChildren(Comparator<? super NotificationEntry> c) { 91 mChildren.sort(c); 92 } 93 getRawChildren()94 List<NotificationEntry> getRawChildren() { 95 return mChildren; 96 } 97 98 public static final GroupEntry ROOT_ENTRY = new GroupEntry("<root>", 0); 99 100 } 101