Search in sources :

Example 1 with WidgetItemComparator

use of com.android.launcher3.widget.WidgetItemComparator in project Neo-Launcher by NeoApplications.

the class WidgetsModel method getWidgetsList.

/**
 * Returns a list of {@link WidgetListRowEntry}. All {@link WidgetItem} in a single row
 * are sorted (based on label and user), but the overall list of {@link WidgetListRowEntry}s
 * is not sorted. This list is sorted at the UI when using
 * {@link com.android.launcher3.widget.WidgetsDiffReporter}
 *
 * @see com.android.launcher3.widget.WidgetsListAdapter#setWidgets(ArrayList)
 */
public synchronized ArrayList<WidgetListRowEntry> getWidgetsList(Context context) {
    ArrayList<WidgetListRowEntry> result = new ArrayList<>();
    AlphabeticIndexCompat indexer = new AlphabeticIndexCompat(context);
    WidgetItemComparator widgetComparator = new WidgetItemComparator();
    for (Map.Entry<PackageItemInfo, ArrayList<WidgetItem>> entry : mWidgetsList.entrySet()) {
        WidgetListRowEntry row = new WidgetListRowEntry(entry.getKey(), entry.getValue());
        row.titleSectionName = (row.pkgItem.title == null) ? "" : indexer.computeSectionName(row.pkgItem.title);
        Collections.sort(row.widgets, widgetComparator);
        result.add(row);
    }
    return result;
}
Also used : AlphabeticIndexCompat(com.android.launcher3.compat.AlphabeticIndexCompat) WidgetItemComparator(com.android.launcher3.widget.WidgetItemComparator) ArrayList(java.util.ArrayList) WidgetListRowEntry(com.android.launcher3.widget.WidgetListRowEntry) HashMap(java.util.HashMap) Map(java.util.Map) MultiHashMap(com.android.launcher3.util.MultiHashMap)

Example 2 with WidgetItemComparator

use of com.android.launcher3.widget.WidgetItemComparator in project android_packages_apps_Trebuchet by LineageOS.

the class WidgetsModel method getWidgetsList.

/**
 * Returns a list of {@link WidgetListRowEntry}. All {@link WidgetItem} in a single row
 * are sorted (based on label and user), but the overall list of {@link WidgetListRowEntry}s
 * is not sorted. This list is sorted at the UI when using
 * {@link com.android.launcher3.widget.WidgetsDiffReporter}
 *
 * @see com.android.launcher3.widget.WidgetsListAdapter#setWidgets(ArrayList)
 */
public synchronized ArrayList<WidgetListRowEntry> getWidgetsList(Context context) {
    ArrayList<WidgetListRowEntry> result = new ArrayList<>();
    AlphabeticIndexCompat indexer = new AlphabeticIndexCompat(context);
    WidgetItemComparator widgetComparator = new WidgetItemComparator();
    for (Map.Entry<PackageItemInfo, ArrayList<WidgetItem>> entry : mWidgetsList.entrySet()) {
        WidgetListRowEntry row = new WidgetListRowEntry(entry.getKey(), entry.getValue());
        row.titleSectionName = (row.pkgItem.title == null) ? "" : indexer.computeSectionName(row.pkgItem.title);
        Collections.sort(row.widgets, widgetComparator);
        result.add(row);
    }
    return result;
}
Also used : AlphabeticIndexCompat(com.android.launcher3.compat.AlphabeticIndexCompat) WidgetItemComparator(com.android.launcher3.widget.WidgetItemComparator) ArrayList(java.util.ArrayList) PackageItemInfo(com.android.launcher3.model.data.PackageItemInfo) WidgetListRowEntry(com.android.launcher3.widget.WidgetListRowEntry) HashMap(java.util.HashMap) Map(java.util.Map) MultiHashMap(com.android.launcher3.util.MultiHashMap)

Aggregations

AlphabeticIndexCompat (com.android.launcher3.compat.AlphabeticIndexCompat)2 MultiHashMap (com.android.launcher3.util.MultiHashMap)2 WidgetItemComparator (com.android.launcher3.widget.WidgetItemComparator)2 WidgetListRowEntry (com.android.launcher3.widget.WidgetListRowEntry)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)1