Java 类android.accounts.OnAccountsUpdateListener 实例源码

项目:FMTech    文件:FinskyDrawerLayout.java   
public FinskyDrawerLayout(final Context paramContext, AttributeSet paramAttributeSet)
{
  super(paramContext, paramAttributeSet);
  this.mAccountManager = AccountManager.get(paramContext);
  this.mOnAccountsUpdateListener = new OnAccountsUpdateListener()
  {
    public final void onAccountsUpdated(Account[] paramAnonymousArrayOfAccount)
    {
      Utils.syncDebugActivityStatus(paramContext);
      FinskyDrawerLayout.this.refresh();
    }
  };
  this.mCurrentBackendId = 0;
  this.mRefreshRunnable = new Runnable()
  {
    public final void run()
    {
      FinskyDrawerLayout.this.refresh();
    }
  };
  this.mRefreshHandler = new Handler(Looper.myLooper());
}
项目:moVirt    文件:AccountManagerHelper.java   
/**
 * This method should be called only from Singletons so the lifecycle
 * is tied with the application, so we don't have to cleanup the listeners
 *
 * @param callback to be called on accounts updated
 */
public void addOnAccountsUpdatedListener(OnAccountsUpdatedListener callback) {
    try {
        OnAccountsUpdateListener listener = accounts -> {
            Set<MovirtAccount> filtered = new HashSet<>();
            for (Account account : accounts) {
                if (Constants.ACCOUNT_TYPE.equals(account.type)) {
                    try {
                        filtered.add(asMoAccount(account));
                    } catch (IllegalStateException incompatibleAccount) {
                        removeAccount(new MovirtAccount("", account), null); // remove old account
                    }
                }
            }
            callback.onAccountsUpdated(filtered);
        };

        accountManager.addOnAccountsUpdatedListener(listener, null, true);
    } catch (SecurityException e) {
        commonMessageHelper.showError(ErrorType.NORMAL, resources.getMissingAccountsPermissionError());
    }
}
项目:FullRobolectricTestSample    文件:ShadowAccountManager.java   
@Implementation
public void addOnAccountsUpdatedListener(final OnAccountsUpdateListener listener,
    Handler handler, boolean updateImmediately) {

  if (listeners.contains(listener)) {
    return;
  }

  listeners.add(listener);

  if (updateImmediately) {
    listener.onAccountsUpdated(getAccounts());
  }
}
项目:FullRobolectricTestSample    文件:ShadowAccountManager.java   
private void notifyListeners() {
  Account[] accounts = getAccounts();
  Iterator<OnAccountsUpdateListener> iter = listeners.iterator();
  OnAccountsUpdateListener listener;
  while (iter.hasNext()) {
    listener = iter.next();
    listener.onAccountsUpdated(accounts);
  }
}
项目:XPrivacy    文件:XAccountManager.java   
public XOnAccountsUpdateListener(OnAccountsUpdateListener listener, int uid) {
    mListener = listener;
    mUid = uid;
}
项目:smarper    文件:XAccountManager.java   
public XOnAccountsUpdateListener(OnAccountsUpdateListener listener, int uid) {
    mListener = listener;
    mUid = uid;
}
项目:xprivacy-mod    文件:XAccountManager.java   
public XOnAccountsUpdateListener(OnAccountsUpdateListener listener, int uid) {
    mListener = listener;
    mUid = uid;
}
项目:Chatting-App-    文件:Kontalk.java   
@Override
public void onCreate() {
    super.onCreate();
    mHandler = new Handler();

    // init preferences
    Preferences.init(this);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mPrefChangedListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
            // no account - abort
            if (Authenticator.getDefaultAccount(Kontalk.this) == null)
                return;

            // manual server address
            if ("pref_network_uri".equals(key)) {
                // just restart the message center for now
                android.util.Log.w(TAG, "network address changed");
                MessageCenterService.restart(Kontalk.this);
            }

            // hide presence flag / encrypt user data flag
            else if ("pref_hide_presence".equals(key) || "pref_encrypt_userdata".equals(key)) {
                MessageCenterService.updateStatus(Kontalk.this);
            }

            // changing remove prefix
            else if ("pref_remove_prefix".equals(key)) {
                SyncAdapter.requestSync(getApplicationContext(), true);
            }
        }
    };
    prefs.registerOnSharedPreferenceChangeListener(mPrefChangedListener);

    // TODO listen for changes to phone numbers

    Account account = Authenticator.getDefaultAccount(this);
    if (account != null) {
        // update notifications from locally unread messages
        MessagingNotification.updateMessagesNotification(this, false);

        // register account change listener
        final OnAccountsUpdateListener listener = new OnAccountsUpdateListener() {
            @Override
            public void onAccountsUpdated(Account[] accounts) {
                Account my = null;
                for (int i = 0; i < accounts.length; i++) {
                    if (accounts[i].type.equals(Authenticator.ACCOUNT_TYPE)) {
                        my = accounts[i];
                        break;
                    }
                }

                // account removed!!! Shutdown everything.
                if (my == null) {
                    Log.w(TAG, "my account has been removed, shutting down");
                    // delete all messages
                    MessagesProvider.deleteDatabase(Kontalk.this);
                    // stop message center
                    MessageCenterService.stop(Kontalk.this);
                    // invalidate cached personal key
                    invalidatePersonalKey();
                }
            }
        };

        AccountManager am = AccountManager.get(this);

        // register listener to handle account removal
        am.addOnAccountsUpdatedListener(listener, mHandler, true);
    }

    // enable/disable components
    setServicesEnabled(this, account != null);
}
项目:ImapNote2    文件:Listactivity.java   
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Accounts spinner
this.accountSpinner = (Spinner) findViewById(R.id.accountSpinner);
Listactivity.currentList = new ArrayList<String>();
// Spinner item selection Listener
this.accountSpinner.setOnItemSelectedListener(this);

