Add test for private API forceAnimationOnUI
b/27343522 Change-Id: I5167a159f5630ab064f434930f3056754e2c0f44
This commit is contained in:
@@ -23,6 +23,4 @@ LOCAL_PACKAGE_NAME := VectorDrawableTest
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.test.dynamic" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" />
|
||||
|
||||
<application
|
||||
android:hardwareAccelerated="true"
|
||||
android:label="vector"
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener {
|
||||
private static final String LOGCAT = "AnimatedVectorDrawableTest";
|
||||
@@ -45,35 +46,51 @@ public class AnimatedVectorDrawableTest extends Activity implements View.OnClick
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
final int[] layerTypes = {View.LAYER_TYPE_SOFTWARE, View.LAYER_TYPE_HARDWARE};
|
||||
final boolean[] forceOnUi = {false, true};
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ScrollView scrollView = new ScrollView(this);
|
||||
GridLayout container = new GridLayout(this);
|
||||
scrollView.addView(container);
|
||||
container.setColumnCount(2);
|
||||
container.setColumnCount(layerTypes.length * forceOnUi.length);
|
||||
|
||||
for (int j = 0; j < layerTypes.length; j++) {
|
||||
for (int k = 0; k < forceOnUi.length; k++) {
|
||||
TextView textView = new TextView(this);
|
||||
String category = "Layer:"
|
||||
+ (layerTypes[j] == View.LAYER_TYPE_SOFTWARE ? "SW" : "HW")
|
||||
+ (forceOnUi[k] == true ? ",forceUI" : "");
|
||||
textView.setText(category);
|
||||
container.addView(textView);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < icon.length; i++) {
|
||||
for (int j = 0; j < layerTypes.length; j++) {
|
||||
Button button = new Button(this);
|
||||
button.setWidth(400);
|
||||
button.setHeight(400);
|
||||
button.setLayerType(layerTypes[j], null);
|
||||
button.setBackgroundResource(icon[i]);
|
||||
AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
|
||||
d.registerAnimationCallback(new Animatable2.AnimationCallback() {
|
||||
@Override
|
||||
public void onAnimationStart(Drawable drawable) {
|
||||
Log.v(LOGCAT, "Animator start");
|
||||
for (int k = 0; k < forceOnUi.length; k++) {
|
||||
Button button = new Button(this);
|
||||
button.setWidth(300);
|
||||
button.setHeight(300);
|
||||
button.setLayerType(layerTypes[j], null);
|
||||
button.setBackgroundResource(icon[i]);
|
||||
AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
|
||||
if (forceOnUi[k] == true) {
|
||||
d.forceAnimationOnUI();
|
||||
}
|
||||
d.registerAnimationCallback(new Animatable2.AnimationCallback() {
|
||||
@Override
|
||||
public void onAnimationStart(Drawable drawable) {
|
||||
Log.v(LOGCAT, "Animator start");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Drawable drawable) {
|
||||
Log.v(LOGCAT, "Animator end");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onAnimationEnd(Drawable drawable) {
|
||||
Log.v(LOGCAT, "Animator end");
|
||||
}
|
||||
});
|
||||
|
||||
container.addView(button);
|
||||
button.setOnClickListener(this);
|
||||
container.addView(button);
|
||||
button.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user