Search in sources :

Example 1 with LabelComparator

use of com.android.launcher3.util.LabelComparator in project android_packages_apps_Launcher3 by crdroidandroid.

the class AlphabeticalAppsList method onAppsUpdated.

/**
 * Updates internals when the set of apps are updated.
 */
@Override
public void onAppsUpdated() {
    // Sort the list of apps
    mApps.clear();
    for (AppInfo app : mAllAppsStore.getApps()) {
        if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
            mApps.add(app);
        }
    }
    Collections.sort(mApps, mAppNameComparator);
    // As a special case for some languages (currently only Simplified Chinese), we may need to
    // coalesce sections
    Locale curLocale = mLauncher.getResources().getConfiguration().locale;
    boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE);
    if (localeRequiresSectionSorting) {
        // Compute the section headers. We use a TreeMap with the section name comparator to
        // ensure that the sections are ordered when we iterate over it later
        TreeMap<String, ArrayList<AppInfo>> sectionMap = new TreeMap<>(new LabelComparator());
        for (AppInfo info : mApps) {
            // Add the section to the cache
            String sectionName = info.sectionName;
            // Add it to the mapping
            ArrayList<AppInfo> sectionApps = sectionMap.get(sectionName);
            if (sectionApps == null) {
                sectionApps = new ArrayList<>();
                sectionMap.put(sectionName, sectionApps);
            }
            sectionApps.add(info);
        }
        // Add each of the section apps to the list in order
        mApps.clear();
        for (Map.Entry<String, ArrayList<AppInfo>> entry : sectionMap.entrySet()) {
            mApps.addAll(entry.getValue());
        }
    }
    // Recompose the set of adapter items from the current set of apps
    if (mSearchResults == null) {
        updateAdapterItems();
    }
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) LabelComparator(com.android.launcher3.util.LabelComparator) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 2 with LabelComparator

use of com.android.launcher3.util.LabelComparator in project android_packages_apps_Launcher3 by AOSPA.

the class AlphabeticalAppsList method onAppsUpdated.

/**
 * Updates internals when the set of apps are updated.
 */
@Override
public void onAppsUpdated() {
    // Sort the list of apps
    mApps.clear();
    for (AppInfo app : mAllAppsStore.getApps()) {
        if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
            mApps.add(app);
        }
    }
    Collections.sort(mApps, mAppNameComparator);
    // As a special case for some languages (currently only Simplified Chinese), we may need to
    // coalesce sections
    Locale curLocale = mLauncher.getResources().getConfiguration().locale;
    boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE);
    if (localeRequiresSectionSorting) {
        // Compute the section headers. We use a TreeMap with the section name comparator to
        // ensure that the sections are ordered when we iterate over it later
        TreeMap<String, ArrayList<AppInfo>> sectionMap = new TreeMap<>(new LabelComparator());
        for (AppInfo info : mApps) {
            // Add the section to the cache
            String sectionName = info.sectionName;
            // Add it to the mapping
            ArrayList<AppInfo> sectionApps = sectionMap.get(sectionName);
            if (sectionApps == null) {
                sectionApps = new ArrayList<>();
                sectionMap.put(sectionName, sectionApps);
            }
            sectionApps.add(info);
        }
        // Add each of the section apps to the list in order
        mApps.clear();
        for (Map.Entry<String, ArrayList<AppInfo>> entry : sectionMap.entrySet()) {
            mApps.addAll(entry.getValue());
        }
    }
    // Recompose the set of adapter items from the current set of apps
    if (mSearchResults == null) {
        updateAdapterItems();
    }
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) LabelComparator(com.android.launcher3.util.LabelComparator) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 3 with LabelComparator

use of com.android.launcher3.util.LabelComparator in project android_packages_apps_Trebuchet by LineageOS.

the class AlphabeticalAppsList method onAppsUpdated.

/**
 * Updates internals when the set of apps are updated.
 */
@Override
public void onAppsUpdated() {
    // Sort the list of apps
    mApps.clear();
    for (AppInfo app : mAllAppsStore.getApps()) {
        if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
            mApps.add(app);
        }
    }
    Collections.sort(mApps, mAppNameComparator);
    // As a special case for some languages (currently only Simplified Chinese), we may need to
    // coalesce sections
    Locale curLocale = mLauncher.getResources().getConfiguration().locale;
    boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE);
    if (localeRequiresSectionSorting) {
        // Compute the section headers. We use a TreeMap with the section name comparator to
        // ensure that the sections are ordered when we iterate over it later
        TreeMap<String, ArrayList<AppInfo>> sectionMap = new TreeMap<>(new LabelComparator());
        for (AppInfo info : mApps) {
            // Add the section to the cache
            String sectionName = info.sectionName;
            // Add it to the mapping
            ArrayList<AppInfo> sectionApps = sectionMap.get(sectionName);
            if (sectionApps == null) {
                sectionApps = new ArrayList<>();
                sectionMap.put(sectionName, sectionApps);
            }
            sectionApps.add(info);
        }
        // Add each of the section apps to the list in order
        mApps.clear();
        for (Map.Entry<String, ArrayList<AppInfo>> entry : sectionMap.entrySet()) {
            mApps.addAll(entry.getValue());
        }
    }
    // Recompose the set of adapter items from the current set of apps
    updateAdapterItems();
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) LabelComparator(com.android.launcher3.util.LabelComparator) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 4 with LabelComparator

