当前位置: 首页>>代码示例>>Java>>正文


Java WXImageStrategy类代码示例

本文整理汇总了Java中com.taobao.weex.common.WXImageStrategy的典型用法代码示例。如果您正苦于以下问题:Java WXImageStrategy类的具体用法?Java WXImageStrategy怎么用?Java WXImageStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WXImageStrategy类属于com.taobao.weex.common包,在下文中一共展示了WXImageStrategy类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSrc

import com.taobao.weex.common.WXImageStrategy; //导入依赖的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);
    }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:35,代码来源:WXImage.java

示例2: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
@Override
public void setImage(final String url, final ImageView view,
                     WXImageQuality quality, WXImageStrategy strategy) {

  WXSDKManager.getInstance().postOnUiThread(new Runnable() {

    @Override
    public void run() {
      if(view==null||view.getLayoutParams()==null){
        return;
      }
      if (TextUtils.isEmpty(url)) {
        view.setImageBitmap(null);
        return;
      }
      String temp = url;
      if (url.startsWith("//")) {
        temp = "http:" + url;
      }
      if (view.getLayoutParams().width <= 0 || view.getLayoutParams().height <= 0) {
        return;
      }
      Picasso.with(WXEnvironment.getApplication())
          .load(temp)
          .into(view);
    }
  },0);
}
 
开发者ID:Laisly,项目名称:weex,代码行数:29,代码来源:ImageAdapter.java

示例3: setSrc

import com.taobao.weex.common.WXImageStrategy; //导入依赖的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);
    }
}
 
开发者ID:Laisly,项目名称:weex,代码行数:16,代码来源:WXImage.java

示例4: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
@Override
public void setImage(final String url, final ImageView view, WXImageQuality quality, WXImageStrategy strategy) {
    WXSDKManager.getInstance().postOnUiThread(new Runnable() {
        @Override
        public void run() {

            if (view == null || view.getLayoutParams() == null) {
                return;
            }
            if (TextUtils.isEmpty(url)) {
                view.setImageBitmap(null);
                return;
            }
            String temp = url;
            if (url.startsWith("//")) {
                temp = "http:" + url;
            }
            if (view.getLayoutParams().width <= 0 || view.getLayoutParams().height <= 0) {
                return;
            }
            Picasso.with(WXEnvironment.getApplication())
                    .load(temp)
                    .into(view);

        }
    }, 0);
}
 
开发者ID:o2team,项目名称:weex-demo,代码行数:28,代码来源:ImageAdaptor.java

示例5: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
@Override
public void setImage(final String url, final ImageView view, WXImageQuality quality, WXImageStrategy strategy) {

  WXSDKManager.getInstance().postOnUiThread(new Runnable() {

    @Override
    public void run() {
      if(view==null||view.getLayoutParams()==null){
        return;
      }
      if (TextUtils.isEmpty(url)) {
        view.setImageBitmap(null);
        return;
      }
      String temp = url;
      if (url.startsWith("//")) {
        temp = "http:" + url;
      }
      if (view.getLayoutParams().width <= 0 || view.getLayoutParams().height <= 0) {
        return;
      }
      Picasso.with(WXEnvironment.getApplication())
          .load(temp)
          .into(view);
    }
  },0);
}
 
开发者ID:wingjay,项目名称:jayAndroid,代码行数:28,代码来源:WeexImageAdapter.java

示例6: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
@Override
public void setImage(final String url, final ImageView view,
                     WXImageQuality quality, final WXImageStrategy strategy) {

  WXSDKManager.getInstance().postOnUiThread(new Runnable() {

    @Override
    public void run() {
      if(view==null||view.getLayoutParams()==null){
        return;
      }
      if (TextUtils.isEmpty(url)) {
        view.setImageBitmap(null);
        return;
      }
      String temp = url;
      if (url.startsWith("//")) {
        temp = "http:" + url;
      }
      if (view.getLayoutParams().width <= 0 || view.getLayoutParams().height <= 0) {
        return;
      }


      if(!TextUtils.isEmpty(strategy.placeHolder)){
        Picasso.Builder builder=new Picasso.Builder(WXEnvironment.getApplication());
        Picasso picasso=builder.build();
        picasso.load(Uri.parse(strategy.placeHolder)).into(view);

        view.setTag(strategy.placeHolder.hashCode(),picasso);
      }


      Picasso.with(WXEnvironment.getApplication())
          .load(temp)
          .into(view, new Callback() {
            @Override
            public void onSuccess() {
              if(strategy.getImageListener()!=null){
                strategy.getImageListener().onImageFinish(url,view,true,null);
              }

              if(!TextUtils.isEmpty(strategy.placeHolder)){
                ((Picasso) view.getTag(strategy.placeHolder.hashCode())).cancelRequest(view);
              }
            }

            @Override
            public void onError() {
              if(strategy.getImageListener()!=null){
                strategy.getImageListener().onImageFinish(url,view,false,null);
              }
            }
          });
    }
  },0);
}
 
