use of android.support.design.widget.TabLayout in project ZhihuDailyPurify by izzyleung.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
layoutResID = R.layout.activity_main;
super.onCreate(savedInstanceState);
TabLayout tabs = (TabLayout) findViewById(R.id.main_pager_tabs);
ViewPager viewPager = (ViewPager) findViewById(R.id.main_pager);
assert tabs != null;
assert viewPager != null;
viewPager.setOffscreenPageLimit(PAGE_COUNT);
MainPagerAdapter adapter = new MainPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(adapter);
tabs.setupWithViewPager(viewPager);
FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_pick_date);
assert floatingActionButton != null;
floatingActionButton.setOnClickListener(v -> prepareIntent(PickDateActivity.class));
}
use of android.support.design.widget.TabLayout in project chuck by jgilfelt.
the class TransactionActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chuck_activity_transaction);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
title = (TextView) findViewById(R.id.toolbar_title);
final ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
if (viewPager != null) {
setupViewPager(viewPager);
}
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
transactionId = getIntent().getLongExtra(ARG_TRANSACTION_ID, 0);
getSupportLoaderManager().initLoader(0, null, this);
}
use of android.support.design.widget.TabLayout in project materialistic by hidroh.
the class ItemActivityTest method testScrollToTop.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollToTop() {
Intent intent = new Intent();
intent.putExtra(ItemActivity.EXTRA_ITEM, new TestItem() {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
@Override
public String getId() {
return "1";
}
@Override
public boolean isStoryType() {
return true;
}
@Override
public int getKidCount() {
return 10;
}
@Override
public String getUrl() {
return "http://example.com";
}
});
controller.withIntent(intent).create().start().resume();
// see https://github.com/robolectric/robolectric/issues/1326
ShadowLooper.pauseMainLooper();
controller.visible();
ShadowApplication.getInstance().getForegroundThreadScheduler().advanceToLastPostedRunnable();
RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
recyclerView.smoothScrollToPosition(1);
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(1);
TabLayout tabLayout = (TabLayout) activity.findViewById(R.id.tab_layout);
assertThat(tabLayout.getTabCount()).isEqualTo(2);
tabLayout.getTabAt(1).select();
tabLayout.getTabAt(0).select();
tabLayout.getTabAt(0).select();
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(0);
}
use of android.support.design.widget.TabLayout in project materialistic by hidroh.
the class HelpLazyLoadView method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText(R.string.comments));
tabLayout.addTab(tabLayout.newTab().setText(R.string.article));
Preferences.StoryViewMode defaultView = Preferences.getDefaultStoryView(getContext());
int defaultTab;
switch(defaultView) {
case Comment:
default:
defaultTab = 0;
break;
case Article:
case Readability:
defaultTab = 1;
break;
}
//noinspection ConstantConditions
tabLayout.getTabAt(defaultTab).select();
}
use of android.support.design.widget.TabLayout in project materialistic by hidroh.
the class BaseListActivityLandTest method testScrollItemToTop.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollItemToTop() {
activity.onItemSelected(new TestHnItem(1L) {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
});
TabLayout tabLayout = (TabLayout) activity.findViewById(R.id.tab_layout);
assertThat(tabLayout.getTabCount()).isEqualTo(2);
tabLayout.getTabAt(0).select();
ViewPager viewPager = (ViewPager) activity.findViewById(R.id.content);
viewPager.getAdapter().instantiateItem(viewPager, 0);
viewPager.getAdapter().finishUpdate(viewPager);
RecyclerView itemRecyclerView = (RecyclerView) viewPager.findViewById(R.id.recycler_view);
itemRecyclerView.smoothScrollToPosition(1);
assertThat(customShadowOf(itemRecyclerView).getScrollPosition()).isEqualTo(1);
tabLayout.getTabAt(1).select();
tabLayout.getTabAt(0).select();
tabLayout.getTabAt(0).select();
assertThat(customShadowOf(itemRecyclerView).getScrollPosition()).isEqualTo(0);
}
Aggregations