Search in sources :

Example 1 with AppCountInfo

use of com.saggitt.omega.model.AppCountInfo in project Neo-Launcher by NeoApplications.

the class DbHelper method getAppsCount.

public List<AppCountInfo> getAppsCount() {
    List<AppCountInfo> apps = new ArrayList<>();
    String SQL_QUERY = "SELECT package_name, package_count FROM app_count;";
    Cursor cursor = db.rawQuery(SQL_QUERY, null);
    if (!cursor.moveToFirst()) {
        return apps;
    }
    do {
        String name = cursor.getString(0);
        int count = cursor.getInt(1);
        apps.add(new AppCountInfo(name, count));
    } while (cursor.moveToNext());
    cursor.close();
    return apps;
}
Also used : AppCountInfo(com.saggitt.omega.model.AppCountInfo) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 2 with AppCountInfo

use of com.saggitt.omega.model.AppCountInfo in project Neo-Launcher by NeoApplications.

the class AlphabeticalAppsList method sortApps.

private void sortApps(int sortType) {
    switch(sortType) {
        // SORT BY NAME AZ
        case SORT_AZ:
            Collections.sort(mApps, mAppNameComparator);
            break;
        // SORT BY NAME ZA
        case SORT_ZA:
            Collections.sort(mApps, (p2, p1) -> Collator.getInstance().compare(p1.title, p2.title));
            break;
        // SORT BY LAST INSTALLED
        case SORT_LAST_INSTALLED:
            PackageManager pm = mLauncher.getApplicationContext().getPackageManager();
            InstallTimeComparator installTimeComparator = new InstallTimeComparator(pm);
            Collections.sort(mApps, installTimeComparator);
            break;
        // SORT BY MOST USED DESC
        case SORT_MOST_USED:
            DbHelper db = new DbHelper(mLauncher.getApplicationContext());
            List<AppCountInfo> appsCounter = db.getAppsCount();
            db.close();
            MostUsedComparator mostUsedComparator = new MostUsedComparator(appsCounter);
            Collections.sort(mApps, mostUsedComparator);
            break;
        case SORT_BY_COLOR:
            Collections.sort(mApps, mAppColorComparator);
            break;
        default:
            Collections.sort(mApps, mAppNameComparator);
            break;
    }
}
Also used : InstallTimeComparator(com.saggitt.omega.allapps.InstallTimeComparator) PackageManager(android.content.pm.PackageManager) AppCountInfo(com.saggitt.omega.model.AppCountInfo) MostUsedComparator(com.saggitt.omega.allapps.MostUsedComparator) DbHelper(com.saggitt.omega.util.DbHelper)

Aggregations

AppCountInfo (com.saggitt.omega.model.AppCountInfo)2 PackageManager (android.content.pm.PackageManager)1 Cursor (android.database.Cursor)1 InstallTimeComparator (com.saggitt.omega.allapps.InstallTimeComparator)1 MostUsedComparator (com.saggitt.omega.allapps.MostUsedComparator)1 DbHelper (com.saggitt.omega.util.DbHelper)1 ArrayList (java.util.ArrayList)1