pull/125/head
M66B 6 years ago
parent 86c9bea815
commit deaa30a5f3

@ -711,10 +711,14 @@ public class FragmentAccount extends FragmentEx {
// Observe
DB.getInstance(getContext()).account().liveAccount(id).observe(getViewLifecycleOwner(), new Observer<EntityAccount>() {
boolean once = false;
private boolean once = false;
@Override
public void onChanged(@Nullable EntityAccount account) {
if (once)
return;
once = true;
// Get providers
List<Provider> providers = Provider.loadProfiles(getContext());
providers.add(0, new Provider(getString(R.string.title_select)));
@ -725,10 +729,6 @@ public class FragmentAccount extends FragmentEx {
spProvider.setAdapter(padapter);
if (savedInstanceState == null) {
if (once)
return;
once = true;
if (account != null) {
for (int pos = 2; pos < providers.size(); pos++)
if (providers.get(pos).imap_host.equals(account.host)) {

@ -146,7 +146,7 @@ public class FragmentFolder extends FragmentEx {
// Observe
DB.getInstance(getContext()).folder().liveFolder(id).observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
boolean once = false;
private boolean once = false;
@Override
public void onChanged(@Nullable EntityFolder folder) {
@ -155,11 +155,11 @@ public class FragmentFolder extends FragmentEx {
return;
}
if (savedInstanceState == null) {
if (once)
return;
once = true;
if (once)
return;
once = true;
if (savedInstanceState == null) {
cbSynchronize.setChecked(folder.synchronize);
cbUnified.setChecked(folder.unified);
etAfter.setText(Integer.toString(folder.after));

@ -134,6 +134,12 @@ public class FragmentIdentity extends FragmentEx {
Provider provider = (Provider) spProvider.getItemAtPosition(pos);
if (provider.imap_host.equals(account.host) && provider.imap_port == account.port) {
spProvider.setSelection(pos);
// This is needed because the spinner might be invisible
etHost.setText(provider.smtp_host);
etPort.setText(Integer.toString(provider.smtp_port));
cbStartTls.setChecked(provider.starttls);
break;
}
}
@ -396,15 +402,15 @@ public class FragmentIdentity extends FragmentEx {
// Observe identity
db.identity().liveIdentity(id).observe(getViewLifecycleOwner(), new Observer<EntityIdentity>() {
boolean once = false;
private boolean once = false;
@Override
public void onChanged(@Nullable final EntityIdentity identity) {
if (savedInstanceState == null) {
if (once)
return;
once = true;
if (once)
return;
once = true;
if (savedInstanceState == null) {
etName.setText(identity == null ? null : identity.name);
etEmail.setText(identity == null ? null : identity.email);
etReplyTo.setText(identity == null ? null : identity.replyto);
@ -433,8 +439,14 @@ public class FragmentIdentity extends FragmentEx {
db.account().liveAccounts().removeObservers(getViewLifecycleOwner());
db.account().liveAccounts().observe(getViewLifecycleOwner(), new Observer<List<EntityAccount>>() {
private boolean once = false;
@Override
public void onChanged(List<EntityAccount> accounts) {
if (once)
return;
once = true;
if (accounts == null)
accounts = new ArrayList<>();

Loading…
Cancel
Save