+ 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);
+ }
+ }
+ public void onAccountSummaryRowViewClicked(View view) {
+ ViewGroup row;
+ if (view.getId() == R.id.account_expander) row = (ViewGroup) view.getParent().getParent();
+ else row = (ViewGroup) view.getParent();
+
+ LedgerAccount acc = (LedgerAccount) row.getTag();
+ switch (view.getId()) {
+ case R.id.account_row_acc_name:
+ case R.id.account_expander:
+ case R.id.account_expander_container:
+ debug("accounts", "Account expander clicked");
+ if (!acc.hasSubAccounts()) return;
+
+ boolean wasExpanded = acc.isExpanded();
+
+ View arrow = row.findViewById(R.id.account_expander_container);
+
+ arrow.clearAnimation();
+ ViewPropertyAnimator animator = arrow.animate();
+
+ acc.toggleExpanded();
+ DbOpQueue.add("update accounts set expanded=? where name=? and profile=?",
+ new Object[]{acc.isExpanded(), acc.getName(), profile.getUuid()
+ });
+
+ if (wasExpanded) {
+ debug("accounts", String.format("Collapsing account '%s'", acc.getName()));
+ arrow.setRotation(0);
+ animator.rotationBy(180);
+
+ // removing all child accounts from the view
+ int start = -1, count = 0;
+ try (LockHolder ignored = Data.accounts.lockForWriting()) {
+ for (int i = 0; i < Data.accounts.size(); i++) {
+ if (acc.isParentOf(Data.accounts.get(i))) {
+// debug("accounts", String.format("Found a child '%s' at position %d",
+// Data.accounts.get(i).getName(), i));
+ if (start == -1) {
+ start = i;
+ }
+ count++;
+ }
+ else {
+ if (start != -1) {
+// debug("accounts",
+// String.format("Found a non-child '%s' at position %d",
+// Data.accounts.get(i).getName(), i));
+ break;
+ }
+ }
+ }
+
+ if (start != -1) {
+ for (int j = 0; j < count; j++) {
+// debug("accounts", String.format("Removing item %d: %s", start + j,
+// Data.accounts.get(start).getName()));
+ Data.accounts.removeQuietly(start);
+ }
+
+ mAccountSummaryFragment.modelAdapter
+ .notifyItemRangeRemoved(start, count);
+ }
+ }
+ }
+ else {
+ debug("accounts", String.format("Expanding account '%s'", acc.getName()));
+ arrow.setRotation(180);
+ animator.rotationBy(-180);
+ List<LedgerAccount> children = profile.loadVisibleChildAccountsOf(acc);
+ try (LockHolder ignored = Data.accounts.lockForWriting()) {
+ int parentPos = Data.accounts.indexOf(acc);
+ if (parentPos != -1) {
+ // may have disappeared in a concurrent refresh operation
+ Data.accounts.addAllQuietly(parentPos + 1, children);
+ mAccountSummaryFragment.modelAdapter
+ .notifyItemRangeInserted(parentPos + 1, children.size());
+ }
+ }
+ }
+ break;
+ case R.id.account_row_acc_amounts:
+ if (acc.getAmountCount() > AccountSummaryAdapter.AMOUNT_LIMIT) {
+ acc.toggleAmountsExpanded();
+ DbOpQueue
+ .add("update accounts set amounts_expanded=? where name=? and profile=?",
+ new Object[]{acc.amountsExpanded(), acc.getName(),
+ profile.getUuid()
+ });
+ Data.accounts.triggerItemChangedNotification(acc);
+ }
+ break;
+ }
+ }
+