use of com.android.launcher3.widget.model.WidgetsListHeaderEntry in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListAdapter method shouldClearVisibleEntries.
/**
* Returns {@code true} if there is a change in {@link #mAllEntries} that results in an
* invalidation of {@link #mVisibleEntries}. e.g. there is change in the device language.
*/
private boolean shouldClearVisibleEntries() {
Map<PackageUserKey, PackageItemInfo> packagesInfo = mAllEntries.stream().filter(entry -> entry instanceof WidgetsListHeaderEntry).map(entry -> entry.mPkgItem).collect(Collectors.toMap(entry -> new PackageUserKey(entry.packageName, entry.user), entry -> entry));
for (WidgetsListBaseEntry visibleEntry : mVisibleEntries) {
PackageUserKey key = new PackageUserKey(visibleEntry.mPkgItem.packageName, visibleEntry.mPkgItem.user);
PackageItemInfo packageItemInfo = packagesInfo.get(key);
if (packageItemInfo != null && !visibleEntry.mPkgItem.title.equals(packageItemInfo.title)) {
return true;
}
}
return false;
}
use of com.android.launcher3.widget.model.WidgetsListHeaderEntry in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListHeader method applyIconAndLabel.
@UiThread
private void applyIconAndLabel(WidgetsListHeaderEntry entry) {
PackageItemInfo info = entry.mPkgItem;
setIcon(info);
setTitles(entry);
setExpanded(entry.isWidgetListShown());
super.setTag(info);
verifyHighRes();
}
use of com.android.launcher3.widget.model.WidgetsListHeaderEntry in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsModel method getWidgetsListForPicker.
/**
* Returns a list of {@link WidgetsListBaseEntry}. All {@link WidgetItem} in a single row
* are sorted (based on label and user), but the overall list of
* {@link WidgetsListBaseEntry}s is not sorted. This list is sorted at the UI when using
* {@link WidgetsDiffReporter}
*
* @see com.android.launcher3.widget.picker.WidgetsListAdapter#setWidgets(List)
*/
public synchronized ArrayList<WidgetsListBaseEntry> getWidgetsListForPicker(Context context) {
ArrayList<WidgetsListBaseEntry> result = new ArrayList<>();
AlphabeticIndexCompat indexer = new AlphabeticIndexCompat(context);
for (Map.Entry<PackageItemInfo, List<WidgetItem>> entry : mWidgetsList.entrySet()) {
PackageItemInfo pkgItem = entry.getKey();
List<WidgetItem> widgetItems = entry.getValue();
String sectionName = (pkgItem.title == null) ? "" : indexer.computeSectionName(pkgItem.title);
result.add(new WidgetsListHeaderEntry(pkgItem, sectionName, widgetItems));
result.add(new WidgetsListContentEntry(pkgItem, sectionName, widgetItems));
}
return result;
}
use of com.android.launcher3.widget.model.WidgetsListHeaderEntry in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListHeaderViewHolderBinderTest method bindViewHolder_shouldAttachOnHeaderClickListener.
@Test
public void bindViewHolder_shouldAttachOnHeaderClickListener() {
WidgetsListHeaderHolder viewHolder = mViewHolderBinder.newViewHolder(new FrameLayout(mTestActivity));
WidgetsListHeader widgetsListHeader = viewHolder.mWidgetsListHeader;
WidgetsListHeaderEntry entry = generateSampleAppHeader(APP_NAME, TEST_PACKAGE, /* numOfWidgets= */
3);
mViewHolderBinder.bindViewHolder(viewHolder, entry, /* position= */
0);
widgetsListHeader.callOnClick();
verify(mOnHeaderClickListener).onHeaderClicked(eq(true), eq(new PackageUserKey(entry.mPkgItem.packageName, entry.mPkgItem.user)));
}
use of com.android.launcher3.widget.model.WidgetsListHeaderEntry in project android_packages_apps_Launcher3 by crdroidandroid.
the class SimpleWidgetsSearchAlgorithmTest 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);
}
Aggregations