final HandlerThread mThread;
final BackgroundHandler mBackgroundHandler;
- final MainHandler mMainHandler = new MainHandler();
+ final MainHandler mMainHandler = new MainHandler(Looper.getMainLooper());
private ApplicationsState(Application app) {
mContext = app;
static final int MSG_LAUNCHER_INFO_CHANGED = 7;
static final int MSG_LOAD_ENTRIES_COMPLETE = 8;
+ public MainHandler(Looper looper) {
+ super(looper);
+ }
+
@Override
public void handleMessage(Message msg) {
rebuildActiveSessions();
mDrawerLayout = null;
return;
}
- if (sDashboardCategories == null) {
- sTileCache = new HashMap<>();
- sDashboardCategories = TileUtils.getCategories(this, sTileCache);
- }
+ getDashboardCategories();
setActionBar(toolbar);
mDrawerAdapter = new SettingsDrawerAdapter(this);
ListView listView = (ListView) findViewById(R.id.left_drawer);
protected void onResume() {
super.onResume();
- final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
- filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
- filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
- filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
- filter.addDataScheme("package");
- registerReceiver(mPackageReceiver, filter);
+ if (mDrawerLayout != null) {
+ final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
+ filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+ filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
+ filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
+ filter.addDataScheme("package");
+ registerReceiver(mPackageReceiver, filter);
- new CategoriesUpdater().execute();
+ new CategoriesUpdater().execute();
+ }
}
@Override
protected void onPause() {
- unregisterReceiver(mPackageReceiver);
+ if (mDrawerLayout != null) {
+ unregisterReceiver(mPackageReceiver);
+ }
super.onPause();
}
}
public List<DashboardCategory> getDashboardCategories() {
+ if (sDashboardCategories == null) {
+ sTileCache = new HashMap<>();
+ sDashboardCategories = TileUtils.getCategories(this, sTileCache);
+ }
return sDashboardCategories;
}