Home Features Docs Blog Support GitHub

Sample code to implement fetch image from gallery

(Sachin) #1

Is there any sample code that i can refer to to implement fetch image from gallery, i could not find anything on MOE samples


(Marco) #2

In my projects I use https://cocoapods.org/pods/SDWebImage
You’ll need to bind the library yourself, it’s easy, then you can follow all the example that are written for ObjectiveC or Swift.

This is what it looks like translated in java, it’s an actual example from one of my app:

UIImageView image = UIImageView.alloc().init();  //standard UIImageView that you already find in MOE
UIImageViewExt.sd_setImageWithURL(image, NSURL.URLWithString(url)); //binding of SDWebImage, the image pointed by url is loaded asynchronously and placed inside the image view

the same in ObjectiveC was something like this

[image sd_setImageWithURL:[NSURL URLWithString:url]

in Java you need to use the class UIImageViewExt instead of calling the method directly on the image view because in ObjectiveC you can extend existing classes, in java it’s not possible.

The MOE binding tools take care of this creating classes with the same name plus the Ext suffix.

Hope this help