use of rocks.tbog.tblauncher.db.AppRecord in project TBLauncher by TBog.
the class AppsHandler method loadFromDB.
public void loadFromDB(boolean wait) {
Log.d(TAG, "loadFromDB(wait= " + wait + " )");
synchronized (this) {
mIsLoaded = false;
}
final Timer timer = Timer.startMilli();
final HashMap<String, AppEntry> apps = new HashMap<>();
final Runnable load = () -> {
TagsHandler tagsHandler = mApplication.tagsHandler();
Context context = getContext();
Map<String, AppRecord> dbApps = DBHelper.getAppsData(context);
apps.clear();
// convert from AppRecord to AppEntry
for (AppRecord rec : dbApps.values()) {
AppEntry appEntry = record2app(context, rec);
apps.put(appEntry.id, appEntry);
}
setTagsForApps(apps.values(), tagsHandler);
};
final Runnable apply = () -> {
synchronized (AppsHandler.this) {
mAppsCache.clear();
mAppsCache.putAll(apps);
mIsLoaded = true;
timer.stop();
Log.d("time", "Time to load all DB apps: " + timer);
// run and remove tasks
Runnable task;
while (null != (task = mAfterLoadedTasks.poll())) task.run();
}
};
if (wait) {
load.run();
apply.run();
} else
Utilities.runAsync((t) -> load.run(), (t) -> apply.run());
}
use of rocks.tbog.tblauncher.db.AppRecord in project TBLauncher by TBog.
the class IconsHandler method changeIcon.
public void changeIcon(AppEntry appEntry, Drawable drawable) {
Bitmap bitmap = getIconBitmap(ctx, drawable);
TBApplication app = TBApplication.getApplication(ctx);
AppRecord appRecord = app.getDataHandler().setCustomAppIcon(appEntry.getUserComponentName(), bitmap);
app.drawableCache().cacheDrawable(appEntry.getIconCacheId(), null);
appEntry.setCustomIcon(appRecord.dbId);
app.drawableCache().cacheDrawable(appEntry.getIconCacheId(), drawable);
}
Aggregations