Android Open Source - Swipe-Tabs Tablet Transformer From Project Back to project page Swipe-Tabs .
License The source code is released under:
MIT License
If you think the Android project Swipe-Tabs 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 it.bellotti.android.swipetabs.transforms;
/ / f r o m w w w . j a v a 2 s . c o m
import android.graphics.Camera;
import android.graphics.Matrix;
import android.view.View;
/**
* Created with IntelliJ IDEA.
* User: SimoneBellotti
* Date: 24/11/2014
* Time: 13.08
*/
public class TabletTransformer extends BaseTransformer {
private static final Matrix OFFSET_MATRIX = new Matrix();
private static final Camera OFFSET_CAMERA = new Camera();
private static final float [] OFFSET_TEMP_FLOAT = new float [2];
@Override
protected void onTransform(View view, float position) {
final float rotation = (position < 0 ? 30f : -30f) * Math.abs(position);
view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight()));
view.setPivotX(view.getWidth() * 0.5f);
view.setPivotY(0);
view.setRotationY(rotation);
}
protected final float getOffsetXForRotation(float degrees, int width, int height) {
OFFSET_MATRIX.reset();
OFFSET_CAMERA.save();
OFFSET_CAMERA.rotateY(Math.abs(degrees));
OFFSET_CAMERA.getMatrix(OFFSET_MATRIX);
OFFSET_CAMERA.restore();
OFFSET_MATRIX.preTranslate(-width * 0.5f, -height * 0.5f);
OFFSET_MATRIX.postTranslate(width * 0.5f, height * 0.5f);
OFFSET_TEMP_FLOAT[0] = width;
OFFSET_TEMP_FLOAT[1] = height;
OFFSET_MATRIX.mapPoints(OFFSET_TEMP_FLOAT);
return (width - OFFSET_TEMP_FLOAT[0]) * (degrees > 0.0f ? 1.0f : -1.0f);
}
}
Java Source Code List it.bellotti.android.swipetabs.activities.MainActivity.java it.bellotti.android.swipetabs.adapters.TabsPagerAdapter.java it.bellotti.android.swipetabs.fragments.CalendarFragment.java it.bellotti.android.swipetabs.fragments.HomeFragment.java it.bellotti.android.swipetabs.fragments.StatisticsFragment.java it.bellotti.android.swipetabs.transforms.AccordionTransformer.java it.bellotti.android.swipetabs.transforms.AlphaTransformer.java it.bellotti.android.swipetabs.transforms.BackgroundToForegroundTransformer.java it.bellotti.android.swipetabs.transforms.BaseTransformer.java it.bellotti.android.swipetabs.transforms.CubeInTransformer.java it.bellotti.android.swipetabs.transforms.CubeOutTransformer.java it.bellotti.android.swipetabs.transforms.DepthPageTransformer.java it.bellotti.android.swipetabs.transforms.FlipHorizontalTransformer.java it.bellotti.android.swipetabs.transforms.FlipVerticalTransformer.java it.bellotti.android.swipetabs.transforms.ForegroundToBackgroundTransformer.java it.bellotti.android.swipetabs.transforms.ParallaxPageTransformer.java it.bellotti.android.swipetabs.transforms.RotateDownTransformer.java it.bellotti.android.swipetabs.transforms.RotateUpTransformer.java it.bellotti.android.swipetabs.transforms.RotationPageTransformer.java it.bellotti.android.swipetabs.transforms.ScalePageTransformer.java it.bellotti.android.swipetabs.transforms.StackTransformer.java it.bellotti.android.swipetabs.transforms.TabletTransformer.java it.bellotti.android.swipetabs.transforms.ZoomInPageTransformer.java it.bellotti.android.swipetabs.transforms.ZoomOutPageTransformer.java it.bellotti.android.swipetabs.transforms.ZoomOutSlideTransformer.java