app/src/main/java/org/andstatus/app/account/MyAccounts.java
/**
     * Find persistent MyAccount by accountName in local cache AND
     * in Android AccountManager
     *
     * @return Invalid account if was not found
     */
Find persistent MyAccount by accountName in local cache AND
in Android AccountManager

@return Invalid account if was not found
Find persistent MyAccount by accountName in local cache AND in Android AccountManager @return Invalid account if was not found
@NonNull
    public MyAccount fromAccountName(AccountName accountName) {
        if (accountName == null || !accountName.isValid) return MyAccount.EMPTY;
        for (MyAccount persistentAccount : myAccounts) {
            if (persistentAccount.getAccountName().equals(accountName.getName())) {
                return persistentAccount;
            }
        }
        for (android.accounts.Account androidAccount : AccountUtils.getCurrentAccounts(myContext.context())) {
            if (accountName.toString().equals(androidAccount.name)) {
                MyAccount myAccount = Builder.loadFromAndroidAccount(myContext, androidAccount).getAccount();
                if (myAccount.isValid()) {
                    myAccounts.add(myAccount);
                }
                MyPreferences.onPreferencesChanged();
                return myAccount;
            }
        }
        return MyAccount.EMPTY;
    }
@ NonNull public MyAccount fromAccountName ( AccountName accountName ) { if ( accountName == null || ! accountName . isValid ) return MyAccount . EMPTY ; for ( MyAccount persistentAccount : myAccounts ) { if ( persistentAccount . getAccountName ( ) . equals ( accountName . getName ( ) ) ) { return persistentAccount ; } } for ( android . accounts . Account androidAccount : AccountUtils . getCurrentAccounts ( myContext . context ( ) ) ) { if ( accountName . toString ( ) . equals ( androidAccount . name ) ) { MyAccount myAccount = Builder . loadFromAndroidAccount ( myContext , androidAccount ) . getAccount ( ) ; if ( myAccount . isValid ( ) ) { myAccounts . add ( myAccount ) ; } MyPreferences . onPreferencesChanged ( ) ; return myAccount ; } } return MyAccount . EMPTY ; }
Find persistent MyAccount by accountName in local cache AND
 in Android AccountManager
Find persistent MyAccount by accountName in local cache AND in Android AccountManager