Android Open Source - AndroidImageSlider Flip Page View Transformer






From Project

Back to project page AndroidImageSlider.

License

The source code is released under:

MIT License

If you think the Android project AndroidImageSlider listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.daimajia.slider.library.Transformers;
/* ww w . j  a  v a2 s.c  o  m*/
import android.os.Build;
import android.view.View;

import com.daimajia.slider.library.Tricks.ViewPagerEx;
import com.nineoldandroids.view.ViewHelper;

public class FlipPageViewTransformer extends BaseTransformer {

    @Override
    protected void onTransform(View view, float position) {
        float percentage = 1 - Math.abs(position);
        if(Build.VERSION.SDK_INT >= 13){
            view.setCameraDistance(12000);
        }
        setVisibility(view, position);
        setTranslation(view);
        setSize(view, position, percentage);
        setRotation(view, position, percentage);
    }

    private void setVisibility(View page, float position) {
        if (position < 0.5 && position > -0.5) {
            page.setVisibility(View.VISIBLE);
        } else {
            page.setVisibility(View.INVISIBLE);
        }
    }

    private void setTranslation(View view) {
        ViewPagerEx viewPager = (ViewPagerEx) view.getParent();
        int scroll = viewPager.getScrollX() - view.getLeft();
        ViewHelper.setTranslationX(view,scroll);
    }

    private void setSize(View view, float position, float percentage) {
        ViewHelper.setScaleX(view,(position != 0 && position != 1) ? percentage : 1);
        ViewHelper.setScaleY(view,(position != 0 && position != 1) ? percentage : 1);
    }

    private void setRotation(View view, float position, float percentage) {
        if (position > 0) {
            ViewHelper.setRotationY(view,-180 * (percentage + 1));
        } else {
            ViewHelper.setRotationY(view,180 * (percentage + 1));
        }
    }
}




Java Source Code List

com.daimajia.slider.demo.ChildAnimationExample.java
com.daimajia.slider.demo.MainActivity.java
com.daimajia.slider.demo.TransformerAdapter.java
com.daimajia.slider.library.SliderAdapter.java
com.daimajia.slider.library.SliderLayout.java
com.daimajia.slider.library.Animations.BaseAnimationInterface.java
com.daimajia.slider.library.Animations.DescriptionAnimation.java
com.daimajia.slider.library.Indicators.PagerIndicator.java
com.daimajia.slider.library.SliderTypes.BaseSliderView.java
com.daimajia.slider.library.SliderTypes.DefaultSliderView.java
com.daimajia.slider.library.SliderTypes.TextSliderView.java
com.daimajia.slider.library.Transformers.AccordionTransformer.java
com.daimajia.slider.library.Transformers.BackgroundToForegroundTransformer.java
com.daimajia.slider.library.Transformers.BaseTransformer.java
com.daimajia.slider.library.Transformers.CubeInTransformer.java
com.daimajia.slider.library.Transformers.DefaultTransformer.java
com.daimajia.slider.library.Transformers.DepthPageTransformer.java
com.daimajia.slider.library.Transformers.FadeTransformer.java
com.daimajia.slider.library.Transformers.FlipHorizontalTransformer.java
com.daimajia.slider.library.Transformers.FlipPageViewTransformer.java
com.daimajia.slider.library.Transformers.ForegroundToBackgroundTransformer.java
com.daimajia.slider.library.Transformers.RotateDownTransformer.java
com.daimajia.slider.library.Transformers.RotateUpTransformer.java
com.daimajia.slider.library.Transformers.StackTransformer.java
com.daimajia.slider.library.Transformers.TabletTransformer.java
com.daimajia.slider.library.Transformers.ZoomInTransformer.java
com.daimajia.slider.library.Transformers.ZoomOutSlideTransformer.java
com.daimajia.slider.library.Transformers.ZoomOutTransformer.java
com.daimajia.slider.library.Tricks.FixedSpeedScroller.java
com.daimajia.slider.library.Tricks.InfinitePagerAdapter.java
com.daimajia.slider.library.Tricks.InfiniteViewPager.java
com.daimajia.slider.library.Tricks.ViewPagerEx.java