You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/04/17 03:56:29 UTC

[GitHub] [incubator-weex] BatterMan-Li opened a new issue #2328: The default implementation of the load command callback for WXImage has compatibility issues

BatterMan-Li opened a new issue #2328: The default implementation of the load command callback for WXImage has compatibility issues
URL: https://github.com/apache/incubator-weex/issues/2328
 
 
   First, I load the image scheme into Glide in the ImageAdapter.
   Then, in the default implementation of the WXImage processing load command:
   
   
   imageStrategy.setImageListener(new ImageListener() {
               public void onImageFinish(String url, ImageView imageView, boolean result, Map extra) {
                   if(WXImage.this.getDomObject() != null && WXImage.this.getDomObject().getEvents().contains("load")) {
                       HashMap params = new HashMap();
                       HashMap size = new HashMap(2);
                       if(imageView != null && imageView.getDrawable() != null && imageView.getDrawable() instanceof ImageDrawable) {
                           size.put("naturalWidth", Integer.valueOf(((ImageDrawable)imageView.getDrawable()).getBitmapWidth()));
                           size.put("naturalHeight", Integer.valueOf(((ImageDrawable)imageView.getDrawable()).getBitmapHeight()));
                       } else {
                           size.put("naturalWidth", Integer.valueOf(0));
                           size.put("naturalHeight", Integer.valueOf(0));
                       }
   
                       if(WXImage.this.getDomObject() != null && WXImage.this.containsEvent("load")) {
                           params.put("success", Boolean.valueOf(result));
                           params.put("size", size);
                           WXImage.this.fireEvent("load", params);
                       }
                   }
   
               }
           });
   
   As you can see, imageview.getdrawable () determines that if it's not ImageDrawable, the width is 0,0. However, the Drawable returned by Glide is of type GlideBitmapDrawable, resulting in incorrect values returned by width and height.
   
   Personally think that should not be forced to judge Drawable must be ImageDrawable here, other types can be, as long as it is Drawable, wide high with Drawable. GetIntrinsicWidth and getIntrinsicHeight access. This is compatible with more image loading libraries.
   
   When the picture is dynamically set to width and height, the default width and height is 0,0, and the returned naturalWidth obtained by load is -1 and -1, so that the dynamically set pictures are displayed as wrong images
   
   How do I use glide to get the load back to normal naturalWidth, naturalHeight?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services