use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.
the class WidgetsModel method setWidgetsAndShortcuts.
private synchronized void setWidgetsAndShortcuts(ArrayList<WidgetItem> rawWidgetsShortcuts, LauncherAppState app, @Nullable PackageUserKey packageUser) {
if (DEBUG) {
Log.d(TAG, "addWidgetsAndShortcuts, widgetsShortcuts#=" + rawWidgetsShortcuts.size());
}
// Temporary cache for {@link PackageItemInfos} to avoid having to go through
// {@link mPackageItemInfos} to locate the key to be used for {@link #mWidgetsList}
PackageItemInfoCache packageItemInfoCache = new PackageItemInfoCache();
if (packageUser == null) {
// Clear the list if this is an update on all widgets and shortcuts.
mWidgetsList.clear();
} else {
// Otherwise, only clear the widgets and shortcuts for the changed package.
mWidgetsList.remove(packageItemInfoCache.getOrCreate(packageUser));
}
// add and update.
mWidgetsList.putAll(rawWidgetsShortcuts.stream().filter(new WidgetValidityCheck(app)).flatMap(widgetItem -> getPackageUserKeys(app.getContext(), widgetItem).stream().map(key -> new Pair<>(packageItemInfoCache.getOrCreate(key), widgetItem))).collect(groupingBy(pair -> pair.first, mapping(pair -> pair.second, toList()))));
// Update each package entry
IconCache iconCache = app.getIconCache();
for (PackageItemInfo p : packageItemInfoCache.values()) {
iconCache.getTitleAndIconForApp(p, true);
}
}
use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.
the class WidgetsDiffReporterTest method createWidgetsContentEntry.
private WidgetsListContentEntry createWidgetsContentEntry(String packageName, String appName, int numOfWidgets) {
List<WidgetItem> widgetItems = generateWidgetItems(packageName, numOfWidgets);
PackageItemInfo pInfo = createPackageItemInfo(packageName, appName, widgetItems.get(0).user);
return new WidgetsListContentEntry(pInfo, /* titleSectionName= */
"", widgetItems);
}
use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.
the class WidgetsDiffReporterTest method createWidgetsHeaderEntry.
private WidgetsListHeaderEntry createWidgetsHeaderEntry(String packageName, String appName, int numOfWidgets) {
List<WidgetItem> widgetItems = generateWidgetItems(packageName, numOfWidgets);
PackageItemInfo pInfo = createPackageItemInfo(packageName, appName, widgetItems.get(0).user);
return new WidgetsListHeaderEntry(pInfo, /* titleSectionName= */
"", widgetItems);
}
use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.
the class WidgetsListAdapterTest method generateSampleMap.
/**
* Generates a list of sample widget entries.
*
* <p>Each sample app has 1 widget only. An app is represented by 2 entries,
* {@link WidgetsListHeaderEntry} & {@link WidgetsListContentEntry}. Only
* {@link WidgetsListHeaderEntry} is always visible in the {@link WidgetsListAdapter}.
* {@link WidgetsListContentEntry} is only shown upon clicking the corresponding app's
* {@link WidgetsListHeaderEntry}. Only at most one {@link WidgetsListContentEntry} is shown at
* a time.
*
* @param num the number of apps that have widgets.
*/
private ArrayList<WidgetsListBaseEntry> generateSampleMap(int num) {
ArrayList<WidgetsListBaseEntry> result = new ArrayList<>();
if (num <= 0)
return result;
for (int i = 0; i < num; i++) {
String packageName = TEST_PACKAGE_PLACEHOLDER + i;
List<WidgetItem> widgetItems = generateWidgetItems(packageName, /* numOfWidgets= */
1);
PackageItemInfo pInfo = new PackageItemInfo(packageName, widgetItems.get(0).user);
pInfo.title = pInfo.packageName;
pInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
result.add(new WidgetsListHeaderEntry(pInfo, /* titleSectionName= */
"", widgetItems));
result.add(new WidgetsListContentEntry(pInfo, /* titleSectionName= */
"", widgetItems));
}
return result;
}
use of com.android.launcher3.model.data.PackageItemInfo in project android_packages_apps_404Launcher by P-404.
the class WidgetsListTableViewHolderBinderTest method generateSampleAppWithWidgets.
private WidgetsListContentEntry generateSampleAppWithWidgets(String appName, String packageName, int numOfWidgets) {
PackageItemInfo appInfo = new PackageItemInfo(packageName, UserHandle.CURRENT);
appInfo.title = appName;
appInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
return new WidgetsListContentEntry(appInfo, /* titleSectionName= */
"", generateWidgetItems(packageName, numOfWidgets), Integer.MAX_VALUE);
}
Aggregations