use of android.support.design.widget.TabLayout in project zype-android by zype.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
for (int i = 0; i < tabLayout.getTabCount(); i++) {
TabLayout.Tab tab = tabLayout.getTabAt(i);
tab.setCustomView(mSectionsPagerAdapter.getTabView(i));
}
SettingsParamsBuilder settingsParamsBuilder = new SettingsParamsBuilder();
getApi().executeRequest(WebApiManager.Request.GET_SETTINGS, settingsParamsBuilder.build());
if (ZypeConfiguration.isNativeSubscriptionEnabled(this)) {
new BillingManager(this, this);
}
}
use of android.support.design.widget.TabLayout in project twicalico by moko256.
the class ShowUserActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_user);
subscription = new CompositeSubscription();
setSupportActionBar(findViewById(R.id.toolbar_show_user));
actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white_24dp);
viewPager = findViewById(R.id.show_user_view_pager);
viewPager.setOffscreenPageLimit(1);
tabLayout = findViewById(R.id.tab_show_user);
tabLayout.setupWithViewPager(viewPager);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
Fragment fragment = ((FragmentPagerAdapter) viewPager.getAdapter()).getFragment(tab.getPosition());
if (fragment instanceof MovableTopInterface) {
((MovableTopInterface) fragment).moveToTop();
}
}
});
tweetListViewPool = new RecyclerView.RecycledViewPool();
userListViewPool = new RecyclerView.RecycledViewPool();
findViewById(R.id.activity_show_user_fab).setOnClickListener(v -> {
if (user != null) {
startActivity(PostActivity.getIntent(this, TwitterStringUtils.plusAtMark(user.getScreenName()) + " "));
}
});
userScreenName = getIntent().getStringExtra("userScreenName");
userId = getIntent().getLongExtra("userId", -1);
if (userId != -1) {
user = GlobalApplication.userCache.get(userId);
}
if (user != null) {
new ShowUserFragmentsPagerAdapter(getSupportFragmentManager(), this, user.getId()).initAdapter(viewPager);
} else {
subscription.add(getUserSingle().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(it -> {
user = it;
new ShowUserFragmentsPagerAdapter(getSupportFragmentManager(), this, it.getId()).initAdapter(viewPager);
}, e -> Snackbar.make(findViewById(getSnackBarParentContainerId()), TwitterStringUtils.convertErrorToText(e), Snackbar.LENGTH_INDEFINITE).show()));
}
}
Aggregations