use of android.support.v4.view.ViewPager in project philm by chrisbanes.
the class BasePhilmTabFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_viewpager, container, false);
mAdapter = new TabPagerAdapter(getChildFragmentManager());
mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
mViewPager.setAdapter(mAdapter);
mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.spacing_minor));
mTabLayout = (TabLayout) view.findViewById(R.id.viewpager_tabs);
mTabLayout.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) {
final Fragment fragment = mAdapter.getItem(tab.getPosition());
if (fragment instanceof ListFragment) {
((ListFragment) fragment).smoothScrollTo(0);
}
}
});
if (savedInstanceState != null) {
mCurrentItem = savedInstanceState.getInt(SAVE_SELECTED_TAB);
}
return view;
}
use of android.support.v4.view.ViewPager in project cheesesquare by chrisbanes.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.ic_menu);
ab.setDisplayHomeAsUpEnabled(true);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
if (navigationView != null) {
setupDrawerContent(navigationView);
}
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
if (viewPager != null) {
setupViewPager(viewPager);
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
});
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
use of android.support.v4.view.ViewPager in project cw-omnibus by commonsguy.
the class PagerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View result = inflater.inflate(R.layout.pager, container, false);
ViewPager pager = (ViewPager) result.findViewById(R.id.pager);
pager.setAdapter(buildAdapter());
return (result);
}
use of android.support.v4.view.ViewPager 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);
}
use of android.support.v4.view.ViewPager in project materialistic by hidroh.
the class BaseListActivityLandTest method testDefaultReadabilityView.
@Test
public void testDefaultReadabilityView() {
PreferenceManager.getDefaultSharedPreferences(activity).edit().putString(activity.getString(R.string.pref_story_display), activity.getString(R.string.pref_story_display_value_readability)).apply();
controller.pause().resume();
activity.onItemSelected(new TestHnItem(1L) {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
});
ViewPager viewPager = (ViewPager) activity.findViewById(R.id.content);
viewPager.getAdapter().instantiateItem(viewPager, viewPager.getCurrentItem());
assertStoryMode();
}
Aggregations