Search in sources :

Example 1 with DepthPageTransformer

use of org.horaapps.leafpic.animations.DepthPageTransformer in project LeafPic by HoraApps.

the class SingleMediaActivity method initUI.

private void initUI() {
    setSupportActionBar(toolbar);
    toolbar.bringToFront();
    toolbar.setNavigationIcon(getToolbarIcon(CommunityMaterial.Icon.cmd_arrow_left));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    setRecentApp(getString(R.string.app_name));
    setupSystemUI();
    getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
                showSystemUI();
            else
                hideSystemUI();
        }
    });
    adapter = new MediaPagerAdapter(getSupportFragmentManager(), getAlbum().getMedia());
    adapter.setVideoOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (SP.getBoolean("set_internal_player", false)) {
                Intent mpdIntent = new Intent(SingleMediaActivity.this, PlayerActivity.class).setData(getAlbum().getCurrentMedia().getUri());
                startActivity(mpdIntent);
            } else {
                Intent intentOpenWith = new Intent(Intent.ACTION_VIEW);
                intentOpenWith.setDataAndType(getAlbum().getMedia().get(mViewPager.getCurrentItem()).getUri(), getAlbum().getMedia().get(mViewPager.getCurrentItem()).getMimeType());
                startActivity(intentOpenWith);
            }
        }
    });
    getSupportActionBar().setTitle((getAlbum().getCurrentMediaIndex() + 1) + " " + getString(R.string.of) + " " + getAlbum().getMedia().size());
    mViewPager.setAdapter(adapter);
    mViewPager.setCurrentItem(getAlbum().getCurrentMediaIndex());
    mViewPager.setPageTransformer(true, new DepthPageTransformer());
    mViewPager.setOffscreenPageLimit(3);
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            getAlbum().setCurrentPhotoIndex(position);
            toolbar.setTitle((position + 1) + " " + getString(R.string.of) + " " + getAlbum().getMedia().size());
            invalidateOptionsMenu();
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    Display aa = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
    if (aa.getRotation() == Surface.ROTATION_90) {
        Configuration configuration = new Configuration();
        configuration.orientation = Configuration.ORIENTATION_LANDSCAPE;
        onConfigurationChanged(configuration);
    }
}
Also used : DepthPageTransformer(org.horaapps.leafpic.animations.DepthPageTransformer) Configuration(android.content.res.Configuration) MediaPagerAdapter(org.horaapps.leafpic.adapters.MediaPagerAdapter) Intent(android.content.Intent) View(android.view.View) HackyViewPager(org.horaapps.leafpic.views.HackyViewPager) ViewPager(android.support.v4.view.ViewPager) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 2 with DepthPageTransformer

use of org.horaapps.leafpic.animations.DepthPageTransformer in project LeafPic by HoraApps.

the class SingleMediaActivity method initUi.

private void initUi() {
    setSupportActionBar(toolbar);
    toolbar.bringToFront();
    toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
    toolbar.setNavigationOnClickListener(v -> onBackPressed());
    setupSystemUI();
    getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(visibility -> {
        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0)
            showSystemUI();
        else
            hideSystemUI();
    });
    updatePageTitle(position);
    mViewPager.setAdapter(adapter);
    mViewPager.setCurrentItem(position);
    useImageMenu = isCurrentMediaImage();
    mViewPager.setPageTransformer(true, AnimationUtils.getPageTransformer(new DepthPageTransformer()));
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            SingleMediaActivity.this.position = position;
            updatePageTitle(position);
            // Invalidate the options menu only when we aren't using the correct menu
            if (isCurrentMediaImage() == useImageMenu)
                return;
            supportInvalidateOptionsMenu();
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    if (((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getRotation() == Surface.ROTATION_90) {
        Configuration configuration = new Configuration();
        configuration.orientation = Configuration.ORIENTATION_LANDSCAPE;
        onConfigurationChanged(configuration);
    }
}
Also used : DepthPageTransformer(org.horaapps.leafpic.animations.DepthPageTransformer) Configuration(android.content.res.Configuration) HackyViewPager(org.horaapps.leafpic.views.HackyViewPager) ViewPager(android.support.v4.view.ViewPager) WindowManager(android.view.WindowManager)

Aggregations

Configuration (android.content.res.Configuration)2 ViewPager (android.support.v4.view.ViewPager)2 WindowManager (android.view.WindowManager)2 DepthPageTransformer (org.horaapps.leafpic.animations.DepthPageTransformer)2 HackyViewPager (org.horaapps.leafpic.views.HackyViewPager)2 Intent (android.content.Intent)1 Display (android.view.Display)1 View (android.view.View)1 MediaPagerAdapter (org.horaapps.leafpic.adapters.MediaPagerAdapter)1