use of de.schildbach.wallet.util.ViewPagerTabs in project bitcoin-wallet by bitcoin-wallet.
the class NetworkMonitorActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.network_monitor_content);
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);
}
}
use of de.schildbach.wallet.util.ViewPagerTabs in project bitcoin-wallet by bitcoin-wallet.
the class NetworkMonitorActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.network_monitor_content);
final ViewPager2 pager = findViewById(R.id.network_monitor_pager);
final ViewPagerTabs pagerTabs = findViewById(R.id.network_monitor_pager_tabs);
pagerTabs.addTabLabels(TAB_LABELS);
final boolean twoPanes = getResources().getBoolean(R.bool.network_monitor_two_panes);
if (twoPanes) {
final RecyclerView recyclerView = (RecyclerView) pager.getChildAt(0);
recyclerView.setClipToPadding(false);
recyclerView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
final int width = recyclerView.getWidth();
recyclerView.setPadding(0, 0, width / 2, 0);
pager.setCurrentItem(0);
});
pager.setUserInputEnabled(false);
pagerTabs.setMode(ViewPagerTabs.Mode.STATIC);
} else {
pager.setPageTransformer(new ZoomOutPageTransformer());
pager.registerOnPageChangeCallback(pagerTabs.getPageChangeCallback());
pagerTabs.setMode(ViewPagerTabs.Mode.DYNAMIC);
}
pager.setOffscreenPageLimit(1);
pager.setAdapter(new PagerAdapter());
}
use of de.schildbach.wallet.util.ViewPagerTabs in project bitcoin-wallet by bitcoin-wallet.
the class AddressBookActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final FragmentManager fragmentManager = getSupportFragmentManager();
setContentView(R.layout.address_book_content);
final ViewPager2 pager = findViewById(R.id.address_book_pager);
final ViewPagerTabs pagerTabs = findViewById(R.id.address_book_pager_tabs);
pagerTabs.addTabLabels(TAB_LABELS);
final boolean twoPanes = getResources().getBoolean(R.bool.address_book_two_panes);
walletActivityViewModel = new ViewModelProvider(this).get(AbstractWalletActivityViewModel.class);
walletActivityViewModel.wallet.observe(this, wallet -> invalidateOptionsMenu());
viewModel = new ViewModelProvider(this).get(AddressBookViewModel.class);
viewModel.pageTo.observe(this, new Event.Observer<Integer>() {
@Override
protected void onEvent(final Integer position) {
if (!twoPanes)
pager.setCurrentItem(position, true);
}
});
viewModel.showEditAddressBookEntryDialog.observe(this, new Event.Observer<Address>() {
@Override
protected void onEvent(final Address address) {
EditAddressBookEntryFragment.edit(fragmentManager, address);
}
});
viewModel.showScanOwnAddressDialog.observe(this, new Event.Observer<Void>() {
@Override
protected void onEvent(final Void v) {
final DialogBuilder dialog = DialogBuilder.dialog(AddressBookActivity.this, R.string.address_book_options_scan_title, R.string.address_book_options_scan_own_address);
dialog.singleDismissButton(null);
dialog.show();
}
});
viewModel.showScanInvalidDialog.observe(this, new Event.Observer<Void>() {
@Override
protected void onEvent(final Void v) {
final DialogBuilder dialog = DialogBuilder.dialog(AddressBookActivity.this, R.string.address_book_options_scan_title, R.string.address_book_options_scan_invalid);
dialog.singleDismissButton(null);
dialog.show();
}
});
if (twoPanes) {
final RecyclerView recyclerView = (RecyclerView) pager.getChildAt(0);
recyclerView.setClipToPadding(false);
recyclerView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
final int width = recyclerView.getWidth();
recyclerView.setPadding(0, 0, width / 2, 0);
pager.setCurrentItem(0);
});
pager.setUserInputEnabled(false);
pagerTabs.setMode(ViewPagerTabs.Mode.STATIC);
} else {
pager.setPageTransformer(new ZoomOutPageTransformer());
pager.registerOnPageChangeCallback(pagerTabs.getPageChangeCallback());
pagerTabs.setMode(ViewPagerTabs.Mode.DYNAMIC);
}
pager.setOffscreenPageLimit(1);
pager.setAdapter(new AddressBookActivity.PagerAdapter());
}
Aggregations