use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsListContentEntryTest method equals_entriesWithSameContents_returnTrue.
@Test
public void equals_entriesWithSameContents_returnTrue() {
WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
2, /* spanY= */
3);
WidgetsListContentEntry widgetsListRowEntry1 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
WidgetsListContentEntry widgetsListRowEntry2 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
assertThat(widgetsListRowEntry1.equals(widgetsListRowEntry2)).isTrue();
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by AOSPA.
the class WidgetsListContentEntryTest method equals_entriesWithDifferentMaxSpanSize_returnFalse.
@Test
public void equals_entriesWithDifferentMaxSpanSize_returnFalse() {
WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
2, /* spanY= */
3);
WidgetsListContentEntry widgetsListRowEntry1 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
WidgetsListContentEntry widgetsListRowEntry2 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
2);
assertThat(widgetsListRowEntry1.equals(widgetsListRowEntry2)).isFalse();
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by AOSPA.
the class WidgetsListContentEntryTest method equals_entriesWithDifferentPackageItemInfo_returnFalse.
@Test
public void equals_entriesWithDifferentPackageItemInfo_returnFalse() {
WidgetItem widgetItem1 = createWidgetItem(mWidget1, /* spanX= */
2, /* spanY= */
3);
WidgetsListContentEntry widgetsListRowEntry1 = new WidgetsListContentEntry(mPackageItemInfo1, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
WidgetsListContentEntry widgetsListRowEntry2 = new WidgetsListContentEntry(mPackageItemInfo2, /* titleSectionName= */
"T", List.of(widgetItem1), /* maxSpanSizeInCells= */
3);
assertThat(widgetsListRowEntry1.equals(widgetsListRowEntry2)).isFalse();
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by AOSPA.
the class SimpleWidgetsSearchAlgorithm method getFilteredWidgets.
/**
* Returns entries for all matched widgets
*/
public static ArrayList<WidgetsListBaseEntry> getFilteredWidgets(PopupDataProvider dataProvider, String input) {
ArrayList<WidgetsListBaseEntry> results = new ArrayList<>();
dataProvider.getAllWidgets().stream().filter(entry -> entry instanceof WidgetsListHeaderEntry).forEach(headerEntry -> {
List<WidgetItem> matchedWidgetItems = filterWidgetItems(input, headerEntry.mPkgItem.title.toString(), headerEntry.mWidgets);
if (matchedWidgetItems.size() > 0) {
results.add(new WidgetsListSearchHeaderEntry(headerEntry.mPkgItem, headerEntry.mTitleSectionName, matchedWidgetItems));
results.add(new WidgetsListContentEntry(headerEntry.mPkgItem, headerEntry.mTitleSectionName, matchedWidgetItems));
}
});
return results;
}
use of com.android.launcher3.widget.model.WidgetsListContentEntry in project android_packages_apps_Launcher3 by AOSPA.
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;
}
Aggregations