示例#1
0
  private AccountManager() {
    this.application = Application.getInstance();
    accountItems = new HashMap<String, AccountItem>();
    enabledAccounts = new HashSet<String>();
    savedStatuses = new ArrayList<SavedStatus>();
    authorizationErrorProvider =
        new BaseAccountNotificationProvider<AccountAuthorizationError>(
            R.drawable.ic_stat_auth_failed);
    passwordRequestProvider =
        new BaseAccountNotificationProvider<PasswordRequest>(R.drawable.ic_stat_request);

    TypedArray accountAvatars =
        application.getResources().obtainTypedArray(R.array.account_avatars);
    colors = accountAvatars.length();
    accountAvatars.recycle();

    TypedArray types = application.getResources().obtainTypedArray(R.array.account_types);
    accountTypes = new ArrayList<AccountType>();
    for (int index = 0; index < types.length(); index++) {
      int id = types.getResourceId(index, 0);
      TypedArray values = application.getResources().obtainTypedArray(id);
      AccountProtocol protocol = AccountProtocol.valueOf(values.getString(0));
      if (Application.SDK_INT < 8 && protocol == AccountProtocol.wlm) {
        values.recycle();
        continue;
      }
      ArrayList<String> servers = new ArrayList<String>();
      servers.add(values.getString(9));
      for (int i = 10; i < values.length(); i++) servers.add(values.getString(i));
      accountTypes.add(
          new AccountType(
              id,
              protocol,
              values.getString(1),
              values.getString(2),
              values.getString(3),
              values.getDrawable(4),
              values.getBoolean(5, false),
              values.getString(6),
              values.getInt(7, 5222),
              values.getBoolean(8, false),
              servers));
      values.recycle();
    }
    types.recycle();
    away = false;
    xa = false;
  }