Add a method to know if an account is local or not

This commit is contained in:
Shinokuni 2019-07-30 15:48:59 +02:00
parent 5cf6089301
commit c540a5c57e
4 changed files with 7 additions and 3 deletions

View File

@ -190,7 +190,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
finish();
}
if (accountWeakReference.get() != null && !(accountWeakReference.get().getAccountType() == Account.AccountType.LOCAL)) {
if (accountWeakReference.get() != null && !accountWeakReference.get().isLocal()) {
refreshLayout.setRefreshing(true);
onRefresh();
accountWeakReference.clear();

View File

@ -228,6 +228,10 @@ public class Account implements Parcelable {
return new Credentials(login, password, url);
}
public boolean isLocal() {
return accountType == AccountType.LOCAL;
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj == null)

View File

@ -63,7 +63,7 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
});
credentialsPref.setOnPreferenceClickListener(preference -> {
if (account.getAccountType() != Account.AccountType.LOCAL) {
if (!account.isLocal()) {
Intent intent = new Intent(getContext(), AddAccountActivity.class);
intent.putExtra(AddAccountActivity.EDIT_ACCOUNT, account);
startActivity(intent);

View File

@ -238,7 +238,7 @@ public class MainViewModel extends AndroidViewModel {
}
public boolean isAccountLocal() {
return currentAccount.getAccountType() == Account.AccountType.LOCAL;
return currentAccount.isLocal();
}
//endregion