use of com.taobao.weex.common.WXImageSharpen in project weex-example by KalicyZhou.
the class WXImage method setRemoteSrc.
private void setRemoteSrc(Uri rewrited) {
WXImageStrategy imageStrategy = new WXImageStrategy();
imageStrategy.isClipping = true;
WXImageSharpen imageSharpen = getDomObject().getAttrs().getImageSharpen();
imageStrategy.isSharpen = imageSharpen == WXImageSharpen.SHARPEN;
int radius = getDomObject().getStyles().getBlur();
radius = Math.max(0, radius);
imageStrategy.blurRadius = Math.min(10, radius);
imageStrategy.setImageListener(new WXImageStrategy.ImageListener() {
@Override
public void onImageFinish(String url, ImageView imageView, boolean result, Map extra) {
if (getDomObject() != null && getDomObject().getEvents().contains(Constants.Event.ONLOAD)) {
Map<String, Object> params = new HashMap<String, Object>();
Map<String, Object> size = new HashMap<>(2);
if (imageView != null && imageView.getDrawable() != null && imageView.getDrawable() instanceof ImageDrawable) {
size.put("naturalWidth", ((ImageDrawable) imageView.getDrawable()).getBitmapWidth());
size.put("naturalHeight", ((ImageDrawable) imageView.getDrawable()).getBitmapHeight());
} else {
size.put("naturalWidth", 0);
size.put("naturalHeight", 0);
}
if (getDomObject() != null && containsEvent(Constants.Event.ONLOAD)) {
params.put("success", result);
params.put("size", size);
fireEvent(Constants.Event.ONLOAD, params);
}
}
}
});
String placeholder = null;
if (getDomObject().getAttrs().containsKey(Constants.Name.PLACEHOLDER)) {
placeholder = (String) getDomObject().getAttrs().get(Constants.Name.PLACEHOLDER);
} else if (getDomObject().getAttrs().containsKey(Constants.Name.PLACE_HOLDER)) {
placeholder = (String) getDomObject().getAttrs().get(Constants.Name.PLACE_HOLDER);
}
if (placeholder != null) {
imageStrategy.placeHolder = getInstance().rewriteUri(Uri.parse(placeholder), URIAdapter.IMAGE).toString();
}
IWXImgLoaderAdapter imgLoaderAdapter = getInstance().getImgLoaderAdapter();
if (imgLoaderAdapter != null) {
imgLoaderAdapter.setImage(rewrited.toString(), getHostView(), getDomObject().getAttrs().getImageQuality(), imageStrategy);
}
}
use of com.taobao.weex.common.WXImageSharpen in project weex-example by KalicyZhou.
the class WXAttr method getImageSharpen.
public WXImageSharpen getImageSharpen() {
Object obj = get(Constants.Name.SHARPEN);
if (obj == null) {
obj = get(Constants.Name.IMAGE_SHARPEN);
}
if (obj == null) {
return WXImageSharpen.UNSHARPEN;
}
String imageSharpen = obj.toString();
WXImageSharpen waImageSharpen = WXImageSharpen.UNSHARPEN;
if (imageSharpen.equals("sharpen")) {
waImageSharpen = WXImageSharpen.SHARPEN;
}
return waImageSharpen;
}
Aggregations