| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.transition; |
| 18 |
|
| 19 |
import android.animation.Animator; |
| 20 |
import android.animation.ObjectAnimator; |
| 21 |
import android.view.View; |
| 22 |
import android.view.ViewGroup; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public class Rotate extends Transition { |
| 31 |
|
| 32 |
private static final String PROPNAME_ROTATION = "android:rotate:rotation"; |
| 33 |
|
| 34 |
@Override |
| 35 |
public void captureStartValues(TransitionValues transitionValues) { |
| 36 |
transitionValues.values.put(PROPNAME_ROTATION, transitionValues.view.getRotation()); |
| 37 |
} |
| 38 |
|
| 39 |
@Override |
| 40 |
public void captureEndValues(TransitionValues transitionValues) { |
| 41 |
transitionValues.values.put(PROPNAME_ROTATION, transitionValues.view.getRotation()); |
| 42 |
} |
| 43 |
|
| 44 |
@Override |
| 45 |
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, |
| 46 |
TransitionValues endValues) { |
| 47 |
if (startValues == null || endValues == null) { |
| 48 |
return null; |
| 49 |
} |
| 50 |
final View view = endValues.view; |
| 51 |
float startRotation = (Float) startValues.values.get(PROPNAME_ROTATION); |
| 52 |
float endRotation = (Float) endValues.values.get(PROPNAME_ROTATION); |
| 53 |
if (startRotation != endRotation) { |
| 54 |
view.setRotation(startRotation); |
| 55 |
return ObjectAnimator.ofFloat(view, View.ROTATION, |
| 56 |
startRotation, endRotation); |
| 57 |
} |
| 58 |
return null; |
| 59 |
} |
| 60 |
} |