use of com.android.launcher3.util.LabelComparator in project Neo-Launcher by NeoApplications.

the class AlphabeticalAppsList method onAppsUpdated.

/**
 * Updates internals when the set of apps are updated.
 */
@Override
public void onAppsUpdated() {
    // Sort the list of apps
    mApps.clear();
    for (AppInfo app : mAllAppsStore.getApps()) {
        if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
            mApps.add(app);
        }
    }
    // Collections.sort(mApps, mAppNameComparator);
    Context context = mLauncher.getApplicationContext();
    OmegaPreferences prefs = Utilities.getOmegaPrefs(context);
    sortApps(prefs.getSortMode());
    // As a special case for some languages (currently only Simplified Chinese), we may need to
    // coalesce sections
    Locale curLocale = mLauncher.getResources().getConfiguration().locale;
    boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE);
    if (localeRequiresSectionSorting) {
        // Compute the section headers. We use a TreeMap with the section name comparator to
        // ensure that the sections are ordered when we iterate over it later
        TreeMap<String, ArrayList<AppInfo>> sectionMap = new TreeMap<>(new LabelComparator());
        for (AppInfo info : mApps) {
            // Add the section to the cache
            String sectionName = getAndUpdateCachedSectionName(info);
            // Add it to the mapping
            ArrayList<AppInfo> sectionApps = sectionMap.get(sectionName);
            if (sectionApps == null) {
                sectionApps = new ArrayList<>();
                sectionMap.put(sectionName, sectionApps);
            }
            sectionApps.add(info);
        }
        // Add each of the section apps to the list in order
        mApps.clear();
        for (Map.Entry<String, ArrayList<AppInfo>> entry : sectionMap.entrySet()) {
            mApps.addAll(entry.getValue());
        }
    }
    // Recompose the set of adapter items from the current set of apps
    updateAdapterItems();
}
Also used : Context(android.content.Context) Locale(java.util.Locale) ArrayList(java.util.ArrayList) LabelComparator(com.android.launcher3.util.LabelComparator) OmegaPreferences(com.saggitt.omega.OmegaPreferences) TreeMap(java.util.TreeMap) AppInfo(com.android.launcher3.AppInfo) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 5 with LabelComparator

use of com.android.launcher3.util.LabelComparator in project android_packages_apps_404Launcher by P-404.

the class AlphabeticalAppsList method onAppsUpdated.

/**
 * Updates internals when the set of apps are updated.
 */
@Override
public void onAppsUpdated() {
    // Sort the list of apps
    mApps.clear();
    for (AppInfo app : mAllAppsStore.getApps()) {
        if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
            mApps.add(app);
        }
    }
    Collections.sort(mApps, mAppNameComparator);
    // As a special case for some languages (currently only Simplified Chinese), we may need to
    // coalesce sections
    Locale curLocale = mLauncher.getResources().getConfiguration().locale;
    boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE);
    if (localeRequiresSectionSorting) {
        // Compute the section headers. We use a TreeMap with the section name comparator to
        // ensure that the sections are ordered when we iterate over it later
        TreeMap<String, ArrayList<AppInfo>> sectionMap = new TreeMap<>(new LabelComparator());
        for (AppInfo info : mApps) {
            // Add the section to the cache
            String sectionName = info.sectionName;
            // Add it to the mapping
            ArrayList<AppInfo> sectionApps = sectionMap.get(sectionName);
            if (sectionApps == null) {
                sectionApps = new ArrayList<>();
                sectionMap.put(sectionName, sectionApps);
            }
            sectionApps.add(info);
        }
        // Add each of the section apps to the list in order
        mApps.clear();
        for (Map.Entry<String, ArrayList<AppInfo>> entry : sectionMap.entrySet()) {
            mApps.addAll(entry.getValue());
        }
    }
    // Recompose the set of adapter items from the current set of apps
    if (mSearchResults == null) {
        updateAdapterItems();
    }
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) LabelComparator(com.android.launcher3.util.LabelComparator) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) AppInfo(com.android.launcher3.model.data.AppInfo)

Aggregations

LabelComparator (com.android.launcher3.util.LabelComparator)7 ArrayList (java.util.ArrayList)7 Locale (java.util.Locale)7 Map (java.util.Map)7 TreeMap (java.util.TreeMap)7 AppInfo (com.android.launcher3.model.data.AppInfo)6 Context (android.content.Context)1 AppInfo (com.android.launcher3.AppInfo)1 OmegaPreferences (com.saggitt.omega.OmegaPreferences)1 HashMap (java.util.HashMap)1