Search in sources :

Example 1 with ShortcutInfo

use of org.adw.launcher2.ShortcutInfo in project ADWLauncher2 by boombuler.

the class Preferences method getLaunchCountComparator.

private Comparator<IconItemInfo> getLaunchCountComparator() {
    final AppDB myAppDB = mLauncher.getAppDB();
    return new Comparator<IconItemInfo>() {

        @Override
        public int compare(IconItemInfo a, IconItemInfo b) {
            int valA = Integer.MAX_VALUE;
            int valB = Integer.MAX_VALUE;
            if (a instanceof ShortcutInfo)
                valA = myAppDB.getLaunchCounter((ShortcutInfo) a);
            if (b instanceof ShortcutInfo)
                valB = myAppDB.getLaunchCounter((ShortcutInfo) b);
            return valB - valA;
        }
    };
}
Also used : ShortcutInfo(org.adw.launcher2.ShortcutInfo) AppDB(org.adw.launcher2.appdb.AppDB) IconItemInfo(org.adw.launcher2.IconItemInfo) Comparator(java.util.Comparator)

Example 2 with ShortcutInfo

use of org.adw.launcher2.ShortcutInfo in project ADWLauncher2 by boombuler.

the class AppDB method getApps.

public List<ShortcutInfo> getApps(long[] appIds) {
    ArrayList<ShortcutInfo> result = new ArrayList<ShortcutInfo>();
    ContentResolver cr = mContext.getContentResolver();
    Cursor c = cr.query(AppInfos.CONTENT_URI, new String[] { AppInfos.ID, AppInfos.COMPONENT_NAME, AppInfos.ICON, AppInfos.ICON_CHANGED, AppInfos.TITLE, AppInfos.TITLE_CHANGED, AppInfos.LAST_LAUNCHED, AppInfos.LAUNCH_COUNT }, getAppIdFilter(appIds), null, null);
    try {
        c.moveToFirst();
        final int idIdx = c.getColumnIndex(AppInfos.ID);
        final int iconIdx = c.getColumnIndex(AppInfos.ICON);
        final int iconChangedIdx = c.getColumnIndex(AppInfos.ICON_CHANGED);
        final int cnIdx = c.getColumnIndex(AppInfos.COMPONENT_NAME);
        final int titleIdx = c.getColumnIndex(AppInfos.TITLE);
        final int titleChangedIdx = c.getColumnIndex(AppInfos.TITLE_CHANGED);
        final int launchcntIdx = c.getColumnIndex(AppInfos.LAUNCH_COUNT);
        final int lastlaunchIdx = c.getColumnIndex(AppInfos.LAST_LAUNCHED);
        while (!c.isAfterLast()) {
            Bitmap icon = getIconFromCursor(c, iconIdx);
            String cnStr = c.getString(cnIdx);
            String title = c.getString(titleIdx);
            if (mLaunchInfos.containsKey(cnStr))
                mLaunchInfos.remove(cnStr);
            mLaunchInfos.put(cnStr, new LaunchInfo((int) c.getLong(launchcntIdx), c.getLong(lastlaunchIdx)));
            ComponentName cname = ComponentName.unflattenFromString(cnStr);
            if (mIconCache != null)
                mIconCache.addToCache(cname, title, icon);
            ShortcutInfo info = new ShortcutInfo(c.getLong(idIdx), cname);
            info.setTitleInAppsDb(c.getInt(titleChangedIdx) == 1);
            info.setIconInAppsDb(c.getInt(iconChangedIdx) == 1);
            result.add(info);
            c.moveToNext();
        }
    } finally {
        c.close();
    }
    return result;
}
Also used : Bitmap(android.graphics.Bitmap) ShortcutInfo(org.adw.launcher2.ShortcutInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver)

Aggregations

ShortcutInfo (org.adw.launcher2.ShortcutInfo)2 ComponentName (android.content.ComponentName)1 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 IconItemInfo (org.adw.launcher2.IconItemInfo)1 AppDB (org.adw.launcher2.appdb.AppDB)1