Universal Image Loader Java Binding - Syntax Question RRS feed

  • Question

  • User53176 posted

    Hi All,

    I'm using the Universal Image Loader Java Binding Project from here (https://github.com/LukeForder/Xamarin-Bindings-Android-Universal-Image-Loader).

    I'm trying to download an image without placing it into an imageview. The Java syntax looks like this.

    // Load image, decode it to Bitmap and return Bitmap to callback imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { // Do whatever you want with Bitmap } });

    I can't work out how to perform the same function with Xamarin. Has anyone got a working example of this?

    Thanks in advance, Brad

    Saturday, April 25, 2015 12:43 PM

All replies

  • User51468 posted

    Hey did you find out the syntax? I am also stuck at the same point in my project.

    Friday, May 8, 2015 9:29 PM
  • User209 posted

    C# does not allow for anonymous classes like Java does, so you need to create your own class which inherits from SimpleImageLoadingListener like so:

    public class MySimpleImageLoadingListener : SimpleImageLoadingListener
        // implement here

    Note that SimpleImageLoadingListener might be an Interface in C# and could potentially be called ISimpleImageLoadingListener instead, but that does not change anything.

    Saturday, May 9, 2015 9:49 AM
  • User53176 posted

    Thanks for the reply. I'm still struggling in how to get this working.

    The OnLoadingComplete method accepts the imageuri, an imageview and the bitmap. The imageuri is already provided to the LoadImage method but the bitmap would be output from the LoadImage function. So it appears I still need to pass the imageview but I can't seem to get it working. Any assistance would be appreciated.

    ImageLoader.Instance.LoadImage (dataItem.image, MySimpleImageLoadingListener ());
    public class MySimpleImageLoadingListener : SimpleImageLoadingListener
        private View _imageview;
        public MySimpleImageLoadingListener(View imageview)
            _imageview = imageview;
        public override void OnLoadingComplete(string imageUri, View imageview, Bitmap loadedimage)
            // Do whatever you want with Bitmap
    Sunday, May 24, 2015 4:26 PM