Exemplo n.º 1
0
 private void setAccountType(String name, AccountType bankType) throws JSONException {
   if (name.equals("zfb")) {
     bankType.setToAction(true);
   } else if (name.equals("lthj")) {
     bankType.setToAction(false);
   }
 }
Exemplo n.º 2
0
  public List<AccountName> getList(JSONArray jsonArray) {
    List<AccountName> listName = new ArrayList<AccountName>();

    for (int i = 0; i < jsonArray.length(); i++) {
      AccountName bankName = new AccountName();
      try {
        JSONObject json = jsonArray.getJSONObject(i);
        bankName.setBankName(json.getString("bankname"));
        // Log.e("json.isNull===",""+json.isNull("creditCard"));
        if (!json.isNull("creditCard")) { // 信用卡
          AccountType bankType = new AccountType();
          bankType.setName("信用卡");
          setAccountType(json.getString("creditCard"), bankType);
          bankName.getBankType().add(bankType);
        }
        if (!json.isNull("debitCard")) { // 借记卡
          AccountType bankType = new AccountType();
          bankType.setName("借记卡");
          setAccountType(json.getString("debitCard"), bankType);
          bankName.getBankType().add(bankType);
        }
      } catch (JSONException e) {
        e.printStackTrace();
      }
      listName.add(bankName);
    }

    return listName;
  }
Exemplo n.º 3
0
 public static Account readFrom(JsonObject json) {
   Account ret = new Account();
   ret.setBalance(json.get("balance").getAsBigDecimal());
   ret.setCustomerId(json.get("customerId").getAsInt());
   ret.setId(json.get("id").getAsInt());
   ret.setType(AccountType.valueOf(json.get("type").getAsString()));
   return ret;
 }
Exemplo n.º 4
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + id;
   result = prime * result + customerId;
   result = prime * result + ((type == null) ? 0 : type.hashCode());
   result = prime * result + ((balance == null) ? 0 : balance.hashCode());
   return result;
 }
Exemplo n.º 5
0
  private void initTypeSpinner(final List<AccountType> listType) {
    final Spinner type_brank = (Spinner) findViewById(R.id.account_spinner_bank_stye);

    // TextView dnaRemind = (TextView)findViewById(R.id.TextView07);
    allcountries = new ArrayList<String>();
    if (listType != null && listType.size() > 0) {
      for (AccountType bankType : listType) {
        allcountries.add(bankType.getName());
      }
    }
    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, allcountries);
    adapter.setDropDownViewResource(R.layout.myspinner_dropdown);
    type_brank.setAdapter(adapter);
    type_brank.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
            isAlipay = listType.get(position).getToAction();
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });
  }
Exemplo n.º 6
0
 public void setType(int type) {
   this.type = AccountType.values()[type];
 }
Exemplo n.º 7
0
 public int getIntType() {
   return type.ordinal();
 }
Exemplo n.º 8
0
  /**
   * Creates new account.
   *
   * @param user full or bare jid.
   * @param password
   * @param accountType xmpp account type can be replaced depend on server part.
   * @param syncable
   * @param storePassword
   * @param useOrbot
   * @return assigned account name.
   * @throws NetworkException if user or server part are invalid.
   */
  public String addAccount(
      String user,
      String password,
      AccountType accountType,
      boolean syncable,
      boolean storePassword,
      boolean useOrbot)
      throws NetworkException {
    if (accountType.getProtocol().isOAuth()) {
      int index = 1;
      while (true) {
        user = String.valueOf(index);
        boolean found = false;
        for (AccountItem accountItem : accountItems.values())
          if (accountItem
                  .getConnectionSettings()
                  .getServerName()
                  .equals(accountType.getFirstServer())
              && accountItem.getConnectionSettings().getUserName().equals(user)) {
            found = true;
            break;
          }
        if (!found) break;
        index++;
      }
    }

    if (user == null) throw new NetworkException(R.string.EMPTY_USER_NAME);

    if (user.indexOf("@") == -1) {
      if ("".equals(accountType.getFirstServer()))
        throw new NetworkException(R.string.EMPTY_SERVER_NAME);
      else user += "@" + accountType.getFirstServer();
    }

    String serverName = StringUtils.parseServer(user);
    String userName = StringUtils.parseName(user);
    String resource = StringUtils.parseResource(user);
    String host = accountType.getHost();
    int port = accountType.getPort();
    boolean tlsRequired = accountType.isTLSRequired();
    if (useOrbot) tlsRequired = true;

    if ("".equals(serverName)) {
      throw new NetworkException(R.string.EMPTY_SERVER_NAME);
    } else if (!accountType.isAllowServer() && !serverName.equals(accountType.getFirstServer()))
      throw new NetworkException(R.string.INCORRECT_USER_NAME);

    if ("".equals(userName)) throw new NetworkException(R.string.EMPTY_USER_NAME);
    if ("".equals(resource)) resource = "android" + StringUtils.randomString(8);

    if (accountType.getId() == R.array.account_type_xmpp) {
      host = serverName;
      for (AccountType check : accountTypes)
        if (check.getServers().contains(serverName)) {
          accountType = check;
          host = check.getHost();
          port = check.getPort();
          tlsRequired = check.isTLSRequired();
          break;
        }
    }

    AccountItem accountItem;
    for (; ; ) {
      if (getAccount(userName + '@' + serverName + '/' + resource) == null) break;
      resource = "android" + StringUtils.randomString(8);
    }

    accountItem =
        addAccount(
            accountType.getProtocol(),
            true,
            host,
            port,
            serverName,
            userName,
            storePassword,
            password,
            resource,
            getNextColorIndex(),
            0,
            StatusMode.available,
            SettingsManager.statusText(),
            true,
            true,
            tlsRequired ? TLSMode.required : TLSMode.enabled,
            false,
            useOrbot ? ProxyType.orbot : ProxyType.none,
            "localhost",
            8080,
            "",
            "",
            syncable,
            null,
            null,
            ArchiveMode.available);
    onAccountChanged(accountItem.getAccount());
    if (accountItems.size() > 1 && SettingsManager.contactsEnableShowAccounts())
      SettingsManager.enableContactsShowAccount();
    return accountItem.getAccount();
  }