imapNotes2Account = new ImapNotes2Account();
Listactivity.accountManager = AccountManager.get(getApplicationContext());
Listactivity.accountManager.addOnAccountsUpdatedListener((OnAccountsUpdateListener)
    new AccountsUpdateListener(), null, true);

status = (TextView)findViewById(R.id.status);

this.spinnerList = new ArrayAdapter<String>
    (this, android.R.layout.simple_spinner_item,Listactivity.currentList);
spinnerList.setDropDownViewResource
    (android.R.layout.simple_spinner_dropdown_item);
this.accountSpinner.setAdapter(spinnerList);

this.noteList = new ArrayList<OneNote>();
((ImapNotes2)this.getApplicationContext()).SetNotesList(this.noteList);
this.listToView = new NotesListAdapter(
    getApplicationContext(),
    this.noteList,
    R.layout.note_element,
    new String[]{"title","date"},
    new int[]{R.id.noteTitle, R.id.noteInformation});
listview = (ListView) findViewById(R.id.notesList);
listview.setAdapter(this.listToView);

listview.setTextFilterEnabled(true);

this.imapFolder = new Imaper();
((ImapNotes2)this.getApplicationContext()).SetImaper(this.imapFolder);

if (Listactivity.storedNotes == null)
    storedNotes = new NotesDb(getApplicationContext());

// When item is clicked, we go to NoteDetailActivity
listview.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> arg0, View widget, int selectedNote, long arg3) {
        Intent toDetail = new Intent(widget.getContext(), NoteDetailActivity.class);
        toDetail.putExtra("selectedNote", (OneNote)arg0.getItemAtPosition(selectedNote));
        toDetail.putExtra("useSticky", Listactivity.imapNotes2Account.GetUsesticky());
        startActivityForResult(toDetail,SEE_DETAIL); 
    }
  });

  editAccountButton = (Button) findViewById(R.id.editAccountButton);
  editAccountButton.setOnClickListener(clickListenerEditAccount);

}