开发者ID:wangwei123,项目名称:my-weex,代码行数:58,代码来源:ImageAdapter.java

示例7: setRemoteSrc

import com.taobao.weex.common.WXImageStrategy; //导入依赖的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);
      }
  }
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:51,代码来源:WXImage.java

示例8: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
@Override
public void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy) {
  //实现你自己的图片下载,否则图片无法显示。
}
 
开发者ID:Aarthas,项目名称:android_Json2view,代码行数:5,代码来源:ImageAdapter.java

示例9: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
@Override
public void setImage(final String url, final ImageView view, WXImageQuality quality, final WXImageStrategy strategy) {
    WXSDKManager.getInstance().postOnUiThread(new Runnable() {
        @Override
        public void run() {
            if(view==null||view.getLayoutParams()==null){
                return;
            }
            if (TextUtils.isEmpty(url)) {
                view.setImageBitmap(null);
                return;
            }
            String temp = url;
            if (url.startsWith("//")) {
                temp = "https:" + url;
            }
            if (view.getLayoutParams().width <= 0 || view.getLayoutParams().height <= 0) {
                return;
            }
            if(!TextUtils.isEmpty(strategy.placeHolder)){
                Picasso.Builder builder=new Picasso.Builder(WXEnvironment.getApplication());
                Picasso picasso=builder.build();
                picasso.load(Uri.parse(strategy.placeHolder)).into(view);

                view.setTag(strategy.placeHolder.hashCode(),picasso);
            }
            Picasso.with(WXEnvironment.getApplication())
                    .load(temp)
                    .into(view, new Callback() {
                        @Override
                        public void onSuccess() {
                            if(strategy.getImageListener()!=null){
                                strategy.getImageListener().onImageFinish(url,view,true,null);
                            }

                            if(!TextUtils.isEmpty(strategy.placeHolder)){
                                ((Picasso) view.getTag(strategy.placeHolder.hashCode())).cancelRequest(view);
                            }
                        }
                        @Override
                        public void onError() {
                            if(strategy.getImageListener()!=null){
                                strategy.getImageListener().onImageFinish(url,view,false,null);
                            }
                        }
                    });
        }
    });
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:50,代码来源:ImageAdapter.java

示例10: setRemoteSrc

import com.taobao.weex.common.WXImageStrategy; //导入依赖的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);
      }
  }
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:50,代码来源:WXImage.java

示例11: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
@Override
public void setImage(final String url, final ImageView view,
                     WXImageQuality quality, final WXImageStrategy strategy) {

  WXSDKManager.getInstance().postOnUiThread(new Runnable() {

    @Override
    public void run() {
      if(view==null||view.getLayoutParams()==null){
        return;
      }
      if (TextUtils.isEmpty(url)) {
        view.setImageBitmap(null);
        return;
      }
      String temp = url;
      if (url.startsWith("//")) {
        temp = "http:" + url;
      }
      if (view.getLayoutParams().width <= 0 || view.getLayoutParams().height <= 0) {
        return;
      }


      if(!TextUtils.isEmpty(strategy.placeHolder)){
        Picasso.Builder builder=new Picasso.Builder(WXEnvironment.getApplication());
        Picasso picasso=builder.build();
        picasso.load(Uri.parse(strategy.placeHolder)).into(view);

        view.setTag(strategy.placeHolder.hashCode(),picasso);
      }

      Picasso.with(WXEnvironment.getApplication())
          .load(temp)
          .transform(new BlurTransformation(strategy.blurRadius))
          .into(view, new Callback() {
            @Override
            public void onSuccess() {
              if(strategy.getImageListener()!=null){
                strategy.getImageListener().onImageFinish(url,view,true,null);
              }

              if(!TextUtils.isEmpty(strategy.placeHolder)){
                ((Picasso) view.getTag(strategy.placeHolder.hashCode())).cancelRequest(view);
              }
            }

            @Override
            public void onError() {
              if(strategy.getImageListener()!=null){
                strategy.getImageListener().onImageFinish(url,view,false,null);
              }
            }
          });
    }
  },0);
}
 
开发者ID:weexteam,项目名称:weexpack-android,代码行数:58,代码来源:ImageAdapter.java

示例12: setImage

import com.taobao.weex.common.WXImageStrategy; //导入依赖的package包/类
void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy); 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:2,代码来源:IWXImgLoaderAdapter.java


注:本文中的com.taobao.weex.common.WXImageStrategy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。