Search in sources :

Example 1 with DepthPageTransformer

use of com.alexvasilkov.gestures.commons.DepthPageTransformer in project GestureViews by alexvasilkov.

the class Ex6AdvancedDemoActivity method initPager.

private void initPager() {
    // Setting up pager views
    pagerAdapter = new PhotoPagerAdapter(views.pager);
    pagerAdapter.setSetupListener(settingsMenu);
    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());
    views.pagerToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    views.pagerToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(@NonNull View view) {
            onBackPressed();
        }
    });
    onCreateOptionsMenuFullMode(views.pagerToolbar.getMenu());
    views.pagerToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelectedFullMode(item);
        }
    });
}
Also used : DepthPageTransformer(com.alexvasilkov.gestures.commons.DepthPageTransformer) PhotoPagerAdapter(com.alexvasilkov.gestures.sample.adapters.PhotoPagerAdapter) MenuItem(android.view.MenuItem) ViewPager(android.support.v4.view.ViewPager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with DepthPageTransformer

use of com.alexvasilkov.gestures.commons.DepthPageTransformer in project GestureViews by alexvasilkov.

the class BaseComplexListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.complex_list_screen);
    final RecyclerView list = findViewById(R.id.complex_list);
    pager = findViewById(R.id.complex_pager);
    pagerBackground = findViewById(R.id.complex_pager_background);
    final List<ListItem> items = createItems();
    // Setting up recycler view
    list.setLayoutManager(new LinearLayoutManager(this));
    list.setAdapter(new ListAdapter(items, this::onImageClick));
    // Setting up pager view
    pagerAdapter = new PagerAdapter(pager, getSettingsController());
    pager.setAdapter(pagerAdapter);
    pager.setPageTransformer(true, new DepthPageTransformer());
    // Setting up animator
    animator = createAnimator(list, pager);
    animator.addPositionUpdateListener(this::applyImageAnimationState);
}
Also used : DepthPageTransformer(com.alexvasilkov.gestures.commons.DepthPageTransformer) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 3 with DepthPageTransformer

use of com.alexvasilkov.gestures.commons.DepthPageTransformer 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

DepthPageTransformer (com.alexvasilkov.gestures.commons.DepthPageTransformer)3 ViewPager (android.support.v4.view.ViewPager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 PhotoPagerAdapter (com.alexvasilkov.gestures.sample.adapters.PhotoPagerAdapter)1 PhotoPagerAdapter (com.alexvasilkov.gestures.sample.demo.adapter.PhotoPagerAdapter)1