I have a ViewPager which have contains two different fragments. We assume that they names are A and B fragments. One of these fragments has a date validation process. When a user attempts to navigate to B from A, if the selected date is later than today, the ViewPager turns back to Fragment A (rejecting navigation to B).
This is provided with onPageScrolled like below.
@Override public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) { if ( position == 0 ) { if ( positionOffset > 0.5 && getLastCycleDay() > DateHelper.CreateToday( false ) ) { mPager.setCurrentItem( 1 ); SnackbarHelper.newInstance().snackbarshow( IntroActivity.this, resources.getString( R.string.dont_allow_new_cycle ) ); } } My question is which onPageScrolled works twice and when I want to run a method in that, this method also works twice.
How can I prevent this situation ?
