mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 03:19:24 +01:00
Moved observers and loaders to onActivityCreate
This commit is contained in:
@@ -114,7 +114,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
String theme = prefs.getString("theme" , "light");
|
||||
String theme = prefs.getString("theme", "light");
|
||||
boolean dark = "dark".equals(theme);
|
||||
cbDarkTheme.setTag(dark);
|
||||
cbDarkTheme.setChecked(dark);
|
||||
@@ -124,16 +124,16 @@ public class FragmentSetup extends FragmentEx {
|
||||
if (checked != (Boolean) button.getTag()) {
|
||||
button.setTag(checked);
|
||||
cbDarkTheme.setChecked(checked);
|
||||
prefs.edit().putString("theme" , checked ? "dark" : "light").apply();
|
||||
prefs.edit().putString("theme", checked ? "dark" : "light").apply();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cbDebug.setChecked(prefs.getBoolean("debug" , false));
|
||||
cbDebug.setChecked(prefs.getBoolean("debug", false));
|
||||
cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("debug" , checked).apply();
|
||||
prefs.edit().putBoolean("debug", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -145,22 +145,6 @@ public class FragmentSetup extends FragmentEx {
|
||||
tvIdentityDone.setVisibility(View.INVISIBLE);
|
||||
tvPermissionsDone.setVisibility(View.INVISIBLE);
|
||||
|
||||
final DB db = DB.getInstance(getContext());
|
||||
|
||||
db.account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
||||
tvAccountDone.setVisibility(accounts.size() > 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
db.identity().liveIdentities(true).observe(this, new Observer<List<EntityIdentity>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityIdentity> identities) {
|
||||
tvIdentityDone.setVisibility(identities.size() > 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
int[] grantResults = new int[permissions.length];
|
||||
for (int i = 0; i < permissions.length; i++)
|
||||
grantResults[i] = ContextCompat.checkSelfPermission(getActivity(), permissions[i]);
|
||||
@@ -171,6 +155,7 @@ public class FragmentSetup extends FragmentEx {
|
||||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DB db = DB.getInstance(getContext());
|
||||
EntityFolder outbox = db.folder().getOutbox();
|
||||
if (outbox == null) {
|
||||
outbox = new EntityFolder();
|
||||
@@ -186,6 +171,27 @@ public class FragmentSetup extends FragmentEx {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
DB db = DB.getInstance(getContext());
|
||||
|
||||
db.account().liveAccounts(true).observe(this, new Observer<List<EntityAccount>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
||||
tvAccountDone.setVisibility(accounts.size() > 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
db.identity().liveIdentities(true).observe(this, new Observer<List<EntityIdentity>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<EntityIdentity> identities) {
|
||||
tvIdentityDone.setVisibility(identities.size() > 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
boolean has = (grantResults.length > 0);
|
||||
|
||||
Reference in New Issue
Block a user