When I switched to viewPager2 I had to implement another type of adapter (I used FragmentPagerAdapter and now I use FragmentStateAdapter), now I want to call the instantiateItem element that had the old adapter but it doesn't appear in the new one.
public void onPageChange(int position) {
//I cannot call instantiateItem from pagerAdapter
Object object = pagerAdapter.instantiateItem(mMainViewPager,position);
if (object instanceof MapFragment) {
MapFragment fragment = (MapFragment) object;
//fragment.setDevice(mDevice);
//fragment.setLastTracking();
}
if (object instanceof DevicesFragment) {
DevicesFragment fragment = (DevicesFragment) object;
//fragment.refresh();
}
}