コード例 #1
0
 private void onPasswordChecked(
     final CheckAppPasswordTask task, final AsyncResult<Boolean> result) {
   final Optional<? extends Boolean> isValid = result.getResult();
   if (!isValid.isPresent()) {
     Toaster.instance().show(R.string.errormessage_error_occured);
     return;
   }
   if (isFinishing()) {
     return;
   }
   if (isValid.get()) {
     try {
       if (_simplyFinish) {
         finish();
         return;
       }
       if (new AccountRepository().any()) {
         final Bundle extras = getIntent().getExtras();
         if (extras != null && extras.containsKey(DashboardActivity.EXTRA_PARC_ACCOUNT_ADDRESS)) {
           final Intent intent = new Intent(this, DashboardActivity.class).putExtras(extras);
           finish();
           startActivity(intent);
         } else {
           final AppSettings appSettings = AppSettings.instance();
           final Optional<AddressValue> primaryAddress = appSettings.getPrimaryAddress();
           if (primaryAddress.isPresent()) {
             final Intent intent =
                 new Intent(this, DashboardActivity.class)
                     .putExtra(DashboardActivity.EXTRA_PARC_ACCOUNT_ADDRESS, primaryAddress.get());
             finish();
             startActivity(intent);
             return;
           }
           final Optional<AddressValue> lastAddress = appSettings.readLastUsedAccAddress();
           if (lastAddress.isPresent()) {
             final Intent intent =
                 new Intent(this, DashboardActivity.class)
                     .putExtra(DashboardActivity.EXTRA_PARC_ACCOUNT_ADDRESS, lastAddress.get());
             finish();
             startActivity(intent);
           } else {
             AccountListActivity.start(this);
           }
         }
       } else {
         startActivity(new Intent(this, AddAccountActivity.class));
       }
     } catch (NacPersistenceRuntimeException e) {
       Toaster.instance().show(R.string.errormessage_error_occured, Toaster.Length.LONG);
     }
   } else if (_passwordInput != null) {
     InputErrorUtils.setErrorState(_passwordInput, R.string.errormessage_invalid_password);
   }
 }
コード例 #2
0
 @Override
 protected void onResume() {
   super.onResume();
   if (!ServerFinder.instance().peekBest().isPresent()) {
     ServerFinder.instance().getBestAsync();
   }
   final Bundle extras = getIntent().getExtras();
   final Optional<BinaryData> eKey = EKeyProvider.instance().getKey();
   if (eKey.isPresent()) {
     Timber.d("Key present, checking...");
     _dialogLayout.setVisibility(View.GONE);
     showProgressDialog(R.string.progress_dialog_message_password_checking);
     getHandler()
         .postDelayed(
             () -> {
               if (isNotDestroyed()) {
                 if (extras != null
                     && extras.containsKey(DashboardActivity.EXTRA_PARC_ACCOUNT_ADDRESS)) {
                   final Intent intent =
                       new Intent(this, DashboardActivity.class).putExtras(extras);
                   startActivity(intent);
                 } else if (lastUsedAddress != null) {
                   final Intent intent = new Intent(this, DashboardActivity.class);
                   if (extras != null && !extras.isEmpty()) {
                     intent.putExtras(extras);
                   }
                   startActivity(intent);
                 } else {
                   AccountListActivity.start(this);
                 }
                 finish();
               }
             },
             1000);
   } else {
     Timber.d("Key not present, waiting for password input");
   }
 }