android: add animationEnd callback for image
This commit is contained in:
parent
e1b10b10bb
commit
96e61e2268
@ -60,6 +60,7 @@ import java.io.File;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
|
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.async.AsyncResult;
|
import pub.doric.async.AsyncResult;
|
||||||
import pub.doric.extension.bridge.DoricMethod;
|
import pub.doric.extension.bridge.DoricMethod;
|
||||||
@ -86,6 +87,7 @@ public class ImageNode extends ViewNode<ImageView> {
|
|||||||
private int errorColor = Color.TRANSPARENT;
|
private int errorColor = Color.TRANSPARENT;
|
||||||
private JSObject stretchInset = null;
|
private JSObject stretchInset = null;
|
||||||
private float imageScale = DoricUtils.getScreenScale();
|
private float imageScale = DoricUtils.getScreenScale();
|
||||||
|
private Animatable2Compat.AnimationCallback animationCallback = null;
|
||||||
|
|
||||||
public ImageNode(DoricContext doricContext) {
|
public ImageNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
@ -325,6 +327,9 @@ public class ImageNode extends ViewNode<ImageView> {
|
|||||||
.toJSONObject());
|
.toJSONObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (resource instanceof Animatable2Compat && animationCallback != null) {
|
||||||
|
((Animatable2Compat) resource).registerAnimationCallback(animationCallback);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).into(new DrawableImageViewTarget(mView) {
|
}).into(new DrawableImageViewTarget(mView) {
|
||||||
@ -499,6 +504,18 @@ public class ImageNode extends ViewNode<ImageView> {
|
|||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
loadIntoTarget(Glide.with(getContext()).load(file));
|
loadIntoTarget(Glide.with(getContext()).load(file));
|
||||||
break;
|
break;
|
||||||
|
case "onAnimationEnd":
|
||||||
|
if (!prop.isString()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String functionId = prop.asString().value();
|
||||||
|
animationCallback = new Animatable2Compat.AnimationCallback() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Drawable drawable) {
|
||||||
|
callJSResponse(functionId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
super.blend(view, name, prop);
|
super.blend(view, name, prop);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user