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;
}
};
}
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;
}
Aggregations