mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Tying LauncherAppState lifecycle with LauncherProvider
The content provider is the first component started with the main process, which makes it ideal for initiating LauncherAppState Change-Id: I03db82a8949ad1376af53a0033592f421dbf0b15
This commit is contained in:
@@ -171,7 +171,6 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
||||
|
||||
private static void queuePendingShortcutInfo(PendingInstallShortcutInfo info, Context context) {
|
||||
// Queue the item up for adding if launcher has not loaded properly yet
|
||||
LauncherAppState.setApplicationContext(context.getApplicationContext());
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
boolean launcherNotLoaded = app.getModel().getCallback() == null;
|
||||
|
||||
|
||||
@@ -417,7 +417,6 @@ public class Launcher extends Activity
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
LauncherAppState.setApplicationContext(getApplicationContext());
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
|
||||
// Load configuration-specific DeviceProfile
|
||||
|
||||
@@ -84,6 +84,10 @@ public class LauncherProvider extends ContentProvider {
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
final Context context = getContext();
|
||||
// The content provider exists for the entire duration of the launcher main process and
|
||||
// is the first component to get created. Initializing application context here ensures
|
||||
// that LauncherAppState always exists in the main process.
|
||||
LauncherAppState.setApplicationContext(context.getApplicationContext());
|
||||
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
|
||||
mOpenHelper = new DatabaseHelper(context);
|
||||
StrictMode.setThreadPolicy(oldPolicy);
|
||||
|
||||
@@ -22,8 +22,6 @@ import android.content.Intent;
|
||||
|
||||
public class WallpaperChangedReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent data) {
|
||||
LauncherAppState.setApplicationContext(context.getApplicationContext());
|
||||
LauncherAppState appState = LauncherAppState.getInstance();
|
||||
appState.onWallpaperChanged();
|
||||
LauncherAppState.getInstance().onWallpaperChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
||||
|
||||
PackageInstallerCompatVL(Context context) {
|
||||
mInstaller = context.getPackageManager().getPackageInstaller();
|
||||
LauncherAppState.setApplicationContext(context.getApplicationContext());
|
||||
mCache = LauncherAppState.getInstance().getIconCache();
|
||||
mWorker = new Handler(LauncherModel.getWorkerLooper());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user