本文整理汇总了Java中com.taobao.weex.adapter.IWXImgLoaderAdapter.setImage方法的典型用法代码示例。如果您正苦于以下问题:Java IWXImgLoaderAdapter.setImage方法的具体用法?Java IWXImgLoaderAdapter.setImage怎么用?Java IWXImgLoaderAdapter.setImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.weex.adapter.IWXImgLoaderAdapter
的用法示例。
在下文中一共展示了IWXImgLoaderAdapter.setImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSrc
import com.taobao.weex.adapter.IWXImgLoaderAdapter; //导入方法依赖的package包/类
@WXComponentProp(name = Constants.Name.SRC)
public void setSrc(String src) {
WXImageStrategy imageStrategy = new WXImageStrategy();
imageStrategy.isClipping = true;
WXImageSharpen imageSharpen = getDomObject().getAttrs().getImageSharpen();
imageStrategy.isSharpen = imageSharpen == WXImageSharpen.SHARPEN;
imageStrategy.setImageListener(new WXImageStrategy.ImageListener() {
@Override
public void onImageFinish(String url,ImageView imageView, boolean result, Map extra) {
if(!result && imageView!=null){
imageView.setImageDrawable(null);
}
if(getDomObject()!=null && getDomObject().containsEvent(Constants.Event.ONLOAD)){
Map<String,Object> params=new HashMap<String, Object>();
params.put("success",result);
getInstance().fireEvent(getDomObject().getRef(), Constants.Event.ONLOAD,params);
}
}
});
if( getDomObject().getAttrs().containsKey(Constants.Name.PLACE_HOLDER)){
String placeHolder= (String) getDomObject().getAttrs().get(Constants.Name.PLACE_HOLDER);
imageStrategy.placeHolder=placeHolder;
}
IWXImgLoaderAdapter imgLoaderAdapter = getInstance().getImgLoaderAdapter();
if (imgLoaderAdapter != null) {
imgLoaderAdapter.setImage(src, getHostView(),
getDomObject().getAttrs().getImageQuality(), imageStrategy);
}
}
示例2: setSrc
import com.taobao.weex.adapter.IWXImgLoaderAdapter; //导入方法依赖的package包/类
@WXComponentProp(name = WXDomPropConstant.WX_ATTR_SRC)
public void setSrc(String src) {
WXImageStrategy imageStrategy = new WXImageStrategy();
imageStrategy.isClipping = true;
WXImageSharpen imageSharpen = mDomObj.attr.getImageSharpen();
imageStrategy.isSharpen = imageSharpen == WXImageSharpen.SHARPEN;
IWXImgLoaderAdapter imgLoaderAdapter = mInstance.getImgLoaderAdapter();
if (imgLoaderAdapter != null) {
imgLoaderAdapter.setImage(src, ((ImageView) getView()),
mDomObj.attr.getImageQuality(), imageStrategy);
}
}
示例3: setRemoteSrc
import com.taobao.weex.adapter.IWXImgLoaderAdapter; //导入方法依赖的package包/类
private void setRemoteSrc(Uri rewrited,int blurRadius) {
WXImageStrategy imageStrategy = new WXImageStrategy();
imageStrategy.isClipping = true;
WXImageSharpen imageSharpen = getDomObject().getAttrs().getImageSharpen();
imageStrategy.isSharpen = imageSharpen == WXImageSharpen.SHARPEN;
imageStrategy.blurRadius = Math.max(0, blurRadius);
this.mBlurRadius = blurRadius;
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 instanceof Measurable) {
size.put("naturalWidth", ((Measurable) imageView).getNaturalWidth());
size.put("naturalHeight", ((Measurable) imageView).getNaturalHeight());
} 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);
}
}
示例4: setRemoteSrc
import com.taobao.weex.adapter.IWXImgLoaderAdapter; //导入方法依赖的package包/类
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);
}
}
}
});
WXSDKInstance instance = getInstance();
if (getDomObject().getAttrs().containsKey(Constants.Name.PLACE_HOLDER)) {
String attr = (String) getDomObject().getAttrs().get(Constants.Name.PLACE_HOLDER);
if (TextUtils.isEmpty(attr)) {
imageStrategy.placeHolder = instance.rewriteUri(Uri.parse(attr), URIAdapter.IMAGE).toString();
}
}
IWXImgLoaderAdapter imgLoaderAdapter = getInstance().getImgLoaderAdapter();
if (imgLoaderAdapter != null) {
imgLoaderAdapter.setImage(rewrited.toString(), getHostView(),
getDomObject().getAttrs().getImageQuality(), imageStrategy);
}
}