code format
This commit is contained in:
parent
8e021133bb
commit
78ba91030f
@ -40,6 +40,7 @@ import android.widget.ImageView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestBuilder;
|
import com.bumptech.glide.RequestBuilder;
|
||||||
@ -53,7 +54,6 @@ import com.bumptech.glide.request.target.DrawableImageViewTarget;
|
|||||||
import com.bumptech.glide.request.target.SizeReadyCallback;
|
import com.bumptech.glide.request.target.SizeReadyCallback;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.facebook.yoga.YogaNode;
|
import com.facebook.yoga.YogaNode;
|
||||||
import com.github.pengfeizhou.jscore.JSNumber;
|
|
||||||
import com.github.pengfeizhou.jscore.JSONBuilder;
|
import com.github.pengfeizhou.jscore.JSONBuilder;
|
||||||
import com.github.pengfeizhou.jscore.JSObject;
|
import com.github.pengfeizhou.jscore.JSObject;
|
||||||
import com.github.pengfeizhou.jscore.JSValue;
|
import com.github.pengfeizhou.jscore.JSValue;
|
||||||
@ -62,10 +62,9 @@ import com.github.pengfeizhou.jscore.JavaValue;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
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;
|
||||||
@ -353,65 +352,65 @@ public class ImageNode extends ViewNode<ImageView> {
|
|||||||
}
|
}
|
||||||
}).into(new DrawableImageViewTarget(mView) {
|
}).into(new DrawableImageViewTarget(mView) {
|
||||||
|
|
||||||
@SuppressLint("MissingSuperCall")
|
@SuppressLint("MissingSuperCall")
|
||||||
@Override
|
@Override
|
||||||
public void getSize(@NonNull SizeReadyCallback cb) {
|
public void getSize(@NonNull SizeReadyCallback cb) {
|
||||||
cb.onSizeReady(SIZE_ORIGINAL, SIZE_ORIGINAL);
|
cb.onSizeReady(SIZE_ORIGINAL, SIZE_ORIGINAL);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setResource(@Nullable Drawable resource) {
|
|
||||||
if (resource instanceof BitmapDrawable) {
|
|
||||||
Bitmap bitmap = ((BitmapDrawable) resource).getBitmap();
|
|
||||||
float scale = DoricUtils.getScreenScale() / imageScale;
|
|
||||||
if (imageScale != DoricUtils.getScreenScale()) {
|
|
||||||
Matrix matrix = new Matrix();
|
|
||||||
matrix.setScale(scale, scale);
|
|
||||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
|
||||||
resource = new BitmapDrawable(getContext().getResources(), bitmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scaleType == 3) { // image tile
|
@Override
|
||||||
BitmapDrawable drawable = new BitmapDrawable(getContext().getResources(), bitmap);
|
protected void setResource(@Nullable Drawable resource) {
|
||||||
drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
|
if (resource instanceof BitmapDrawable) {
|
||||||
drawable.setDither(true);
|
Bitmap bitmap = ((BitmapDrawable) resource).getBitmap();
|
||||||
super.setResource(drawable);
|
float scale = DoricUtils.getScreenScale() / imageScale;
|
||||||
} else if (stretchInset != null) {
|
if (imageScale != DoricUtils.getScreenScale()) {
|
||||||
float left = stretchInset.getProperty("left").asNumber().toFloat() * scale;
|
Matrix matrix = new Matrix();
|
||||||
float top = stretchInset.getProperty("top").asNumber().toFloat() * scale;
|
matrix.setScale(scale, scale);
|
||||||
float right = stretchInset.getProperty("right").asNumber().toFloat() * scale;
|
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||||
float bottom = stretchInset.getProperty("bottom").asNumber().toFloat() * scale;
|
resource = new BitmapDrawable(getContext().getResources(), bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
Rect rect = new Rect(
|
if (scaleType == 3) { // image tile
|
||||||
(int) left,
|
BitmapDrawable drawable = new BitmapDrawable(getContext().getResources(), bitmap);
|
||||||
(int) top,
|
drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
|
||||||
(int) (bitmap.getWidth() - right),
|
drawable.setDither(true);
|
||||||
(int) (bitmap.getHeight() - bottom)
|
super.setResource(drawable);
|
||||||
);
|
} else if (stretchInset != null) {
|
||||||
|
float left = stretchInset.getProperty("left").asNumber().toFloat() * scale;
|
||||||
|
float top = stretchInset.getProperty("top").asNumber().toFloat() * scale;
|
||||||
|
float right = stretchInset.getProperty("right").asNumber().toFloat() * scale;
|
||||||
|
float bottom = stretchInset.getProperty("bottom").asNumber().toFloat() * scale;
|
||||||
|
|
||||||
NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(
|
Rect rect = new Rect(
|
||||||
getContext().getResources(),
|
(int) left,
|
||||||
bitmap,
|
(int) top,
|
||||||
DoricUtils.getNinePatchChunk(rect),
|
(int) (bitmap.getWidth() - right),
|
||||||
rect,
|
(int) (bitmap.getHeight() - bottom)
|
||||||
null
|
);
|
||||||
);
|
|
||||||
super.setResource(ninePatchDrawable);
|
NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(
|
||||||
} else {
|
getContext().getResources(),
|
||||||
super.setResource(resource);
|
bitmap,
|
||||||
|
DoricUtils.getNinePatchChunk(rect),
|
||||||
|
rect,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
super.setResource(ninePatchDrawable);
|
||||||
|
} else {
|
||||||
|
super.setResource(resource);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
super.setResource(resource);
|
||||||
|
}
|
||||||
|
if (mSuperNode instanceof FlexNode) {
|
||||||
|
YogaNode node = ((FlexNode) mSuperNode).mView.getYogaNodeForView(mView);
|
||||||
|
if (node != null) {
|
||||||
|
node.dirty();
|
||||||
|
}
|
||||||
|
mView.requestLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
super.setResource(resource);
|
|
||||||
}
|
|
||||||
if (mSuperNode instanceof FlexNode) {
|
|
||||||
YogaNode node = ((FlexNode) mSuperNode).mView.getYogaNodeForView(mView);
|
|
||||||
if (node != null) {
|
|
||||||
node.dirty();
|
|
||||||
}
|
|
||||||
mView.requestLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user