private OnPageChangeListener createWizardDialogPageChangeListener ( @ NonNull final WizardDialog wizardDialog ) { return new OnPageChangeListener ( ) { @ Override public void onPageScrolled ( final int position , final float positionOffset , final int positionOffsetPixels ) { } @ Override public void onPageSelected ( final int position ) { int [ ] colors = getResources ( ) . getIntArray ( R . array . wizard_dialog_background_colors ) ; BackgroundAnimation backgroundAnimation = new CrossFadeTransitionAnimation . Builder ( getActivity ( ) ) . create ( ) ; wizardDialog . setBackgroundColor ( colors [ position ] , backgroundAnimation ) ; TypedArray backgroundIds = getResources ( ) . obtainTypedArray ( R . array . wizard_dialog_header_backgrounds ) ; BackgroundAnimation headerBackgroundAnimation = new CircleTransitionAnimation . Builder ( getActivity ( ) ) . setListener ( createHeaderAnimationListener ( wizardDialog ) ) . create ( ) ; wizardDialog . setHeaderBackground ( backgroundIds . getResourceId ( position , 0 ) , headerBackgroundAnimation ) ; backgroundIds . recycle ( ) ; TypedArray iconIds = getResources ( ) . obtainTypedArray ( R . array . wizard_dialog_header_icons ) ; DrawableAnimation headerIconAnimation = new ScaleTransitionAnimation . Builder ( getActivity ( ) ) . create ( ) ; wizardDialog . setHeaderIcon ( iconIds . getResourceId ( position , 0 ) , headerIconAnimation ) ; iconIds . recycle ( ) ; } @ Override public void onPageScrollStateChanged ( final int state ) { } } ; }
Creates and returns a listener which allows to change the background color of the wizard dialog when its view pager is scrolled .