+ public void updateLastUpdateTextFromDB() {
+ {
+ long last_update = MLDB.get_option_value(MLDB.OPT_TRANSACTION_LIST_STAMP, 0L);
+
+ Log.d("transactions", String.format("Last update = %d", last_update));
+ if (last_update == 0) {
+ Data.lastUpdateDate.set(null);
+ }
+ else {
+ Data.lastUpdateDate.set(new Date(last_update));
+ }
+ }
+ }
+ public void scheduleTransactionListRetrieval() {
+ retrieveTransactionsTask = new RetrieveTransactionsTask(new WeakReference<>(this));
+
+ RetrieveTransactionsTask.Params params = new RetrieveTransactionsTask.Params(
+ PreferenceManager.getDefaultSharedPreferences(this));
+
+ retrieveTransactionsTask.execute(params);
+ bTransactionListCancelDownload.setEnabled(true);
+ }
+ public void onStopTransactionRefreshClick(View view) {
+ Log.d("interactive", "Cancelling transactions refresh");
+ if (retrieveTransactionsTask != null) retrieveTransactionsTask.cancel(false);
+ bTransactionListCancelDownload.setEnabled(false);
+ }
+ public void onRetrieveDone(boolean success) {
+ progressLayout.setVisibility(View.GONE);
+ updateLastUpdateTextFromDB();
+ }
+ public void onRetrieveStart() {
+ progressBar.setIndeterminate(true);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) progressBar.setProgress(0, false);
+ else progressBar.setProgress(0);
+ progressLayout.setVisibility(View.VISIBLE);
+ }
+ public void onRetrieveProgress(RetrieveTransactionsTask.Progress progress) {
+ if ((progress.getTotal() == RetrieveTransactionsTask.Progress.INDETERMINATE) ||
+ (progress.getTotal() == 0))
+ {
+ progressBar.setIndeterminate(true);
+ }
+ else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ progressBar.setMin(0);
+ }
+ progressBar.setMax(progress.getTotal());
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ progressBar.setProgress(progress.getProgress(), true);
+ }
+ else progressBar.setProgress(progress.getProgress());
+ progressBar.setIndeterminate(false);
+ }
+ }