use of com.android.launcher3.widget.picker.WidgetsDiffReporter 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.picker.WidgetsDiffReporter in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsDiffReporterTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mTestProfile = new InvariantDeviceProfile();
mTestProfile.numRows = 5;
mTestProfile.numColumns = 5;
doAnswer(invocation -> ((ComponentWithLabel) invocation.getArgument(0)).getComponent().getPackageName()).when(mIconCache).getTitleNoCache(any());
mContext = RuntimeEnvironment.application;
mWidgetsDiffReporter = new WidgetsDiffReporter(mIconCache, mAdapter);
mHeaderA = createWidgetsHeaderEntry(TEST_PACKAGE_PREFIX + "A", /* appName= */
"A", /* numOfWidgets= */
3);
mHeaderB = createWidgetsHeaderEntry(TEST_PACKAGE_PREFIX + "B", /* appName= */
"B", /* numOfWidgets= */
3);
mHeaderC = createWidgetsHeaderEntry(TEST_PACKAGE_PREFIX + "C", /* appName= */
"C", /* numOfWidgets= */
3);
mContentC = createWidgetsContentEntry(TEST_PACKAGE_PREFIX + "C", /* appName= */
"C", /* numOfWidgets= */
3);
mHeaderD = createWidgetsHeaderEntry(TEST_PACKAGE_PREFIX + "D", /* appName= */
"D", /* numOfWidgets= */
3);
mHeaderE = createWidgetsHeaderEntry(TEST_PACKAGE_PREFIX + "E", /* appName= */
"E", /* numOfWidgets= */
3);
mContentE = createWidgetsContentEntry(TEST_PACKAGE_PREFIX + "E", /* appName= */
"E", /* numOfWidgets= */
3);
}
Aggregations