コード例 #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;
  }
コード例 #2
0
  /**
   * Build a map of all method, representation, fault and resource elements that have an ID. These
   * are used to dereference href values when building the ast.
   *
   * @param desc the URI of the WADL file being processed
   * @param a the root element of an unmarshalled WADL document
   * @throws javax.xml.bind.JAXBException if the WADL file is invalid or if the code generator
   *     encounters a problem.
   * @throws java.io.IOException if the specified WADL file cannot be read.
   */
  @SuppressWarnings("unchecked")
  protected void buildIDMap(Application a, URI desc) throws JAXBException, IOException {
    // process globally declared items
    for (Object child : a.getResourceTypeOrMethodOrRepresentation()) {
      if (child instanceof Method) extractMethodIds((Method) child, desc);
      else if (child instanceof ResourceType) extractResourceTypeIds((ResourceType) child, desc);
      else {
        JAXBElement<RepresentationType> repOrFault = (JAXBElement<RepresentationType>) child;
        extractRepresentationId(repOrFault.getValue(), desc);
      }
    }

    // process resource hierarchy
    if (a.getResources() != null)
      for (Resource r : a.getResources().getResource()) extractResourceIds(r, desc);
  }
コード例 #3
0
  /**
   * Build an abstract tree from an unmarshalled WADL file
   *
   * @param a the application element of the root WADL file
   * @param rootFile the URI of the root WADL file. Other WADL files might be included by reference.
   * @return the resource element that corresponds to the root of the resource tree
   */
  protected ResourceNode buildAst(Application a, URI rootFile) {
    for (String ifaceId : ifaceMap.keySet()) {
      buildResourceTypes(ifaceId, a);
    }

    Resources r = a.getResources();
    ResourceNode n = new ResourceNode(a, r);
    if (r != null) {
      for (Resource child : r.getResource()) {
        buildResourceTree(n, child, rootFile);
      }
    }

    return n;
  }