Fix crash from battery saver switch
Turns out most things expect the conditions to be loaded immediately so if the dashboard hasn't been hit, they crash. Instead load immediately for everything but the dashboard. Change-Id: Iaa1114c88b3766e2ac513acb417ef2a55a0f4e7f Fixes: 28952354
This commit is contained in:
@@ -54,10 +54,15 @@ public class ConditionManager {
|
||||
|
||||
private final ArrayList<ConditionListener> mListeners = new ArrayList<>();
|
||||
|
||||
private ConditionManager(Context context) {
|
||||
private ConditionManager(Context context, boolean loadConditionsNow) {
|
||||
mContext = context;
|
||||
mConditions = new ArrayList<>();
|
||||
new ConditionLoader().execute();
|
||||
if (loadConditionsNow) {
|
||||
ConditionLoader loader = new ConditionLoader();
|
||||
loader.onPostExecute(loader.doInBackground());
|
||||
} else {
|
||||
new ConditionLoader().execute();
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAll() {
|
||||
@@ -241,8 +246,12 @@ public class ConditionManager {
|
||||
}
|
||||
|
||||
public static ConditionManager get(Context context) {
|
||||
return get(context, true);
|
||||
}
|
||||
|
||||
public static ConditionManager get(Context context, boolean loadConditionsNow) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new ConditionManager(context.getApplicationContext());
|
||||
sInstance = new ConditionManager(context.getApplicationContext(), loadConditionsNow);
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
Reference in New Issue
Block a user