コード例 #1
0
  /**
   * Update the list of credentials if the activity is in the appropriate state
   *
   * @param tryDownloading Whether to update the description store and keystore in advance
   */
  protected void updateCredentialList(boolean tryDownloading) {
    if (!credentialsLoaded
        || !descriptionStoreLoaded
        || (!getState().isBooting() && getState() != State.IDLE)) return;

    if (tryDownloading) {
      CredentialManager.updateStores(
          new StoreManager.DownloadHandler() {
            @Override
            public void onSuccess() {
              updateCredentialList(false);
            }

            @Override
            public void onError(Exception e) {
              setFeedback(getString(R.string.downloading_credential_info_failed), "warning");
              updateCredentialList(false);
            }
          });
    }

    LinkedHashMap<IdemixCredentialIdentifier, Attributes> credentials =
        CredentialManager.getAllAttributes();
    credentialListAdapter.updateData(credentials);

    TextView noCredsText = (TextView) findViewById(R.id.no_credentials_text);
    Button enrollButton = (Button) findViewById(R.id.enroll_button);
    Button onlineEnrollButton = (Button) findViewById(R.id.online_enroll_button);
    int visibility = credentials.isEmpty() ? View.VISIBLE : View.INVISIBLE;

    if (noCredsText != null && enrollButton != null) {
      noCredsText.setVisibility(visibility);
      enrollButton.setVisibility(visibility);
      onlineEnrollButton.setVisibility(visibility);
    }
  }