mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
session: reuse removeAccount method for log out
The removeAccount method takes care of invoking the non-deprecated API in applicable API levels. The logout method did not do such a thing. Avoid redundancy, and reuse the removeAccount method for logging out.
This commit is contained in:
parent
1f6f186b98
commit
6aefc07a51
1 changed files with 9 additions and 7 deletions
|
|
@ -125,13 +125,15 @@ public class SessionManager {
|
|||
* Returns a Completable that clears existing accounts from account manager
|
||||
*/
|
||||
public Completable logout() {
|
||||
AccountManager accountManager = AccountManager.get(context);
|
||||
Account[] allAccounts = accountManager.getAccountsByType(BuildConfig.ACCOUNT_TYPE);
|
||||
return Completable.fromObservable(Observable.fromArray(allAccounts)
|
||||
.map(a -> accountManager.removeAccount(a, null, null).getResult()))
|
||||
.doOnComplete(() -> {
|
||||
currentAccount = null;
|
||||
});
|
||||
return Completable.fromObservable(
|
||||
Observable.empty()
|
||||
.doOnComplete(
|
||||
() -> {
|
||||
removeAccount();
|
||||
currentAccount = null;
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue