@Override public void onSent(String result) { try { determinateDialog.dismissAllowingStateLoss(); } catch (IllegalStateException e) { // this is okay as the user may have closed this screen } if (result != null && result.equals(NetworkInterfaceConstants.OK)) deleteFormAfterSent(); String message = getResultMessage(result, this); Toast.makeText(this, message, Toast.LENGTH_LONG).show(); finish(); }
private void uploadBulletin(Bulletin bulletin, File zippedFile) { determinateDialog = DeterminateProgressDialog.newInstance(); try { determinateDialog.show(getSupportFragmentManager(), "dlg_sending"); } catch (IllegalStateException e) { determinateDialog.dismissAllowingStateLoss(); // just means user has left app - do nothing } UniversalId bulletinId = bulletin.getUniversalId(); AsyncTask<Object, Integer, String> uploadTask = new UploadBulletinTask(getApplication(), this, bulletinId); MartusSecurity cryptoCopy = cloneSecurity(getSecurity()); uploadTask.execute( bulletin.getUniversalId(), zippedFile, AppConfig.getInstance(getApplication()) .getCurrentNetworkInterfaceGateway(getServerIp(), getServerPublicKey()), cryptoCopy); }