Exemplo n.º 1
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();
    }
  }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
0
 private void doAlert(Exception e, String msg) {
   AlertDialog dlg =
       Utilities.buildAlert(SelectAccount.this, e, msg, "Login Error", emptyClickListener);
   dlg.show();
 }