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;
99 protected void onStart() {
104 updateLastUpdateTextFromDB();
105 Date lastUpdate = Data.lastUpdateDate.get();
107 long now = new Date().getTime();
108 if ((lastUpdate == null) || (now > (lastUpdate.getTime() + (24 * 3600 * 1000)))) {
109 if (lastUpdate == null) Log.d("db::", "WEB data never fetched. scheduling a fetch");
111 String.format("WEB data last fetched at %1.3f and now is %1.3f. re-fetching",
112 lastUpdate.getTime() / 1000f, now / 1000f));
114 scheduleTransactionListRetrieval();
117 mViewPager.setCurrentItem(mCurrentPage, false);
118 if (mAccountFilter != null) showTransactionsFragment(mAccountFilter);
122 protected void onSaveInstanceState(Bundle outState) {
123 super.onSaveInstanceState(outState);
124 outState.putInt(STATE_CURRENT_PAGE, mViewPager.getCurrentItem());
125 if (TransactionListFragment.accountFilter.get() != null)
126 outState.putString(STATE_ACC_FILTER, TransactionListFragment.accountFilter.get());
129 protected void onCreate(Bundle savedInstanceState) {
130 super.onCreate(savedInstanceState);
132 setContentView(R.layout.activity_main);
134 fab = findViewById(R.id.btn_add_transaction);
135 profileListContainer = findViewById(R.id.nav_profile_list_container);
136 profileListHeadArrow = findViewById(R.id.nav_profiles_arrow);
137 profileListHeadMore = findViewById(R.id.nav_profiles_start_edit);
138 profileListHeadCancel = findViewById(R.id.nav_profiles_cancel_edit);
139 profileListHeadMoreAndCancel = findViewById(R.id.nav_profile_list_head_buttons);
140 drawer = findViewById(R.id.drawer_layout);
141 tvLastUpdate = findViewById(R.id.transactions_last_update);
142 bTransactionListCancelDownload = findViewById(R.id.transaction_list_cancel_download);
143 progressBar = findViewById(R.id.transaction_list_progress_bar);
144 progressLayout = findViewById(R.id.transaction_progress_layout);
145 fragmentManager = getSupportFragmentManager();
146 mSectionsPagerAdapter = new SectionsPagerAdapter(fragmentManager);
147 mViewPager = findViewById(R.id.root_frame);
149 Bundle extra = getIntent().getBundleExtra(BUNDLE_SAVED_STATE);
150 if (extra != null && savedInstanceState == null) savedInstanceState = extra;
153 Toolbar toolbar = findViewById(R.id.toolbar);
154 setSupportActionBar(toolbar);
156 Data.profile.addObserver((o, arg) -> {
157 MobileLedgerProfile profile = Data.profile.get();
158 runOnUiThread(() -> {
159 if (profile == null) setTitle(R.string.app_name);
160 else setTitle(profile.getName());
161 updateLastUpdateTextFromDB();
162 if (profile.isPostingPermitted()) {
163 toolbar.setSubtitle(null);
167 toolbar.setSubtitle(R.string.profile_subitlte_read_only);
171 int newProfileTheme = profile.getThemeId();
172 if (newProfileTheme != Colors.profileThemeId) {
173 Log.d("profiles", String.format("profile theme %d → %d", Colors.profileThemeId,
175 profileThemeChanged();
176 Colors.profileThemeId = newProfileTheme;
180 Data.profiles.addObserver((o, arg) -> {
181 findViewById(R.id.nav_profile_list).setMinimumHeight(
182 (int) (getResources().getDimension(R.dimen.thumb_row_height) *
183 Data.profiles.size()));
184 mProfileListAdapter.notifyDataSetChanged();
187 ActionBarDrawerToggle toggle =
188 new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open,
189 R.string.navigation_drawer_close);
190 drawer.addDrawerListener(toggle);
193 TextView ver = drawer.findViewById(R.id.drawer_version_text);
197 getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0);
198 ver.setText(pi.versionName);
200 catch (Exception e) {
204 if (progressBar == null)
205 throw new RuntimeException("Can't get hold on the transaction value progress bar");
206 if (progressLayout == null) throw new RuntimeException(
207 "Can't get hold on the transaction value progress bar layout");
209 markDrawerItemCurrent(R.id.nav_account_summary);
211 mViewPager.setAdapter(mSectionsPagerAdapter);
212 mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
214 public void onPageSelected(int position) {
217 markDrawerItemCurrent(R.id.nav_account_summary);
220 markDrawerItemCurrent(R.id.nav_latest_transactions);
223 Log.e("MainActivity", String.format("Unexpected page index %d", position));
226 super.onPageSelected(position);
231 if (savedInstanceState != null) {
232 int currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE, -1);
233 if (currentPage != -1) {
234 mCurrentPage = currentPage;
236 mAccountFilter = savedInstanceState.getString(STATE_ACC_FILTER, null);
239 Data.lastUpdateDate.addObserver((o, arg) -> {
240 Log.d("main", "lastUpdateDate changed");
241 runOnUiThread(this::updateLastUpdateDisplay);
244 updateLastUpdateDisplay();
246 findViewById(R.id.btn_no_profiles_add)
247 .setOnClickListener(v -> startEditProfileActivity(null));
249 findViewById(R.id.btn_add_transaction).setOnClickListener(this::fabNewTransactionClicked);
251 findViewById(R.id.nav_new_profile_button)
252 .setOnClickListener(v -> startEditProfileActivity(null));
254 RecyclerView root = findViewById(R.id.nav_profile_list);
256 throw new RuntimeException("Can't get hold on the transaction value view");
258 mProfileListAdapter = new ProfilesRecyclerViewAdapter();
259 root.setAdapter(mProfileListAdapter);
261 mProfileListAdapter.addEditingProfilesObserver(new Observer() {
263 public void update(Observable o, Object arg) {
264 if (mProfileListAdapter.isEditingProfiles()) {
265 profileListHeadArrow.clearAnimation();
266 profileListHeadArrow.setVisibility(View.GONE);
267 profileListHeadMore.setVisibility(View.GONE);
268 profileListHeadCancel.setVisibility(View.VISIBLE);
271 profileListHeadArrow.setRotation(180f);
272 profileListHeadArrow.setVisibility(View.VISIBLE);
273 profileListHeadCancel.setVisibility(View.GONE);
274 profileListHeadMore.setVisibility(View.GONE);
276 .setVisibility(profileListExpanded ? View.VISIBLE : View.GONE);
281 LinearLayoutManager llm = new LinearLayoutManager(this);
283 llm.setOrientation(RecyclerView.VERTICAL);
284 root.setLayoutManager(llm);
286 profileListHeadMore.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
287 profileListHeadCancel.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
288 profileListHeadMoreAndCancel
289 .setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
291 drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
293 public void onDrawerClosed(View drawerView) {
294 super.onDrawerClosed(drawerView);
295 collapseProfileList();
299 private void updateLastUpdateDisplay() {
300 TextView v = findViewById(R.id.transactions_last_update);
301 Date date = Data.lastUpdateDate.get();
303 v.setText(R.string.transaction_last_update_never);
304 Log.d("main", "no last update date :(");
307 final String text = DateFormat.getDateTimeInstance().format(date);
309 Log.d("main", String.format("Date formatted: %s", text));
312 private void profileThemeChanged() {
313 setupProfileColors();
315 Bundle bundle = new Bundle();
316 onSaveInstanceState(bundle);
317 // restart activity to reflect theme change
319 Intent intent = new Intent(this, this.getClass());
320 intent.putExtra(BUNDLE_SAVED_STATE, bundle);
321 startActivity(intent);
323 public void startEditProfileActivity(MobileLedgerProfile profile) {
324 Intent intent = new Intent(this, ProfileDetailActivity.class);
325 Bundle args = new Bundle();
326 if (profile != null) {
327 int index = Data.getProfileIndex(profile);
328 if (index != -1) intent.putExtra(ProfileDetailFragment.ARG_ITEM_ID, index);
330 intent.putExtras(args);
331 startActivity(intent, args);
333 private void setupProfile() {
334 String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null);
335 MobileLedgerProfile profile;
337 profile = MobileLedgerProfile.loadAllFromDB(profileUUID);
339 if (Data.profiles.isEmpty()) {
340 findViewById(R.id.no_profiles_layout).setVisibility(View.VISIBLE);
341 findViewById(R.id.pager_layout).setVisibility(View.GONE);
345 findViewById(R.id.pager_layout).setVisibility(View.VISIBLE);
346 findViewById(R.id.no_profiles_layout).setVisibility(View.GONE);
348 if (profile == null) profile = Data.profiles.get(0);
350 if (profile == null) throw new AssertionError("profile must have a value");
352 Data.setCurrentProfile(profile);
354 public void fabNewTransactionClicked(View view) {
355 Intent intent = new Intent(this, NewTransactionActivity.class);
356 startActivity(intent);
357 overridePendingTransition(R.anim.slide_in_right, R.anim.dummy);
359 public void navSettingsClicked(View view) {
360 Intent intent = new Intent(this, SettingsActivity.class);
361 startActivity(intent);
362 drawer.closeDrawers();
364 public void markDrawerItemCurrent(int id) {
365 TextView item = drawer.findViewById(id);
366 item.setBackgroundColor(Colors.tableRowDarkBG);
368 LinearLayout actions = drawer.findViewById(R.id.nav_actions);
369 for (int i = 0; i < actions.getChildCount(); i++) {
370 View view = actions.getChildAt(i);
371 if (view.getId() != id) {
372 view.setBackgroundColor(Color.TRANSPARENT);
376 public void onAccountSummaryClicked(View view) {
377 drawer.closeDrawers();
379 showAccountSummaryFragment();
381 private void showAccountSummaryFragment() {
382 mViewPager.setCurrentItem(0, true);
383 TransactionListFragment.accountFilter.set(null);
384 // FragmentTransaction ft = fragmentManager.beginTransaction();
385 // accountSummaryFragment = new AccountSummaryFragment();
386 // ft.replace(R.id.root_frame, accountSummaryFragment);
388 // currentFragment = accountSummaryFragment;
390 public void onLatestTransactionsClicked(View view) {
391 drawer.closeDrawers();
393 showTransactionsFragment((String) null);
395 private void resetFragmentBackStack() {
396 // fragmentManager.popBackStack(0, FragmentManager.POP_BACK_STACK_INCLUSIVE);
398 private void showTransactionsFragment(String accName) {
399 TransactionListFragment.accountFilter.set(accName);
400 TransactionListFragment.accountFilter.notifyObservers();
401 mViewPager.setCurrentItem(1, true);
403 private void showTransactionsFragment(LedgerAccount account) {
404 showTransactionsFragment((account == null) ? (String) null : account.getName());
405 // FragmentTransaction ft = fragmentManager.beginTransaction();
406 // if (transactionListFragment == null) {
407 // Log.d("flow", "MainActivity creating TransactionListFragment");
408 // transactionListFragment = new TransactionListFragment();
410 // Bundle bundle = new Bundle();
411 // if (account != null) {
412 // bundle.putString(TransactionListFragment.BUNDLE_KEY_FILTER_ACCOUNT_NAME,
413 // account.getName());
415 // transactionListFragment.setArguments(bundle);
416 // ft.replace(R.id.root_frame, transactionListFragment);
417 // if (account != null)
418 // ft.addToBackStack(getResources().getString(R.string.title_activity_transaction_list));
421 // currentFragment = transactionListFragment;
423 public void showAccountTransactions(LedgerAccount account) {
424 showTransactionsFragment(account);
427 public void onBackPressed() {
428 DrawerLayout drawer = findViewById(R.id.drawer_layout);
429 if (drawer.isDrawerOpen(GravityCompat.START)) {
430 drawer.closeDrawer(GravityCompat.START);
434 String.format("manager stack: %d", fragmentManager.getBackStackEntryCount()));
436 super.onBackPressed();
439 public void updateLastUpdateTextFromDB() {
441 final MobileLedgerProfile profile = Data.profile.get();
443 (profile != null) ? profile.getLongOption(MLDB.OPT_LAST_SCRAPE, 0L) : 0;
445 Log.d("transactions", String.format("Last update = %d", last_update));
446 if (last_update == 0) {
447 Data.lastUpdateDate.set(null);
450 Data.lastUpdateDate.set(new Date(last_update));
454 public void scheduleTransactionListRetrieval() {
455 if (Data.profile.get() == null) return;
457 retrieveTransactionsTask = new RetrieveTransactionsTask(new WeakReference<>(this));
459 retrieveTransactionsTask.execute();
461 public void onStopTransactionRefreshClick(View view) {
462 Log.d("interactive", "Cancelling transactions refresh");
463 if (retrieveTransactionsTask != null) retrieveTransactionsTask.cancel(false);
464 bTransactionListCancelDownload.setEnabled(false);
466 public void onRetrieveDone(String error) {
467 progressLayout.setVisibility(View.GONE);
470 updateLastUpdateTextFromDB();
472 new RefreshDescriptionsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
473 TransactionListViewModel.scheduleTransactionListReload();
475 else Toast.makeText(this, error, Toast.LENGTH_LONG).show();
477 public void onRetrieveStart() {
478 bTransactionListCancelDownload.setEnabled(true);
479 progressBar.setIndeterminateTintList(ColorStateList.valueOf(Colors.primary));
480 progressBar.setProgressTintList(ColorStateList.valueOf(Colors.primary));
481 progressBar.setIndeterminate(true);
482 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) progressBar.setProgress(0, false);
483 else progressBar.setProgress(0);
484 progressLayout.setVisibility(View.VISIBLE);
486 public void onRetrieveProgress(RetrieveTransactionsTask.Progress progress) {
487 if ((progress.getTotal() == RetrieveTransactionsTask.Progress.INDETERMINATE) ||
488 (progress.getTotal() == 0))
490 progressBar.setIndeterminate(true);
493 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
494 progressBar.setMin(0);
496 progressBar.setMax(progress.getTotal());
497 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
498 progressBar.setProgress(progress.getProgress(), true);
500 else progressBar.setProgress(progress.getProgress());
501 progressBar.setIndeterminate(false);
504 public void fabShouldShow() {
505 MobileLedgerProfile profile = Data.profile.get();
506 if ((profile != null) && profile.isPostingPermitted()) fab.show();
508 public void navProfilesHeadClicked(View view) {
509 if (profileListExpanded) {
510 collapseProfileList();
516 private void expandProfileList() {
517 profileListExpanded = true;
520 profileListContainer.setVisibility(View.VISIBLE);
521 profileListContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_down));
522 profileListHeadArrow.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180));
523 profileListHeadMore.setVisibility(View.VISIBLE);
524 profileListHeadMore.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
525 findViewById(R.id.nav_profile_list).setMinimumHeight(
526 (int) (getResources().getDimension(R.dimen.thumb_row_height) *
527 Data.profiles.size()));
529 private void collapseProfileList() {
530 profileListExpanded = false;
532 final Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_up);
533 animation.setAnimationListener(new Animation.AnimationListener() {
535 public void onAnimationStart(Animation animation) {
539 public void onAnimationEnd(Animation animation) {
540 profileListContainer.setVisibility(View.GONE);
543 public void onAnimationRepeat(Animation animation) {
547 mProfileListAdapter.stopEditingProfiles();
549 profileListContainer.startAnimation(animation);
550 profileListHeadArrow.setRotation(0f);
552 .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back));
553 profileListHeadMore.setVisibility(View.GONE);
555 public void onProfileRowClicked(View v) {
556 Data.setCurrentProfile((MobileLedgerProfile) v.getTag());
558 public void enableProfileModifications() {
559 profileModificationEnabled = true;
560 ViewGroup profileList = findViewById(R.id.nav_profile_list);
561 for (int i = 0; i < profileList.getChildCount(); i++) {
562 View aRow = profileList.getChildAt(i);
563 aRow.findViewById(R.id.profile_list_edit_button).setVisibility(View.VISIBLE);
564 aRow.findViewById(R.id.profile_list_rearrange_handle).setVisibility(View.VISIBLE);
566 // FIXME enable rearranging
569 public void disableProfileModifications() {
570 profileModificationEnabled = false;
571 ViewGroup profileList = findViewById(R.id.nav_profile_list);
572 for (int i = 0; i < profileList.getChildCount(); i++) {
573 View aRow = profileList.getChildAt(i);
574 aRow.findViewById(R.id.profile_list_edit_button).setVisibility(View.GONE);
575 aRow.findViewById(R.id.profile_list_rearrange_handle).setVisibility(View.INVISIBLE);
577 // FIXME disable rearranging
580 public void onAccountSummaryRowViewClicked(View view) {
581 ViewGroup row = (ViewGroup) view.getParent();
582 LedgerAccount acc = (LedgerAccount) row.getTag();
583 switch (view.getId()) {
584 case R.id.account_row_acc_name:
585 case R.id.account_expander_container:
586 Log.d("accounts", "Account expander clicked");
587 if (!acc.hasSubAccounts()) return;
589 boolean wasExpanded = acc.isExpanded();
591 View arrow = row.findViewById(R.id.account_expander_container);
593 arrow.clearAnimation();
594 ViewPropertyAnimator animator = arrow.animate();
596 acc.toggleExpanded();
597 DbOpQueue.add("update accounts set expanded=? where name=? and profile=?",
598 new Object[]{acc.isExpanded(), acc.getName(), Data.profile.get().getUuid()
602 Log.d("accounts", String.format("Collapsing account '%s'", acc.getName()));
603 arrow.setRotation(0);
604 animator.rotationBy(180);
606 // removing all child accounts from the view
607 int start = -1, count = 0;
608 try (LockHolder lh = Data.accounts.lockForWriting()) {
609 for (int i = 0; i < Data.accounts.size(); i++) {
610 if (acc.isParentOf(Data.accounts.get(i))) {
611 // Log.d("accounts", String.format("Found a child '%s' at position %d",
612 // Data.accounts.get(i).getName(), i));
621 // String.format("Found a non-child '%s' at position %d",
622 // Data.accounts.get(i).getName(), i));
629 for (int j = 0; j < count; j++) {
630 // Log.d("accounts", String.format("Removing item %d: %s", start + j,
631 // Data.accounts.get(start).getName()));
632 Data.accounts.removeQuietly(start);
635 mAccountSummaryFragment.modelAdapter
636 .notifyItemRangeRemoved(start, count);
641 Log.d("accounts", String.format("Expanding account '%s'", acc.getName()));
642 arrow.setRotation(180);
643 animator.rotationBy(-180);
644 List<LedgerAccount> children =
645 Data.profile.get().loadVisibleChildAccountsOf(acc);
646 try (LockHolder lh = Data.accounts.lockForWriting()) {
647 int parentPos = Data.accounts.indexOf(acc);
648 if (parentPos != -1) {
649 // may have disappeared in a concurrent refresh operation
650 Data.accounts.addAllQuietly(parentPos + 1, children);
651 mAccountSummaryFragment.modelAdapter
652 .notifyItemRangeInserted(parentPos + 1, children.size());
657 case R.id.account_row_acc_amounts:
658 if (acc.getAmountCount() > AccountSummaryAdapter.AMOUNT_LIMIT) {
659 acc.toggleAmountsExpanded();
661 .add("update accounts set amounts_expanded=? where name=? and profile=?",
662 new Object[]{acc.amountsExpanded(), acc.getName(),
663 Data.profile.get().getUuid()
665 Data.accounts.triggerItemChangedNotification(acc);
671 public class SectionsPagerAdapter extends FragmentPagerAdapter {
673 public SectionsPagerAdapter(FragmentManager fm) {
678 public Fragment getItem(int position) {
679 Log.d("main", String.format("Switching to fragment %d", position));
682 // Log.d("flow", "Creating account summary fragment");
683 return mAccountSummaryFragment = new AccountSummaryFragment();
685 return new TransactionListFragment();
687 throw new IllegalStateException(
688 String.format("Unexpected fragment index: " + "%d", position));
693 public int getCount() {