am cb721bf6: Merge "Supporrt tapas build for vector tests" into lmp-mr1-dev
* commit 'cb721bf674e3b36a7c16fcc8f61646404d348bd3': Supporrt tapas build for vector tests
This commit is contained in:
@@ -23,4 +23,6 @@ LOCAL_PACKAGE_NAME := VectorDrawableTest
|
|||||||
|
|
||||||
LOCAL_MODULE_TAGS := tests
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
|
||||||
|
LOCAL_SDK_VERSION := current
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
include $(BUILD_PACKAGE)
|
||||||
|
|||||||
@@ -17,11 +17,18 @@ import android.app.Activity;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.VectorDrawable;
|
import android.graphics.drawable.VectorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.Xml;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.GridLayout;
|
import android.widget.GridLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"})
|
@SuppressWarnings({"UnusedDeclaration"})
|
||||||
@@ -60,6 +67,31 @@ public class VectorDrawablePerformance extends Activity {
|
|||||||
R.drawable.vector_drawable30,
|
R.drawable.vector_drawable30,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static VectorDrawable create(Resources resources, int rid) {
|
||||||
|
try {
|
||||||
|
final XmlPullParser parser = resources.getXml(rid);
|
||||||
|
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
|
int type;
|
||||||
|
while ((type=parser.next()) != XmlPullParser.START_TAG &&
|
||||||
|
type != XmlPullParser.END_DOCUMENT) {
|
||||||
|
// Empty loop
|
||||||
|
}
|
||||||
|
if (type != XmlPullParser.START_TAG) {
|
||||||
|
throw new XmlPullParserException("No start tag found");
|
||||||
|
}
|
||||||
|
|
||||||
|
final VectorDrawable drawable = new VectorDrawable();
|
||||||
|
drawable.inflate(resources, parser, attrs);
|
||||||
|
|
||||||
|
return drawable;
|
||||||
|
} catch (XmlPullParserException e) {
|
||||||
|
Log.e(LOGCAT, "parser error", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(LOGCAT, "parser error", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -72,7 +104,7 @@ public class VectorDrawablePerformance extends Activity {
|
|||||||
VectorDrawable []d = new VectorDrawable[icon.length];
|
VectorDrawable []d = new VectorDrawable[icon.length];
|
||||||
long time = android.os.SystemClock.elapsedRealtimeNanos();
|
long time = android.os.SystemClock.elapsedRealtimeNanos();
|
||||||
for (int i = 0; i < icon.length; i++) {
|
for (int i = 0; i < icon.length; i++) {
|
||||||
d[i] = VectorDrawable.create(res,icon[i]);
|
d[i] = create(res,icon[i]);
|
||||||
}
|
}
|
||||||
time = android.os.SystemClock.elapsedRealtimeNanos()-time;
|
time = android.os.SystemClock.elapsedRealtimeNanos()-time;
|
||||||
TextView t = new TextView(this);
|
TextView t = new TextView(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user