예제 #1
0
  void acctSelected(ServiceAcctInfo info) {
    Account acct = new Account();
    acct.name = info.desc;
    acct.service = info;

    DialogInterface.OnClickListener emptyClickListener =
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {}
        };

    AcctTables db = new AcctTables(this);
    try {
      db.openWritable();

      try {
        db.pushAccount(acct);
      } catch (SQLiteException e) {
        AlertDialog dlg =
            Utilities.buildAlert(
                this, e, "Unable to add account", "Internal Error", emptyClickListener);
        dlg.show();
        return;
      }
    } finally {
      db.close();
    }

    Intent i = getIntent();
    i.putExtra("acct_id", acct.ID);
    setResult(RESULT_OK, i);
    finish();
  }
예제 #2
0
        private void doRetryableAlert(Exception e, String msg) {
          AlertDialog.Builder dialog = new AlertDialog.Builder(SelectAccount.this);
          dialog.setTitle(msg);
          String dispMsg = msg + "\n\n" + e.getMessage();
          dialog.setMessage(dispMsg);
          dialog.setPositiveButton(
              "Retry",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  requestAccountList();
                }
              });
          dialog.setNegativeButton("Cancel", emptyClickListener);

          AlertDialog dlg = dialog.create();
          dlg.show();
        }
예제 #3
0
  private void loadContext(int sessionId) {
    DialogInterface.OnClickListener dismissOnOk =
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            cancel();
          }
        };

    ProfileTable db = new ProfileTable(this);
    try {
      db.openReadable();

      try {
        session = db.getSession(sessionId);
      } catch (SQLiteException e) {
        AlertDialog dlg =
            Utilities.buildAlert(
                this, e, "Unable to retrieve profile", "Internal Error", dismissOnOk);
        dlg.show();
        return;
      }

      if (session == null) {
        AlertDialog dlg =
            Utilities.buildAlert(
                this, null, "Could not find login session", "Internal Error", dismissOnOk);
        dlg.show();
        return;
      }

      try {
        accountList = db.getAccountsBySession(sessionId);
      } catch (SQLiteException e) {
        AlertDialog dlg =
            Utilities.buildAlert(
                this, e, "Unable to retrieve accounts", "Internal Error", dismissOnOk);
        dlg.show();
        return;
      }
    } finally {
      db.close();
    }
    if (accountList == null) {
      requestAccountList();
    } else {
      buildView();
    }
  }
예제 #4
0
 private void doAlert(Exception e, String msg) {
   AlertDialog dlg =
       Utilities.buildAlert(SelectAccount.this, e, msg, "Login Error", emptyClickListener);
   dlg.show();
 }