• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 package com.android.launcher3.taskbar.allapps;
17 
18 import android.content.Context;
19 import android.util.AttributeSet;
20 
21 import androidx.annotation.Nullable;
22 
23 import com.android.launcher3.allapps.ActivityAllAppsContainerView;
24 import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
25 
26 import java.util.Optional;
27 
28 /** All apps container accessible from taskbar. */
29 public class TaskbarAllAppsContainerView extends
30         ActivityAllAppsContainerView<TaskbarOverlayContext> {
31 
32     private @Nullable OnInvalidateHeaderListener mOnInvalidateHeaderListener;
33 
TaskbarAllAppsContainerView(Context context, AttributeSet attrs)34     public TaskbarAllAppsContainerView(Context context, AttributeSet attrs) {
35         this(context, attrs, 0);
36     }
37 
TaskbarAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr)38     public TaskbarAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
39         super(context, attrs, defStyleAttr);
40     }
41 
setOnInvalidateHeaderListener(OnInvalidateHeaderListener onInvalidateHeaderListener)42     void setOnInvalidateHeaderListener(OnInvalidateHeaderListener onInvalidateHeaderListener) {
43         mOnInvalidateHeaderListener = onInvalidateHeaderListener;
44     }
45 
46     @Override
invalidateHeader()47     public void invalidateHeader() {
48         super.invalidateHeader();
49         Optional.ofNullable(mOnInvalidateHeaderListener).ifPresent(
50                 OnInvalidateHeaderListener::onInvalidateHeader);
51     }
52 
53     @Override
isInAllApps()54     public boolean isInAllApps() {
55         // All apps is always open
56         return true;
57     }
58 
59     interface OnInvalidateHeaderListener {
onInvalidateHeader()60         void onInvalidateHeader();
61     }
62 }
63