+ b.transactionProgressLayout.setVisibility(View.GONE);
+ }
+ }
+ public void onRetrieveProgress(@Nullable RetrieveTransactionsTask.Progress progress) {
+ if (progress == null ||
+ progress.getState() == RetrieveTransactionsTask.ProgressState.FINISHED)
+ {
+ Logger.debug(TAG, "progress: Done");
+ b.transactionProgressLayout.setVisibility(View.GONE);
+
+ mainModel.transactionRetrievalDone();
+
+ String error = (progress == null) ? null : progress.getError();
+ if (error != null) {
+ if (error.equals(RetrieveTransactionsTask.Result.ERR_JSON_PARSER_ERROR))
+ error = getResources().getString(R.string.err_json_parser_error);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(error);
+ builder.setPositiveButton(R.string.btn_profile_options, (dialog, which) -> {
+ Logger.debug(TAG, "will start profile editor");
+ ProfileDetailActivity.start(this, profile);
+ });
+ builder.create()
+ .show();
+ return;
+ }
+
+ return;
+ }
+
+
+ b.transactionListCancelDownload.setEnabled(true);
+// ColorStateList csl = Colors.getColorStateList();
+// progressBar.setIndeterminateTintList(csl);
+// progressBar.setProgressTintList(csl);
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+// progressBar.setProgress(0, false);
+// else
+// progressBar.setProgress(0);
+ b.transactionProgressLayout.setVisibility(View.VISIBLE);
+
+ if (progress.isIndeterminate() || (progress.getTotal() <= 0)) {
+ b.transactionListProgressBar.setIndeterminate(true);
+ Logger.debug(TAG, "progress: indeterminate");
+ }
+ else {
+ if (b.transactionListProgressBar.isIndeterminate()) {
+ b.transactionListProgressBar.setIndeterminate(false);
+ }
+// Logger.debug(TAG,
+// String.format(Locale.US, "progress: %d/%d", progress.getProgress(),
+// progress.getTotal
+// ()));
+ b.transactionListProgressBar.setMax(progress.getTotal());
+ // for some reason animation doesn't work - no progress is shown (stick at 0)
+ // on lineageOS 14.1 (Nougat, 7.1.2)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ b.transactionListProgressBar.setProgress(progress.getProgress(), false);
+ else
+ b.transactionListProgressBar.setProgress(progress.getProgress());
+ }
+ }
+ public void fabShouldShow() {
+ if ((profile != null) && profile.permitPosting() && !b.drawerLayout.isOpen())
+ fabManager.showFab();
+ }
+ @Override
+ public Context getContext() {
+ return this;
+ }
+ @Override
+ public void showManagedFab() {
+ fabShouldShow();
+ }
+ @Override
+ public void hideManagedFab() {
+ fabManager.hideFab();
+ }
+ public static class SectionsPagerAdapter extends FragmentStateAdapter {
+
+ public SectionsPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
+ super(fragmentActivity);
+ }
+ @NotNull
+ @Override
+ public Fragment createFragment(int position) {
+ Logger.debug(TAG, String.format(Locale.ENGLISH, "Switching to fragment %d", position));
+ switch (position) {
+ case 0:
+// debug(TAG, "Creating account summary fragment");
+ return new AccountSummaryFragment();
+ case 1:
+ return new TransactionListFragment();
+ default:
+ throw new IllegalStateException(
+ String.format("Unexpected fragment index: " + "%d", position));
+ }
+ }