- 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));
- findViewById(R.id.nav_profile_list).setMinimumHeight(
- (int) (getResources().getDimension(R.dimen.thumb_row_height) *
- Data.profiles.size()));
- }
- private void collapseProfileList() {
- profileListExpanded = false;
-
- 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));
- profileListHeadMore.setVisibility(View.GONE);
- }
- public void onProfileRowClicked(View v) {
- Data.setCurrentProfile((MobileLedgerProfile) v.getTag());
- }
- public void enableProfileModifications() {
- profileModificationEnabled = true;
- ViewGroup profileList = findViewById(R.id.nav_profile_list);
- for (int i = 0; i < profileList.getChildCount(); i++) {
- View aRow = profileList.getChildAt(i);
- aRow.findViewById(R.id.profile_list_edit_button).setVisibility(View.VISIBLE);
- aRow.findViewById(R.id.profile_list_rearrange_handle).setVisibility(View.VISIBLE);
- }
- // FIXME enable rearranging
-
- }
- public void disableProfileModifications() {
- profileModificationEnabled = false;
- ViewGroup profileList = findViewById(R.id.nav_profile_list);
- for (int i = 0; i < profileList.getChildCount(); i++) {
- View aRow = profileList.getChildAt(i);
- aRow.findViewById(R.id.profile_list_edit_button).setVisibility(View.GONE);
- aRow.findViewById(R.id.profile_list_rearrange_handle).setVisibility(View.INVISIBLE);
- }
- // FIXME disable rearranging
-
- }
- public void onAccountSummaryRowViewClicked(View view) {
- ViewGroup row = (ViewGroup) view.getParent();
- LedgerAccount acc = (LedgerAccount) row.getTag();
- switch (view.getId()) {
- case R.id.account_row_acc_name:
- case R.id.account_expander_container:
- Log.d("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();
- Data.profile.get().storeAccount(MLDB.getDatabase(), acc);
-
- if (wasExpanded) {
- Log.d("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;
- int i = 0;
- final ArrayList<LedgerAccount> accountList = Data.accounts.get();
- for (LedgerAccount a : accountList) {
- if (acc.isParentOf(a)) {
- if (start == -1) {
- start = i;
- }
- count++;
- }
- else {
- if (start != -1) {
- break;
- }
- }
- i++;
- }
-
- if (start != -1) {
- for (int j = 0; j < count; j++) {
- Log.d("accounts", String.format("Removing item %d: %s", start + j,
- accountList.get(start).getName()));
- accountList.remove(start);
- }
-
- mAccountSummaryFragment.modelAdapter.notifyItemRangeRemoved(start, count);
- }
- }
- else {
- Log.d("accounts", String.format("Expanding account '%s'", acc.getName()));
- arrow.setRotation(180);
- animator.rotationBy(-180);
- ArrayList<LedgerAccount> accounts = Data.accounts.get();
- List<LedgerAccount> children =
- Data.profile.get().loadVisibleChildAccountsOf(acc);
- int parentPos = accounts.indexOf(acc);
- if (parentPos == -1) throw new RuntimeException(
- "Can't find index of clicked account " + acc.getName());
- accounts.addAll(parentPos + 1, children);
- mAccountSummaryFragment.modelAdapter
- .notifyItemRangeInserted(parentPos + 1, children.size());
- }
- break;
- case R.id.account_row_acc_amounts:
- showAccountTransactions(acc);
- break;
- }