use of androidx.viewpager2.widget.ViewPager2 in project collect by opendatakit.
the class QRCodeTabsActivity method setupViewPager.
private void setupViewPager() {
fragmentTitleList = new String[] { getString(R.string.scan_qr_code_fragment_title), getString(R.string.view_qr_code_fragment_title) };
ViewPager2 viewPager = findViewById(R.id.viewPager);
TabLayout tabLayout = findViewById(R.id.tabLayout);
QRCodeTabsAdapter adapter = new QRCodeTabsAdapter(this);
viewPager.setAdapter(adapter);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(fragmentTitleList[position])).attach();
}
use of androidx.viewpager2.widget.ViewPager2 in project banner by youth5201314.
the class ScrollSpeedManger method reflectLayoutManager.
public static void reflectLayoutManager(Banner banner) {
if (banner.getScrollTime() < 100)
return;
try {
ViewPager2 viewPager2 = banner.getViewPager2();
RecyclerView recyclerView = (RecyclerView) viewPager2.getChildAt(0);
recyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
ScrollSpeedManger speedManger = new ScrollSpeedManger(banner, (LinearLayoutManager) recyclerView.getLayoutManager());
recyclerView.setLayoutManager(speedManger);
Field LayoutMangerField = ViewPager2.class.getDeclaredField("mLayoutManager");
LayoutMangerField.setAccessible(true);
LayoutMangerField.set(viewPager2, speedManger);
Field pageTransformerAdapterField = ViewPager2.class.getDeclaredField("mPageTransformerAdapter");
pageTransformerAdapterField.setAccessible(true);
Object mPageTransformerAdapter = pageTransformerAdapterField.get(viewPager2);
if (mPageTransformerAdapter != null) {
Class<?> aClass = mPageTransformerAdapter.getClass();
Field layoutManager = aClass.getDeclaredField("mLayoutManager");
layoutManager.setAccessible(true);
layoutManager.set(mPageTransformerAdapter, speedManger);
}
Field scrollEventAdapterField = ViewPager2.class.getDeclaredField("mScrollEventAdapter");
scrollEventAdapterField.setAccessible(true);
Object mScrollEventAdapter = scrollEventAdapterField.get(viewPager2);
if (mScrollEventAdapter != null) {
Class<?> aClass = mScrollEventAdapter.getClass();
Field layoutManager = aClass.getDeclaredField("mLayoutManager");
layoutManager.setAccessible(true);
layoutManager.set(mScrollEventAdapter, speedManger);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of androidx.viewpager2.widget.ViewPager2 in project banner by youth5201314.
the class MZScaleInTransformer method requireViewPager.
private ViewPager2 requireViewPager(@NonNull View page) {
ViewParent parent = page.getParent();
ViewParent parentParent = parent.getParent();
if (parent instanceof RecyclerView && parentParent instanceof ViewPager2) {
return (ViewPager2) parentParent;
}
throw new IllegalStateException("Expected the page view to be managed by a ViewPager2 instance.");
}
Aggregations