private void getAccountInfo() {
    if (api.isAuthenticated()) {
      // If we're already authenticated, we don't need to get the login info

      dialog.show();
      LoginAsyncTask login = new LoginAsyncTask(this, null, null, getConfig(), dialog);
      login.execute();
    } else {

      String email = mLoginEmail.getText().toString();

      if (email.length() < 5 || email.indexOf("@") < 0 || email.indexOf(".") < 0) {
        showToast("Error, invalid e-mail");
        return;
      }

      String password = mLoginPassword.getText().toString();

      if (password.length() < 6) {
        showToast("Error, password too short");
        return;
      }

      // It's good to do Dropbox API (and any web API) calls in a separate thread,
      // so we don't get a force-close due to the UI thread stalling.

      dialog.show();
      LoginAsyncTask login = new LoginAsyncTask(this, email, password, getConfig(), dialog);
      login.execute();
    }
  }
Esempio n. 2
0
 public void handleMessage(android.os.Message msg) {
   switch (msg.what) {
     case TimeChecker.TIME_OUT:
       pDialog.pDialogHide();
       showShortToast(ConstantsPromptMessages.NETWORK_POOR);
       if (loginAsyncTask != null && loginAsyncTask.getStatus() != Status.FINISHED) {
         loginAsyncTask.cancel(true);
         loginAsyncTask = null;
       }
       break;
   }
 };
 private void loginAsync() {
   mStatusView.setText(
       mIsLogin ? R.string.msg_login_dialog_title_wait : R.string.msg_update_dialog_title_wait);
   AsyncTaskUtils.cancelTask(mLoginAsyncTask);
   mLoginAsyncTask = new LoginAsyncTask();
   mLoginAsyncTask.execute();
 }
 @Override
 public void onBackPressed() {
   super.onBackPressed();
   if (mLoginAsyncTask != null) {
     mLoginAsyncTask.cancelTask(true);
     DebugUtils.logD(TAG, "login or update is canceled by user");
   }
 }