am d89c7bec: Merge "Add translationZ/Z methods to ViewPropertyAnimatorCompat" into lmp-mr1-ub-dev
* commit 'd89c7bec4d0f9bb268f97fe091e3a1c1634977c9':
Add translationZ/Z methods to ViewPropertyAnimatorCompat
diff --git a/v4/api/current.txt b/v4/api/current.txt
index 7609df0..d10c7cb 100644
--- a/v4/api/current.txt
+++ b/v4/api/current.txt
@@ -2446,6 +2446,8 @@
method public android.support.v4.view.ViewPropertyAnimatorCompat translationXBy(float);
method public android.support.v4.view.ViewPropertyAnimatorCompat translationY(float);
method public android.support.v4.view.ViewPropertyAnimatorCompat translationYBy(float);
+ method public android.support.v4.view.ViewPropertyAnimatorCompat translationZ(float);
+ method public android.support.v4.view.ViewPropertyAnimatorCompat translationZBy(float);
method public android.support.v4.view.ViewPropertyAnimatorCompat withEndAction(java.lang.Runnable);
method public android.support.v4.view.ViewPropertyAnimatorCompat withLayer();
method public android.support.v4.view.ViewPropertyAnimatorCompat withStartAction(java.lang.Runnable);
@@ -2453,6 +2455,8 @@
method public android.support.v4.view.ViewPropertyAnimatorCompat xBy(float);
method public android.support.v4.view.ViewPropertyAnimatorCompat y(float);
method public android.support.v4.view.ViewPropertyAnimatorCompat yBy(float);
+ method public android.support.v4.view.ViewPropertyAnimatorCompat z(float);
+ method public android.support.v4.view.ViewPropertyAnimatorCompat zBy(float);
}
public abstract interface ViewPropertyAnimatorListener {
diff --git a/v4/api21/android/support/v4/view/ViewPropertyAnimatorCompatLollipop.java b/v4/api21/android/support/v4/view/ViewPropertyAnimatorCompatLollipop.java
new file mode 100644
index 0000000..3bfc427
--- /dev/null
+++ b/v4/api21/android/support/v4/view/ViewPropertyAnimatorCompatLollipop.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.view;
+
+import android.view.View;
+
+class ViewPropertyAnimatorCompatLollipop {
+
+ public static void translationZ(View view, float value) {
+ view.animate().translationZ(value);
+ }
+
+ public static void translationZBy(View view, float value) {
+ view.animate().translationZBy(value);
+ }
+
+ public static void z(View view, float value) {
+ view.animate().z(value);
+ }
+
+ public static void zBy(View view, float value) {
+ view.animate().zBy(value);
+ }
+
+}
diff --git a/v4/java/android/support/v4/view/ViewPropertyAnimatorCompat.java b/v4/java/android/support/v4/view/ViewPropertyAnimatorCompat.java
index 8813929..c4a2145 100644
--- a/v4/java/android/support/v4/view/ViewPropertyAnimatorCompat.java
+++ b/v4/java/android/support/v4/view/ViewPropertyAnimatorCompat.java
@@ -60,10 +60,14 @@
public void xBy(ViewPropertyAnimatorCompat vpa, View view, float value);
public void y(ViewPropertyAnimatorCompat vpa, View view, float value);
public void yBy(ViewPropertyAnimatorCompat vpa, View view, float value);
+ public void z(ViewPropertyAnimatorCompat vpa, View view, float value);
+ public void zBy(ViewPropertyAnimatorCompat vpa, View view, float value);
public void translationX(ViewPropertyAnimatorCompat vpa, View view, float value);
public void translationXBy(ViewPropertyAnimatorCompat vpa, View view, float value);
public void translationY(ViewPropertyAnimatorCompat vpa, View view, float value);
public void translationYBy(ViewPropertyAnimatorCompat vpa, View view, float value);
+ public void translationZ(ViewPropertyAnimatorCompat vpa, View view, float value);
+ public void translationZBy(ViewPropertyAnimatorCompat vpa, View view, float value);
public void start(ViewPropertyAnimatorCompat vpa, View view);
public void withLayer(ViewPropertyAnimatorCompat vpa, View view);
public void withStartAction(ViewPropertyAnimatorCompat vpa, View view, Runnable runnable);
@@ -228,6 +232,16 @@
}
@Override
+ public void z(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ // noop on versions prior to Lollipop
+ }
+
+ @Override
+ public void zBy(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ // noop on versions prior to Lollipop
+ }
+
+ @Override
public void translationXBy(ViewPropertyAnimatorCompat vpa, View view, float value) {
// noop on versions prior to ICS
postStartMessage(vpa, view);
@@ -240,6 +254,16 @@
}
@Override
+ public void translationZ(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ // noop on versions prior to Lollipop
+ }
+
+ @Override
+ public void translationZBy(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ // noop on versions prior to Lollipop
+ }
+
+ @Override
public void start(ViewPropertyAnimatorCompat vpa, View view) {
removeStartMessage(view);
startAnimation(vpa, view);
@@ -594,10 +618,34 @@
}
}
+ static class LollipopViewPropertyAnimatorCompatImpl extends KitKatViewPropertyAnimatorCompatImpl {
+ @Override
+ public void translationZ(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ ViewPropertyAnimatorCompatLollipop.translationZ(view, value);
+ }
+
+ @Override
+ public void translationZBy(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ ViewPropertyAnimatorCompatLollipop.translationZBy(view, value);
+ }
+
+ @Override
+ public void z(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ ViewPropertyAnimatorCompatLollipop.z(view, value);
+ }
+
+ @Override
+ public void zBy(ViewPropertyAnimatorCompat vpa, View view, float value) {
+ ViewPropertyAnimatorCompatLollipop.zBy(view, value);
+ }
+ }
+
static final ViewPropertyAnimatorCompatImpl IMPL;
static {
final int version = android.os.Build.VERSION.SDK_INT;
- if (version >= 19) {
+ if (version >= 21) {
+ IMPL = new LollipopViewPropertyAnimatorCompatImpl();
+ } else if (version >= 19) {
IMPL = new KitKatViewPropertyAnimatorCompatImpl();
} else if (version >= 18) {
IMPL = new JBMr2ViewPropertyAnimatorCompatImpl();
@@ -1105,6 +1153,74 @@
}
/**
+ * This method will cause the View's <code>translationZ</code> property to be animated by the
+ * specified value. Animations already running on the property will be canceled.
+ *
+ * <p>Prior to API 21, this method will do nothing.</p>
+ *
+ * @param value The amount to be animated by, as an offset from the current value.
+ * @return This object, allowing calls to methods in this class to be chained.
+ */
+ public ViewPropertyAnimatorCompat translationZBy(float value) {
+ View view;
+ if ((view = mView.get()) != null) {
+ IMPL.translationZBy(this, view, value);
+ }
+ return this;
+ }
+
+ /**
+ * This method will cause the View's <code>translationZ</code> property to be animated to the
+ * specified value. Animations already running on the property will be canceled.
+ *
+ * <p>Prior to API 21, this method will do nothing.</p>
+ *
+ * @param value The amount to be animated by, as an offset from the current value.
+ * @return This object, allowing calls to methods in this class to be chained.
+ */
+ public ViewPropertyAnimatorCompat translationZ(float value) {
+ View view;
+ if ((view = mView.get()) != null) {
+ IMPL.translationZ(this, view, value);
+ }
+ return this;
+ }
+
+ /**
+ * This method will cause the View's <code>z</code> property to be animated to the
+ * specified value. Animations already running on the property will be canceled.
+ *
+ * <p>Prior to API 21, this method will do nothing.</p>
+ *
+ * @param value The amount to be animated by, as an offset from the current value.
+ * @return This object, allowing calls to methods in this class to be chained.
+ */
+ public ViewPropertyAnimatorCompat z(float value) {
+ View view;
+ if ((view = mView.get()) != null) {
+ IMPL.z(this, view, value);
+ }
+ return this;
+ }
+
+ /**
+ * This method will cause the View's <code>z</code> property to be animated by the
+ * specified value. Animations already running on the property will be canceled.
+ *
+ * <p>Prior to API 21, this method will do nothing.</p>
+ *
+ * @param value The amount to be animated by, as an offset from the current value.
+ * @return This object, allowing calls to methods in this class to be chained.
+ */
+ public ViewPropertyAnimatorCompat zBy(float value) {
+ View view;
+ if ((view = mView.get()) != null) {
+ IMPL.zBy(this, view, value);
+ }
+ return this;
+ }
+
+ /**
* Starts the currently pending property animations immediately. Calling <code>start()</code>
* is optional because all animations start automatically at the next opportunity. However,
* if the animations are needed to start immediately and synchronously (not at the time when