+ 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("progress", "indeterminate");
+ }
+ else {
+ if (b.transactionListProgressBar.isIndeterminate()) {
+ b.transactionListProgressBar.setIndeterminate(false);
+ }
+// Logger.debug("progress",
+// String.format(Locale.US, "%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 (fabVerticalOffset <= 0) {
+ int top = b.btnAddTransaction.getTop();
+ int parentHeight = b.mainAppLayout.getHeight();
+ fabVerticalOffset = parentHeight - top;
+ }
+ if ((profile != null) && profile.isPostingPermitted() && !b.drawerLayout.isOpen()) {
+ fabShow();
+ }
+ else
+ fabHide();
+ }
+ private void fabShow() {
+ if (wantedFabState == FAB_SHOWN)
+ return;
+
+// b.btnAddTransaction.show();
+ if (this.fabSlideAnimator != null) {
+ this.fabSlideAnimator.cancel();
+ b.btnAddTransaction.clearAnimation();
+ }
+
+ wantedFabState = FAB_SHOWN;
+ slideFabTo(b.btnAddTransaction, 0, 200L,
+ com.google.android.material.animation.AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
+ }
+ public void fabHide() {
+ if (wantedFabState == FAB_HIDDEN)
+ return;
+
+ if (fabVerticalOffset <= 0)
+ return;
+
+// b.btnAddTransaction.hide();
+ if (this.fabSlideAnimator != null) {
+ this.fabSlideAnimator.cancel();
+ b.btnAddTransaction.clearAnimation();
+ }
+
+ wantedFabState = FAB_HIDDEN;
+ slideFabTo(b.btnAddTransaction, fabVerticalOffset, 150L,
+ com.google.android.material.animation.AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR);
+ }
+ private void slideFabTo(View view, int target, long duration, TimeInterpolator interpolator) {
+ fabSlideAnimator = view.animate()
+ .translationY((float) target)
+ .setInterpolator(interpolator)
+ .setDuration(duration)
+ .setListener(new AnimatorListenerAdapter() {
+ public void onAnimationEnd(Animator animation) {
+ fabSlideAnimator = null;
+ }
+ });
+ }
+
+ public static class SectionsPagerAdapter extends FragmentStateAdapter {
+
+ public SectionsPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
+ super(fragmentActivity);
+ }
+ @NotNull
+ @Override
+ public Fragment createFragment(int position) {
+ Logger.debug("main",
+ String.format(Locale.ENGLISH, "Switching to fragment %d", position));
+ switch (position) {
+ case 0:
+// debug("flow", "Creating account summary fragment");
+ return new AccountSummaryFragment();
+ case 1:
+ return new TransactionListFragment();
+ default:
+ throw new IllegalStateException(
+ String.format("Unexpected fragment index: " + "%d", position));
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return 2;
+ }
+ }