@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.network_monitor_content); final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); final ViewPager pager = (ViewPager) findViewById(R.id.network_monitor_pager); final FragmentManager fm = getSupportFragmentManager(); if (pager != null) { final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.network_monitor_pager_tabs); pagerTabs.addTabLabels( R.string.network_monitor_peer_list_title, R.string.network_monitor_block_list_title); final PagerAdapter pagerAdapter = new PagerAdapter(fm); pager.setAdapter(pagerAdapter); pager.setOnPageChangeListener(pagerTabs); pager.setPageMargin(2); pager.setPageMarginDrawable(R.color.bg_less_bright); peerListFragment = new PeerListFragment(); blockListFragment = new BlockListFragment(); } else { peerListFragment = (PeerListFragment) fm.findFragmentById(R.id.peer_list_fragment); blockListFragment = (BlockListFragment) fm.findFragmentById(R.id.block_list_fragment); } }
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.address_book_content); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); final FragmentManager fragmentManager = getFragmentManager(); walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT); sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT); final FragmentTransaction removal = fragmentManager.beginTransaction(); if (walletAddressesFragment == null) walletAddressesFragment = new WalletAddressesFragment(); else removal.remove(walletAddressesFragment); if (sendingAddressesFragment == null) sendingAddressesFragment = new SendingAddressesFragment(); else removal.remove(sendingAddressesFragment); if (!removal.isEmpty()) { removal.commit(); fragmentManager.executePendingTransactions(); } final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager); if (pager != null) { pager.setAdapter( new TwoFragmentAdapter( fragmentManager, walletAddressesFragment, sendingAddressesFragment)); final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs); pagerTabs.addTabLabels( R.string.address_book_list_receiving_title, R.string.address_book_list_sending_title); pager.setOnPageChangeListener(pagerTabs); final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0; pager.setCurrentItem(position); pager.setPageMargin(2); pager.setPageMarginDrawable(R.color.bg_less_bright); pagerTabs.onPageSelected(position); pagerTabs.onPageScrolled(position, 0, 0); } else { fragmentManager .beginTransaction() .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT) .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT) .commit(); } updateFragments(); }