+ if (mBackMeansToAccountList && (mViewPager.getCurrentItem() == 1)) {
+ Data.accountFilter.setValue(null);
+ showAccountSummaryFragment();
+ mBackMeansToAccountList = false;
+ }
+ else {
+ debug("fragments", String.format(Locale.ENGLISH, "manager stack: %d",
+ fragmentManager.getBackStackEntryCount()));
+
+ super.onBackPressed();
+ }
+ }
+ }
+ public void updateLastUpdateTextFromDB() {
+ long last_update = (profile != null) ? profile.getLongOption(MLDB.OPT_LAST_SCRAPE, 0L) : 0;
+
+ debug("transactions", String.format(Locale.ENGLISH, "Last update = %d", last_update));
+ if (last_update == 0) {
+ Data.lastUpdateDate.postValue(null);
+ }
+ else {
+ Data.lastUpdateDate.postValue(new Date(last_update));
+ }
+ }
+ public void onStopTransactionRefreshClick(View view) {
+ debug("interactive", "Cancelling transactions refresh");
+ Data.stopTransactionsRetrieval();
+ bTransactionListCancelDownload.setEnabled(false);
+ }
+ public void onRetrieveDone(String error) {
+ Data.transactionRetrievalDone();
+ progressLayout.setVisibility(View.GONE);
+
+ if (error == null) {
+ updateLastUpdateTextFromDB();
+
+ new RefreshDescriptionsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ TransactionListViewModel.scheduleTransactionListReload();
+ }
+ else Toast.makeText(this, error, Toast.LENGTH_LONG).show();
+ }
+ public void onRetrieveStart() {
+ bTransactionListCancelDownload.setEnabled(true);
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(Colors.primary));
+ progressBar.setProgressTintList(ColorStateList.valueOf(Colors.primary));
+ 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);
+ }
+ }
+ public void fabShouldShow() {
+ if ((profile != null) && profile.isPostingPermitted()) fab.show();
+ }
+ public void fabHide() {
+ fab.hide();
+ }
+ public void navProfilesHeadClicked(View view) {
+ if (profileListExpanded) {
+ collapseProfileList();
+ }
+ else {
+ expandProfileList();
+ }
+ }
+ private void expandProfileList() {
+ profileListExpanded = true;
+
+
+ profileListContainer.setVisibility(View.VISIBLE);
+ profileListContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_down));
+ profileListHeadArrow.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180));
+ profileListHeadMore.setVisibility(View.VISIBLE);
+ profileListHeadMore.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
+ final ArrayList<MobileLedgerProfile> profiles = Data.profiles.getValue();
+ findViewById(R.id.nav_profile_list).setMinimumHeight(
+ (int) (getResources().getDimension(R.dimen.thumb_row_height) *
+ (profiles != null ? profiles.size() : 0)));
+ }
+ private void collapseProfileList() {
+ boolean wasExpanded = profileListExpanded;
+ profileListExpanded = false;
+
+ if (wasExpanded) {
+ final Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_up);
+ animation.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+
+ }
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ profileListContainer.setVisibility(View.GONE);
+ }
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+
+ }
+ });
+ mProfileListAdapter.stopEditingProfiles();
+
+ profileListContainer.startAnimation(animation);
+ profileListHeadArrow.setRotation(0f);
+ profileListHeadArrow
+ .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back));
+ final Animation moreAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
+ moreAnimation.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+ }
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ profileListHeadMore.setVisibility(View.GONE);
+ }
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+ }
+ });
+ profileListHeadMore.startAnimation(moreAnimation);
+ }
+ else {
+ profileListContainer.setVisibility(View.GONE);
+ profileListHeadArrow.setRotation(0f);
+ profileListHeadMore.setVisibility(View.GONE);