1 /*
2  * Copyright (C) 2018 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.launcher3.model;
18 
19 import android.content.Context;
20 import android.os.UserHandle;
21 
22 import com.android.launcher3.icons.ComponentWithLabel;
23 import com.android.launcher3.LauncherAppState;
24 import com.android.launcher3.util.PackageUserKey;
25 import com.android.launcher3.widget.WidgetListRowEntry;
26 
27 import java.util.ArrayList;
28 import java.util.Collections;
29 import java.util.List;
30 import java.util.Set;
31 
32 import androidx.annotation.Nullable;
33 
34 /**
35  * Widgets data model that is used by the adapters of the widget views and controllers.
36  *
37  * <p> The widgets and shortcuts are organized using package name as its index.
38  */
39 public class WidgetsModel {
40     private static final ArrayList<WidgetListRowEntry> EMPTY_WIDGET_LIST = new ArrayList<>();
41 
42     /**
43      * Returns a list of {@link WidgetListRowEntry}. All {@link WidgetItem} in a single row
44      * are sorted (based on label and user), but the overall list of {@link WidgetListRowEntry}s
45      * is not sorted. This list is sorted at the UI when using
46      * {@link com.android.launcher3.widget.WidgetsDiffReporter}
47      *
48      * @see com.android.launcher3.widget.WidgetsListAdapter#setWidgets(ArrayList)
49      */
getWidgetsList(Context context)50     public synchronized ArrayList<WidgetListRowEntry> getWidgetsList(Context context) {
51         return EMPTY_WIDGET_LIST;
52     }
53 
54     /**
55      * @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
56      *                    only widgets and shortcuts associated with the package/user are.
57      */
update(LauncherAppState app, @Nullable PackageUserKey packageUser)58     public List<ComponentWithLabel> update(LauncherAppState app,
59             @Nullable PackageUserKey packageUser) {
60         return Collections.emptyList();
61     }
62 
63 
onPackageIconsUpdated(Set<String> packageNames, UserHandle user, LauncherAppState app)64     public void onPackageIconsUpdated(Set<String> packageNames, UserHandle user,
65             LauncherAppState app) {
66     }
67 }