private void checkLicense() { if (preferences.getLicenseCount() >= 2) { return; } if (System.currentTimeMillis() - preferences.getLastLicenseTime() <= 1000 * 60 * 30) { return; } // over half hour since last registration, register again to prevent 15 minute return policy // abuse LicenseCheckingTask task = new LicenseCheckingTask(this); task.setCallback( new Callback<LicenseCheckingTask.LicenseCheckingMessage>() { @Override public void doStuff(LicenseCheckingTask.LicenseCheckingMessage param) { backgroundOperationEnded(); switch (param.licenseCheckingStatus) { case Allow: // yay! do nothing break; case Disallow: preferences.setLicenseCount(0); MessageBox.Show( IrssiNotifierActivity.this, getText(R.string.not_licensed_title), getText(R.string.not_licensed), new Callback<Void>() { @Override public void doStuff(Void param) { IrssiNotifierActivity.this.finish(); } }); break; case Error: // do nothing, on next startup licensing will be retried break; } } }); TaskExecutor.executeOnThreadPoolIfPossible(task); backgroundOperationStarted(); }
private void sendSettings() { SettingsSendingTask task = new SettingsSendingTask(this, "", getString(R.string.sending_settings_to_server)); final Context ctx = this; task.setCallback( new Callback<ServerResponse>() { public void doStuff(ServerResponse result) { backgroundOperationEnded(); if (result.getException() != null) { handleNetworkException(result.getException()); return; } if (!result.wasSuccesful()) { MessageBox.Show(ctx, null, getString(R.string.unable_to_send_settings), null); } } }); TaskExecutor.executeOnThreadPoolIfPossible(task); backgroundOperationStarted(); }