コード例 #1
0
  private void showUserIdInfo(final int position) {
    final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position);
    final int isVerified = mUserIdsAdapter.getIsVerified(position);

    DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(
        new Runnable() {
          public void run() {
            UserIdInfoDialogFragment dialogFragment =
                UserIdInfoDialogFragment.newInstance(isRevoked, isVerified);

            dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog");
          }
        });
  }
コード例 #2
0
 /**
  * This is called when the last Cursor provided to onLoadFinished() above is about to be closed.
  * We need to make sure we are no longer using it.
  */
 public void onLoaderReset(Loader<Cursor> loader) {
   switch (loader.getId()) {
     case LOADER_ID_USER_IDS:
       mUserIdsAdapter.swapCursor(null);
       break;
   }
 }
コード例 #3
0
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    /* TODO better error handling? May cause problems when a key is deleted,
     * because the notification triggers faster than the activity closes.
     */
    // Avoid NullPointerExceptions...
    if (data.getCount() == 0) {
      return;
    }
    // Swap the new cursor in. (The framework will take care of closing the
    // old cursor once we return.)
    switch (loader.getId()) {
      case LOADER_ID_UNIFIED:
        {
          if (data.moveToFirst()) {
            if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) {
              // edit button
              mActionEdit.setVisibility(View.VISIBLE);
              mActionEditDivider.setVisibility(View.VISIBLE);
            } else {
              // edit button
              mActionEdit.setVisibility(View.GONE);
              mActionEditDivider.setVisibility(View.GONE);
            }

            // If this key is revoked, it cannot be used for anything!
            if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) {
              mActionEdit.setEnabled(false);
              mActionCertify.setEnabled(false);
              mActionCertifyText.setEnabled(false);
              mActionEncryptText.setEnabled(false);
              mActionEncryptTextText.setEnabled(false);
              mActionEncryptFiles.setEnabled(false);
            } else {
              mActionEdit.setEnabled(true);

              Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000);
              if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) {
                mActionCertify.setEnabled(false);
                mActionCertifyText.setEnabled(false);
                mActionEncryptText.setEnabled(false);
                mActionEncryptTextText.setEnabled(false);
                mActionEncryptFiles.setEnabled(false);
              } else {
                mActionCertify.setEnabled(true);
                mActionCertifyText.setEnabled(true);
                mActionEncryptText.setEnabled(true);
                mActionEncryptTextText.setEnabled(true);
                mActionEncryptFiles.setEnabled(true);
              }
            }

            mHasEncrypt = data.getInt(INDEX_UNIFIED_HAS_ENCRYPT) != 0;

            break;
          }
        }

      case LOADER_ID_USER_IDS:
        mUserIdsAdapter.swapCursor(data);
        break;
    }
    setContentShown(true);
  }