src/main/java/de/blau/android/util/SelectByImageFragment.java
/**
     * Create the view we want to display
     * 
     * @param savedInstanceState the saved state if any
     * @return the View
     */
Create the view we want to display

@param savedInstanceState the saved state if any
@return the View
Create the view we want to display @param savedInstanceState the saved state if any @return the View
@NonNull
    private View createView(@Nullable Bundle savedInstanceState) {
        FragmentActivity activity = getActivity();
        LayoutInflater themedInflater = ThemeUtils.getLayoutInflater(activity);
        int startPos = 0;
        if (savedInstanceState == null) {
            Log.d(DEBUG_TAG, "Initializing from intent");
            imageList = getArguments().getStringArrayList(IMAGE_LIST_KEY);
            startPos = getArguments().getInt(START_POS_KEY);
            imageLoader = (ImageLoader) getArguments().getSerializable(IMAGE_LOADER_KEY);
            getArguments().remove(IMAGE_LOADER_KEY);
        } else {
            Log.d(DEBUG_TAG, "Initializing from saved state");
            imageList = savedInstanceState.getStringArrayList(IMAGE_LIST_KEY);
            startPos = savedInstanceState.getInt(START_POS_KEY);
            imageLoader = (ImageLoader) savedInstanceState.getSerializable(IMAGE_LOADER_KEY);
        }
        View layout = themedInflater.inflate(R.layout.photo_viewer, null);
        ImagePagerAdapter imagePagerAdapter = new ImagePagerAdapter(activity, imageLoader);
        viewPager = (ViewPager) layout.findViewById(R.id.pager);
        viewPager.setAdapter(imagePagerAdapter);
        viewPager.setOffscreenPageLimit(2);
        viewPager.setCurrentItem(startPos);
        viewPager.addOnPageChangeListener(new OnPageSelectedListener() {
            @Override
            public void onPageSelected(int page) {
                if (imageLoader != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode()) {
                    imageLoader.showOnMap(getContext(), page);
                }
            }
        });
        ActionMenuView menuView = (ActionMenuView) layout.findViewById(R.id.photoMenuView);
        Menu menu = menuView.getMenu();
        MenuItem itemBackward = menu.add(Menu.NONE, MENUITEM_BACK, Menu.NONE, R.string.back).setIcon(R.drawable.ic_arrow_back_white_36dp);
        itemBackward.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        itemBackward.setEnabled(true);
        itemBackward.setIcon(R.drawable.ic_arrow_back_white_36dp);
        MenuItem itemForward = menu.add(Menu.NONE, MENUITEM_FORWARD, Menu.NONE, R.string.forward).setIcon(R.drawable.ic_arrow_forward_white_36dp);
        itemForward.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        itemForward.setEnabled(true);
        itemForward.setIcon(R.drawable.ic_arrow_forward_white_36dp);
        menuView.setOnMenuItemClickListener(this);
        return layout;
    }
@ NonNull private View createView ( @ Nullable Bundle savedInstanceState ) { FragmentActivity activity = getActivity ( ) ; LayoutInflater themedInflater = ThemeUtils . getLayoutInflater ( activity ) ; int startPos = 0 ; if ( savedInstanceState == null ) { Log . d ( DEBUG_TAG , "Initializing from intent" ) ; imageList = getArguments ( ) . getStringArrayList ( IMAGE_LIST_KEY ) ; startPos = getArguments ( ) . getInt ( START_POS_KEY ) ; imageLoader = ( ImageLoader ) getArguments ( ) . getSerializable ( IMAGE_LOADER_KEY ) ; getArguments ( ) . remove ( IMAGE_LOADER_KEY ) ; } else { Log . d ( DEBUG_TAG , "Initializing from saved state" ) ; imageList = savedInstanceState . getStringArrayList ( IMAGE_LIST_KEY ) ; startPos = savedInstanceState . getInt ( START_POS_KEY ) ; imageLoader = ( ImageLoader ) savedInstanceState . getSerializable ( IMAGE_LOADER_KEY ) ; } View layout = themedInflater . inflate ( R . layout . photo_viewer , null ) ; ImagePagerAdapter imagePagerAdapter = new ImagePagerAdapter ( activity , imageLoader ) ; viewPager = ( ViewPager ) layout . findViewById ( R . id . pager ) ; viewPager . setAdapter ( imagePagerAdapter ) ; viewPager . setOffscreenPageLimit ( 2 ) ; viewPager . setCurrentItem ( startPos ) ; viewPager . addOnPageChangeListener ( new OnPageSelectedListener ( ) { @ Override public void onPageSelected ( int page ) { if ( imageLoader != null && Build . VERSION . SDK_INT >= Build . VERSION_CODES . N && activity . isInMultiWindowMode ( ) ) { imageLoader . showOnMap ( getContext ( ) , page ) ; } } } ) ; ActionMenuView menuView = ( ActionMenuView ) layout . findViewById ( R . id . photoMenuView ) ; Menu menu = menuView . getMenu ( ) ; MenuItem itemBackward = menu . add ( Menu . NONE , MENUITEM_BACK , Menu . NONE , R . string . back ) . setIcon ( R . drawable . ic_arrow_back_white_36dp ) ; itemBackward . setShowAsAction ( MenuItem . SHOW_AS_ACTION_ALWAYS ) ; itemBackward . setEnabled ( true ) ; itemBackward . setIcon ( R . drawable . ic_arrow_back_white_36dp ) ; MenuItem itemForward = menu . add ( Menu . NONE , MENUITEM_FORWARD , Menu . NONE , R . string . forward ) . setIcon ( R . drawable . ic_arrow_forward_white_36dp ) ; itemForward . setShowAsAction ( MenuItem . SHOW_AS_ACTION_ALWAYS ) ; itemForward . setEnabled ( true ) ; itemForward . setIcon ( R . drawable . ic_arrow_forward_white_36dp ) ; menuView . setOnMenuItemClickListener ( this ) ; return layout ; }
Create the view we want to display
Create the view we want to display
// doing this in single window mode is very annoying so we don't