2 * Copyright © 2019 Damyan Ivanov.
3 * This file is part of MoLe.
4 * MoLe is free software: you can distribute it and/or modify it
5 * under the term of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your opinion), any later version.
9 * MoLe is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License terms for details.
14 * You should have received a copy of the GNU General Public License
15 * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
18 package net.ktnx.mobileledger.ui.activity;
20 import android.content.Intent;
21 import android.content.pm.PackageInfo;
22 import android.content.res.ColorStateList;
23 import android.graphics.Color;
24 import android.os.AsyncTask;
25 import android.os.Build;
26 import android.os.Bundle;
27 import android.util.Log;
28 import android.view.View;
29 import android.view.ViewGroup;
30 import android.view.ViewPropertyAnimator;
31 import android.view.animation.Animation;
32 import android.view.animation.AnimationUtils;
33 import android.widget.LinearLayout;
34 import android.widget.ProgressBar;
35 import android.widget.TextView;
36 import android.widget.Toast;
38 import com.google.android.material.floatingactionbutton.FloatingActionButton;
40 import net.ktnx.mobileledger.R;
41 import net.ktnx.mobileledger.async.DbOpQueue;
42 import net.ktnx.mobileledger.async.RefreshDescriptionsTask;
43 import net.ktnx.mobileledger.async.RetrieveTransactionsTask;
44 import net.ktnx.mobileledger.model.Data;
45 import net.ktnx.mobileledger.model.LedgerAccount;
46 import net.ktnx.mobileledger.model.MobileLedgerProfile;
47 import net.ktnx.mobileledger.ui.account_summary.AccountSummaryAdapter;
48 import net.ktnx.mobileledger.ui.account_summary.AccountSummaryFragment;
49 import net.ktnx.mobileledger.ui.profiles.ProfileDetailFragment;
50 import net.ktnx.mobileledger.ui.profiles.ProfilesRecyclerViewAdapter;
51 import net.ktnx.mobileledger.ui.transaction_list.TransactionListFragment;
52 import net.ktnx.mobileledger.ui.transaction_list.TransactionListViewModel;
53 import net.ktnx.mobileledger.utils.Colors;
54 import net.ktnx.mobileledger.utils.LockHolder;
55 import net.ktnx.mobileledger.utils.MLDB;
57 import java.lang.ref.WeakReference;
58 import java.text.DateFormat;
59 import java.util.Date;
60 import java.util.List;
61 import java.util.Observable;
62 import java.util.Observer;
64 import androidx.appcompat.app.ActionBarDrawerToggle;
65 import androidx.appcompat.widget.Toolbar;
66 import androidx.core.view.GravityCompat;
67 import androidx.drawerlayout.widget.DrawerLayout;
68 import androidx.fragment.app.Fragment;
69 import androidx.fragment.app.FragmentManager;
70 import androidx.fragment.app.FragmentPagerAdapter;
71 import androidx.recyclerview.widget.LinearLayoutManager;
72 import androidx.recyclerview.widget.RecyclerView;
73 import androidx.viewpager.widget.ViewPager;
75 public class MainActivity extends ProfileThemedActivity {
76 public static final String STATE_CURRENT_PAGE = "current_page";
77 public static final String BUNDLE_SAVED_STATE = "bundle_savedState";
78 public static final String STATE_ACC_FILTER = "account_filter";
79 public AccountSummaryFragment mAccountSummaryFragment;
81 private LinearLayout profileListContainer;
82 private View profileListHeadArrow, profileListHeadMore, profileListHeadCancel;
83 private LinearLayout profileListHeadMoreAndCancel;
84 private FragmentManager fragmentManager;
85 private TextView tvLastUpdate;
86 private RetrieveTransactionsTask retrieveTransactionsTask;
87 private View bTransactionListCancelDownload;
88 private ProgressBar progressBar;
89 private LinearLayout progressLayout;
90 private SectionsPagerAdapter mSectionsPagerAdapter;
91 private ViewPager mViewPager;
92 private FloatingActionButton fab;
93 private boolean profileModificationEnabled = false;
94 private boolean profileListExpanded = false;
95 private ProfilesRecyclerViewAdapter mProfileListAdapter;
96 private int mCurrentPage;
97 private String mAccountFilter;
98 private boolean mBackMeansToAccountList = false;
100 protected void onStart() {
105 updateLastUpdateTextFromDB();
106 Date lastUpdate = Data.lastUpdateDate.get();
108 long now = new Date().getTime();
109 if ((lastUpdate == null) || (now > (lastUpdate.getTime() + (24 * 3600 * 1000)))) {
110 if (lastUpdate == null) Log.d("db::", "WEB data never fetched. scheduling a fetch");
112 String.format("WEB data last fetched at %1.3f and now is %1.3f. re-fetching",
113 lastUpdate.getTime() / 1000f, now / 1000f));
115 scheduleTransactionListRetrieval();
118 mViewPager.setCurrentItem(mCurrentPage, false);
119 if (mAccountFilter != null) showTransactionsFragment(mAccountFilter);
123 protected void onSaveInstanceState(Bundle outState) {
124 super.onSaveInstanceState(outState);
125 outState.putInt(STATE_CURRENT_PAGE, mViewPager.getCurrentItem());
126 if (TransactionListFragment.accountFilter.get() != null)
127 outState.putString(STATE_ACC_FILTER, TransactionListFragment.accountFilter.get());
130 protected void onCreate(Bundle savedInstanceState) {
131 super.onCreate(savedInstanceState);
133 setContentView(R.layout.activity_main);
135 fab = findViewById(R.id.btn_add_transaction);
136 profileListContainer = findViewById(R.id.nav_profile_list_container);
137 profileListHeadArrow = findViewById(R.id.nav_profiles_arrow);
138 profileListHeadMore = findViewById(R.id.nav_profiles_start_edit);
139 profileListHeadCancel = findViewById(R.id.nav_profiles_cancel_edit);
140 profileListHeadMoreAndCancel = findViewById(R.id.nav_profile_list_head_buttons);
141 drawer = findViewById(R.id.drawer_layout);
142 tvLastUpdate = findViewById(R.id.transactions_last_update);
143 bTransactionListCancelDownload = findViewById(R.id.transaction_list_cancel_download);
144 progressBar = findViewById(R.id.transaction_list_progress_bar);
145 progressLayout = findViewById(R.id.transaction_progress_layout);
146 fragmentManager = getSupportFragmentManager();
147 mSectionsPagerAdapter = new SectionsPagerAdapter(fragmentManager);
148 mViewPager = findViewById(R.id.root_frame);
150 Bundle extra = getIntent().getBundleExtra(BUNDLE_SAVED_STATE);
151 if (extra != null && savedInstanceState == null) savedInstanceState = extra;
154 Toolbar toolbar = findViewById(R.id.toolbar);
155 setSupportActionBar(toolbar);
157 Data.profile.addObserver((o, arg) -> {
158 MobileLedgerProfile profile = Data.profile.get();
159 runOnUiThread(() -> {
160 if (profile == null) setTitle(R.string.app_name);
161 else setTitle(profile.getName());
162 updateLastUpdateTextFromDB();
163 if (profile.isPostingPermitted()) {
164 toolbar.setSubtitle(null);
168 toolbar.setSubtitle(R.string.profile_subitlte_read_only);
172 int newProfileTheme = profile.getThemeId();
173 if (newProfileTheme != Colors.profileThemeId) {
174 Log.d("profiles", String.format("profile theme %d → %d", Colors.profileThemeId,
176 profileThemeChanged();
177 Colors.profileThemeId = newProfileTheme;
181 Data.profiles.addObserver((o, arg) -> {
182 findViewById(R.id.nav_profile_list).setMinimumHeight(
183 (int) (getResources().getDimension(R.dimen.thumb_row_height) *
184 Data.profiles.size()));
185 mProfileListAdapter.notifyDataSetChanged();
188 ActionBarDrawerToggle toggle =
189 new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open,
190 R.string.navigation_drawer_close);
191 drawer.addDrawerListener(toggle);
194 TextView ver = drawer.findViewById(R.id.drawer_version_text);
198 getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
199 ver.setText(pi.versionName);
201 catch (Exception e) {
205 if (progressBar == null)
206 throw new RuntimeException("Can't get hold on the transaction value progress bar");
207 if (progressLayout == null) throw new RuntimeException(
208 "Can't get hold on the transaction value progress bar layout");
210 markDrawerItemCurrent(R.id.nav_account_summary);
212 mViewPager.setAdapter(mSectionsPagerAdapter);
213 mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
215 public void onPageSelected(int position) {
218 markDrawerItemCurrent(R.id.nav_account_summary);
221 markDrawerItemCurrent(R.id.nav_latest_transactions);
224 Log.e("MainActivity", String.format("Unexpected page index %d", position));
227 super.onPageSelected(position);
232 if (savedInstanceState != null) {
233 int currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE, -1);
234 if (currentPage != -1) {
235 mCurrentPage = currentPage;
237 mAccountFilter = savedInstanceState.getString(STATE_ACC_FILTER, null);
240 Data.lastUpdateDate.addObserver((o, arg) -> {
241 Log.d("main", "lastUpdateDate changed");
242 runOnUiThread(this::updateLastUpdateDisplay);
245 updateLastUpdateDisplay();
247 findViewById(R.id.btn_no_profiles_add)
248 .setOnClickListener(v -> startEditProfileActivity(null));
250 findViewById(R.id.btn_add_transaction).setOnClickListener(this::fabNewTransactionClicked);
252 findViewById(R.id.nav_new_profile_button)
253 .setOnClickListener(v -> startEditProfileActivity(null));
255 RecyclerView root = findViewById(R.id.nav_profile_list);
257 throw new RuntimeException("Can't get hold on the transaction value view");
259 mProfileListAdapter = new ProfilesRecyclerViewAdapter();
260 root.setAdapter(mProfileListAdapter);
262 mProfileListAdapter.addEditingProfilesObserver(new Observer() {
264 public void update(Observable o, Object arg) {
265 if (mProfileListAdapter.isEditingProfiles()) {
266 profileListHeadArrow.clearAnimation();
267 profileListHeadArrow.setVisibility(View.GONE);
268 profileListHeadMore.setVisibility(View.GONE);
269 profileListHeadCancel.setVisibility(View.VISIBLE);
272 profileListHeadArrow.setRotation(180f);
273 profileListHeadArrow.setVisibility(View.VISIBLE);
274 profileListHeadCancel.setVisibility(View.GONE);
275 profileListHeadMore.setVisibility(View.GONE);
277 .setVisibility(profileListExpanded ? View.VISIBLE : View.GONE);
282 LinearLayoutManager llm = new LinearLayoutManager(this);
284 llm.setOrientation(RecyclerView.VERTICAL);
285 root.setLayoutManager(llm);
287 profileListHeadMore.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
288 profileListHeadCancel.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
289 profileListHeadMoreAndCancel
290 .setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
292 drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
294 public void onDrawerClosed(View drawerView) {
295 super.onDrawerClosed(drawerView);
296 collapseProfileList();
300 private void updateLastUpdateDisplay() {
301 TextView v = findViewById(R.id.transactions_last_update);
302 Date date = Data.lastUpdateDate.get();
304 v.setText(R.string.transaction_last_update_never);
305 Log.d("main", "no last update date :(");
308 final String text = DateFormat.getDateTimeInstance().format(date);
310 Log.d("main", String.format("Date formatted: %s", text));
313 private void profileThemeChanged() {
314 setupProfileColors();
316 Bundle bundle = new Bundle();
317 onSaveInstanceState(bundle);
318 // restart activity to reflect theme change
320 Intent intent = new Intent(this, this.getClass());
321 intent.putExtra(BUNDLE_SAVED_STATE, bundle);
322 startActivity(intent);
324 public void startEditProfileActivity(MobileLedgerProfile profile) {
325 Intent intent = new Intent(this, ProfileDetailActivity.class);
326 Bundle args = new Bundle();
327 if (profile != null) {
328 int index = Data.getProfileIndex(profile);
329 if (index != -1) intent.putExtra(ProfileDetailFragment.ARG_ITEM_ID, index);
331 intent.putExtras(args);
332 startActivity(intent, args);
334 private void setupProfile() {
335 String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null);
336 MobileLedgerProfile profile;
338 profile = MobileLedgerProfile.loadAllFromDB(profileUUID);
340 if (Data.profiles.isEmpty()) {
341 findViewById(R.id.no_profiles_layout).setVisibility(View.VISIBLE);
342 findViewById(R.id.pager_layout).setVisibility(View.GONE);
346 findViewById(R.id.pager_layout).setVisibility(View.VISIBLE);
347 findViewById(R.id.no_profiles_layout).setVisibility(View.GONE);
349 if (profile == null) profile = Data.profiles.get(0);
351 if (profile == null) throw new AssertionError("profile must have a value");
353 Data.setCurrentProfile(profile);
355 public void fabNewTransactionClicked(View view) {
356 Intent intent = new Intent(this, NewTransactionActivity.class);
357 startActivity(intent);
358 overridePendingTransition(R.anim.slide_in_right, R.anim.dummy);
360 public void navSettingsClicked(View view) {
361 Intent intent = new Intent(this, SettingsActivity.class);
362 startActivity(intent);
363 drawer.closeDrawers();
365 public void markDrawerItemCurrent(int id) {
366 TextView item = drawer.findViewById(id);
367 item.setBackgroundColor(Colors.tableRowDarkBG);
369 LinearLayout actions = drawer.findViewById(R.id.nav_actions);
370 for (int i = 0; i < actions.getChildCount(); i++) {
371 View view = actions.getChildAt(i);
372 if (view.getId() != id) {
373 view.setBackgroundColor(Color.TRANSPARENT);
377 public void onAccountSummaryClicked(View view) {
378 drawer.closeDrawers();
380 showAccountSummaryFragment();
382 private void showAccountSummaryFragment() {
383 mViewPager.setCurrentItem(0, true);
384 TransactionListFragment.accountFilter.set(null);
385 // FragmentTransaction ft = fragmentManager.beginTransaction();
386 // accountSummaryFragment = new AccountSummaryFragment();
387 // ft.replace(R.id.root_frame, accountSummaryFragment);
389 // currentFragment = accountSummaryFragment;
391 public void onLatestTransactionsClicked(View view) {
392 drawer.closeDrawers();
394 showTransactionsFragment((String) null);
396 private void resetFragmentBackStack() {
397 // fragmentManager.popBackStack(0, FragmentManager.POP_BACK_STACK_INCLUSIVE);
399 private void showTransactionsFragment(String accName) {
400 TransactionListFragment.accountFilter.set(accName);
401 TransactionListFragment.accountFilter.notifyObservers();
402 mViewPager.setCurrentItem(1, true);
404 private void showTransactionsFragment(LedgerAccount account) {
405 showTransactionsFragment((account == null) ? (String) null : account.getName());
406 // FragmentTransaction ft = fragmentManager.beginTransaction();
407 // if (transactionListFragment == null) {
408 // Log.d("flow", "MainActivity creating TransactionListFragment");
409 // transactionListFragment = new TransactionListFragment();
411 // Bundle bundle = new Bundle();
412 // if (account != null) {
413 // bundle.putString(TransactionListFragment.BUNDLE_KEY_FILTER_ACCOUNT_NAME,
414 // account.getName());
416 // transactionListFragment.setArguments(bundle);
417 // ft.replace(R.id.root_frame, transactionListFragment);
418 // if (account != null)
419 // ft.addToBackStack(getResources().getString(R.string.title_activity_transaction_list));
422 // currentFragment = transactionListFragment;
424 public void showAccountTransactions(LedgerAccount account) {
425 mBackMeansToAccountList = true;
426 showTransactionsFragment(account);
429 public void onBackPressed() {
430 DrawerLayout drawer = findViewById(R.id.drawer_layout);
431 if (drawer.isDrawerOpen(GravityCompat.START)) {
432 drawer.closeDrawer(GravityCompat.START);
435 if (mBackMeansToAccountList && (mViewPager.getCurrentItem() == 1)) {
436 TransactionListFragment.accountFilter.set(null);
437 showAccountSummaryFragment();
438 mBackMeansToAccountList = false;
441 Log.d("fragments", String.format("manager stack: %d", fragmentManager.getBackStackEntryCount()));
443 super.onBackPressed();
447 public void updateLastUpdateTextFromDB() {
449 final MobileLedgerProfile profile = Data.profile.get();
451 (profile != null) ? profile.getLongOption(MLDB.OPT_LAST_SCRAPE, 0L) : 0;
453 Log.d("transactions", String.format("Last update = %d", last_update));
454 if (last_update == 0) {
455 Data.lastUpdateDate.set(null);
458 Data.lastUpdateDate.set(new Date(last_update));
462 public void scheduleTransactionListRetrieval() {
463 if (Data.profile.get() == null) return;
465 retrieveTransactionsTask = new RetrieveTransactionsTask(new WeakReference<>(this));
467 retrieveTransactionsTask.execute();
469 public void onStopTransactionRefreshClick(View view) {
470 Log.d("interactive", "Cancelling transactions refresh");
471 if (retrieveTransactionsTask != null) retrieveTransactionsTask.cancel(false);
472 bTransactionListCancelDownload.setEnabled(false);
474 public void onRetrieveDone(String error) {
475 progressLayout.setVisibility(View.GONE);
478 updateLastUpdateTextFromDB();
480 new RefreshDescriptionsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
481 TransactionListViewModel.scheduleTransactionListReload();
483 else Toast.makeText(this, error, Toast.LENGTH_LONG).show();
485 public void onRetrieveStart() {
486 bTransactionListCancelDownload.setEnabled(true);
487 progressBar.setIndeterminateTintList(ColorStateList.valueOf(Colors.primary));
488 progressBar.setProgressTintList(ColorStateList.valueOf(Colors.primary));
489 progressBar.setIndeterminate(true);
490 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) progressBar.setProgress(0, false);
491 else progressBar.setProgress(0);
492 progressLayout.setVisibility(View.VISIBLE);
494 public void onRetrieveProgress(RetrieveTransactionsTask.Progress progress) {
495 if ((progress.getTotal() == RetrieveTransactionsTask.Progress.INDETERMINATE) ||
496 (progress.getTotal() == 0))
498 progressBar.setIndeterminate(true);
501 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
502 progressBar.setMin(0);
504 progressBar.setMax(progress.getTotal());
505 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
506 progressBar.setProgress(progress.getProgress(), true);
508 else progressBar.setProgress(progress.getProgress());
509 progressBar.setIndeterminate(false);
512 public void fabShouldShow() {
513 MobileLedgerProfile profile = Data.profile.get();
514 if ((profile != null) && profile.isPostingPermitted()) fab.show();
516 public void navProfilesHeadClicked(View view) {
517 if (profileListExpanded) {
518 collapseProfileList();
524 private void expandProfileList() {
525 profileListExpanded = true;
528 profileListContainer.setVisibility(View.VISIBLE);
529 profileListContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_down));
530 profileListHeadArrow.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180));
531 profileListHeadMore.setVisibility(View.VISIBLE);
532 profileListHeadMore.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
533 findViewById(R.id.nav_profile_list).setMinimumHeight(
534 (int) (getResources().getDimension(R.dimen.thumb_row_height) *
535 Data.profiles.size()));
537 private void collapseProfileList() {
538 profileListExpanded = false;
540 final Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_up);
541 animation.setAnimationListener(new Animation.AnimationListener() {
543 public void onAnimationStart(Animation animation) {
547 public void onAnimationEnd(Animation animation) {
548 profileListContainer.setVisibility(View.GONE);
551 public void onAnimationRepeat(Animation animation) {
555 mProfileListAdapter.stopEditingProfiles();
557 profileListContainer.startAnimation(animation);
558 profileListHeadArrow.setRotation(0f);
560 .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back));
561 profileListHeadMore.setVisibility(View.GONE);
563 public void onProfileRowClicked(View v) {
564 Data.setCurrentProfile((MobileLedgerProfile) v.getTag());
566 public void enableProfileModifications() {
567 profileModificationEnabled = true;
568 ViewGroup profileList = findViewById(R.id.nav_profile_list);
569 for (int i = 0; i < profileList.getChildCount(); i++) {
570 View aRow = profileList.getChildAt(i);
571 aRow.findViewById(R.id.profile_list_edit_button).setVisibility(View.VISIBLE);
572 aRow.findViewById(R.id.profile_list_rearrange_handle).setVisibility(View.VISIBLE);
574 // FIXME enable rearranging
577 public void disableProfileModifications() {
578 profileModificationEnabled = false;
579 ViewGroup profileList = findViewById(R.id.nav_profile_list);
580 for (int i = 0; i < profileList.getChildCount(); i++) {
581 View aRow = profileList.getChildAt(i);
582 aRow.findViewById(R.id.profile_list_edit_button).setVisibility(View.GONE);
583 aRow.findViewById(R.id.profile_list_rearrange_handle).setVisibility(View.INVISIBLE);
585 // FIXME disable rearranging
588 public void onAccountSummaryRowViewClicked(View view) {
589 ViewGroup row = (ViewGroup) view.getParent();
590 LedgerAccount acc = (LedgerAccount) row.getTag();
591 switch (view.getId()) {
592 case R.id.account_row_acc_name:
593 case R.id.account_expander_container:
594 Log.d("accounts", "Account expander clicked");
595 if (!acc.hasSubAccounts()) return;
597 boolean wasExpanded = acc.isExpanded();
599 View arrow = row.findViewById(R.id.account_expander_container);
601 arrow.clearAnimation();
602 ViewPropertyAnimator animator = arrow.animate();
604 acc.toggleExpanded();
605 DbOpQueue.add("update accounts set expanded=? where name=? and profile=?",
606 new Object[]{acc.isExpanded(), acc.getName(), Data.profile.get().getUuid()
610 Log.d("accounts", String.format("Collapsing account '%s'", acc.getName()));
611 arrow.setRotation(0);
612 animator.rotationBy(180);
614 // removing all child accounts from the view
615 int start = -1, count = 0;
616 try (LockHolder lh = Data.accounts.lockForWriting()) {
617 for (int i = 0; i < Data.accounts.size(); i++) {
618 if (acc.isParentOf(Data.accounts.get(i))) {
619 // Log.d("accounts", String.format("Found a child '%s' at position %d",
620 // Data.accounts.get(i).getName(), i));
629 // String.format("Found a non-child '%s' at position %d",
630 // Data.accounts.get(i).getName(), i));
637 for (int j = 0; j < count; j++) {
638 // Log.d("accounts", String.format("Removing item %d: %s", start + j,
639 // Data.accounts.get(start).getName()));
640 Data.accounts.removeQuietly(start);
643 mAccountSummaryFragment.modelAdapter
644 .notifyItemRangeRemoved(start, count);
649 Log.d("accounts", String.format("Expanding account '%s'", acc.getName()));
650 arrow.setRotation(180);
651 animator.rotationBy(-180);
652 List<LedgerAccount> children =
653 Data.profile.get().loadVisibleChildAccountsOf(acc);
654 try (LockHolder lh = Data.accounts.lockForWriting()) {
655 int parentPos = Data.accounts.indexOf(acc);
656 if (parentPos != -1) {
657 // may have disappeared in a concurrent refresh operation
658 Data.accounts.addAllQuietly(parentPos + 1, children);
659 mAccountSummaryFragment.modelAdapter
660 .notifyItemRangeInserted(parentPos + 1, children.size());
665 case R.id.account_row_acc_amounts:
666 if (acc.getAmountCount() > AccountSummaryAdapter.AMOUNT_LIMIT) {
667 acc.toggleAmountsExpanded();
669 .add("update accounts set amounts_expanded=? where name=? and profile=?",
670 new Object[]{acc.amountsExpanded(), acc.getName(),
671 Data.profile.get().getUuid()
673 Data.accounts.triggerItemChangedNotification(acc);
679 public class SectionsPagerAdapter extends FragmentPagerAdapter {
681 public SectionsPagerAdapter(FragmentManager fm) {
686 public Fragment getItem(int position) {
687 Log.d("main", String.format("Switching to fragment %d", position));
690 // Log.d("flow", "Creating account summary fragment");
691 return mAccountSummaryFragment = new AccountSummaryFragment();
693 return new TransactionListFragment();
695 throw new IllegalStateException(
696 String.format("Unexpected fragment index: " + "%d", position));
701 public int getCount() {