@Override public void onCreate(Bundle savedInstanceState) { // it is necessary to set the view first before calling super because of the nav drawer in // BaseDrawerActivity setContentView(R.layout.activity_accounts); super.onCreate(savedInstanceState); final Intent intent = getIntent(); handleOpenFileIntent(intent); init(); mPager = (ViewPager) findViewById(R.id.pager); mTitlePageIndicator = (TitlePageIndicator) findViewById(R.id.titles); String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_INSERT_OR_EDIT)) { // enter account creation/edit mode if that was specified mPager.setVisibility(View.GONE); mTitlePageIndicator.setVisibility(View.GONE); String accountUID = intent.getStringExtra(UxArgument.SELECTED_ACCOUNT_UID); if (accountUID != null) showEditAccountFragment(accountUID); else { String parentAccountUID = intent.getStringExtra(UxArgument.PARENT_ACCOUNT_UID); showAddAccountFragment(parentAccountUID); } } else { // show the simple accounts list PagerAdapter mPagerAdapter = new AccountViewPagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter); mTitlePageIndicator.setViewPager(mPager); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); int lastTabIndex = preferences.getInt(LAST_OPEN_TAB_INDEX, INDEX_TOP_LEVEL_ACCOUNTS_FRAGMENT); int index = intent.getIntExtra(EXTRA_TAB_INDEX, lastTabIndex); mPager.setCurrentItem(index); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_transactions); ViewPager pager = (ViewPager) findViewById(R.id.pager); mTitlePageIndicator = (TitlePageIndicator) findViewById(R.id.titles); mSectionHeaderTransactions = (TextView) findViewById(R.id.section_header_transactions); if (sLastTitleColor == -1) // if this is first launch of app. Previous launches would have set the color already sLastTitleColor = getResources().getColor(R.color.title_green); mAccountId = getIntent().getLongExtra(UxArgument.SELECTED_ACCOUNT_ID, -1); mAccountsDbAdapter = new AccountsDbAdapter(this); setupActionBarNavigation(); if (getIntent().getAction().equals(Intent.ACTION_INSERT_OR_EDIT)) { pager.setVisibility(View.GONE); mTitlePageIndicator.setVisibility(View.GONE); initializeCreateOrEditTransaction(); } else { // load the transactions list mSectionHeaderTransactions.setVisibility(View.GONE); PagerAdapter pagerAdapter = new AccountViewPagerAdapter(getSupportFragmentManager()); pager.setAdapter(pagerAdapter); mTitlePageIndicator.setViewPager(pager); pager.setCurrentItem(INDEX_TRANSACTIONS_FRAGMENT); } // done creating, activity now running mActivityRunning = true; }