summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java6
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java29
2 files changed, 22 insertions, 13 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
index c9a5f8f68606..e6fe447c8d98 100644
--- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
+++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
@@ -116,7 +116,7 @@ public class ApplicationsState {
final HandlerThread mThread;
final BackgroundHandler mBackgroundHandler;
- final MainHandler mMainHandler = new MainHandler();
+ final MainHandler mMainHandler = new MainHandler(Looper.getMainLooper());
private ApplicationsState(Application app) {
mContext = app;
@@ -687,6 +687,10 @@ public class ApplicationsState {
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();
diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java b/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java
index 581c810c7444..102e47ab1870 100644
--- a/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java
+++ b/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java
@@ -77,10 +77,7 @@ public class SettingsDrawerActivity extends Activity {
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);
@@ -109,19 +106,23 @@ public class SettingsDrawerActivity extends Activity {
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();
}
@@ -178,6 +179,10 @@ public class SettingsDrawerActivity extends Activity {
}
public List<DashboardCategory> getDashboardCategories() {
+ if (sDashboardCategories == null) {
+ sTileCache = new HashMap<>();
+ sDashboardCategories = TileUtils.getCategories(this, sTileCache);
+ }
return sDashboardCategories;
}