Merge "Fixes for animated vector drawables"

This commit is contained in:
Diego Perez
2017-02-14 12:23:08 +00:00
committed by Android (Google) Code Review
3 changed files with 15 additions and 25 deletions

View File

@@ -863,29 +863,6 @@ public class VectorDrawable_Delegate {
}
mLocalMatrix.set(copy.mLocalMatrix);
final ArrayList<Object> children = copy.mChildren;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < children.size(); i++) {
Object copyChild = children.get(i);
if (copyChild instanceof VGroup_Delegate) {
VGroup_Delegate copyGroup = (VGroup_Delegate) copyChild;
mChildren.add(new VGroup_Delegate(copyGroup, targetsMap));
} else {
VPath_Delegate newPath;
if (copyChild instanceof VFullPath_Delegate) {
newPath = new VFullPath_Delegate((VFullPath_Delegate) copyChild);
} else if (copyChild instanceof VClipPath_Delegate) {
newPath = new VClipPath_Delegate((VClipPath_Delegate) copyChild);
} else {
throw new IllegalStateException("Unknown object in the tree!");
}
mChildren.add(newPath);
if (newPath.mPathName != null) {
targetsMap.put(newPath.mPathName, newPath);
}
}
}
}
private VGroup_Delegate() {

View File

@@ -38,7 +38,10 @@ import org.xmlpull.v1.XmlPullParser;
import android.annotation.NonNull;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.NumberPicker;
import java.io.File;
@@ -401,6 +404,15 @@ public final class BridgeInflater extends LayoutInflater {
numberPicker.setMaxValue(Integer.parseInt(maxValue));
}
}
else if (view instanceof ImageView) {
ImageView img = (ImageView) view;
Drawable drawable = img.getDrawable();
if (drawable instanceof Animatable) {
if (!((Animatable) drawable).isRunning()) {
((Animatable) drawable).start();
}
}
}
}
}

View File

@@ -18,6 +18,7 @@ package android.view;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.layoutlib.bridge.Bridge;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
import com.android.tools.layoutlib.java.System_Delegate;
import java.lang.reflect.Field;
import java.util.concurrent.atomic.AtomicReference;
@@ -54,8 +55,8 @@ public class Choreographer_Delegate {
public static void doFrame(long frameTimeNanos) {
Choreographer thisChoreographer = Choreographer.getInstance();
thisChoreographer.mLastFrameTimeNanos = frameTimeNanos;
thisChoreographer.mLastFrameTimeNanos = frameTimeNanos - thisChoreographer
.getFrameIntervalNanos();
thisChoreographer.mFrameInfo.markInputHandlingStart();
thisChoreographer.doCallbacks(Choreographer.CALLBACK_INPUT, frameTimeNanos);