Search in sources :

Example 1 with PhotoPagerAdapter

use of com.alexvasilkov.gestures.sample.demo.adapter.PhotoPagerAdapter in project GestureViews by alexvasilkov.

the class DemoActivity method initPager.

/**
 * Initializing pager and fullscreen mode.
 */
private void initPager() {
    // Setting up pager adapter
    pagerAdapter = new PhotoPagerAdapter(views.pager, getSettingsController());
    pagerListener = new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            onPhotoInPagerSelected(position);
        }
    };
    views.pager.setAdapter(pagerAdapter);
    views.pager.addOnPageChangeListener(pagerListener);
    views.pager.setPageTransformer(true, new DepthPageTransformer());
    // Setting up pager toolbar
    views.pagerToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    views.pagerToolbar.setNavigationOnClickListener(view -> onBackPressed());
    // Enabling immersive mode by clicking on full screen image
    pagerAdapter.setImageClickListener(() -> {
        if (!listAnimator.isLeaving()) {
            // Toggle immersive mode
            showSystemUi(!isSystemUiShown());
        }
    });
    getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(visibility -> views.pagerToolbar.animate().alpha(isSystemUiShown() ? 1f : 0f));
}
Also used : DepthPageTransformer(com.alexvasilkov.gestures.commons.DepthPageTransformer) PhotoPagerAdapter(com.alexvasilkov.gestures.sample.demo.adapter.PhotoPagerAdapter) ViewPager(android.support.v4.view.ViewPager)

Aggregations

ViewPager (android.support.v4.view.ViewPager)1 DepthPageTransformer (com.alexvasilkov.gestures.commons.DepthPageTransformer)1 PhotoPagerAdapter (com.alexvasilkov.gestures.sample.demo.adapter.PhotoPagerAdapter)1