0

So due to memory issue I thought about using Facebook's Fresco library.

So this is what I did,

First I added the following dependencies,

compile 'com.facebook.fresco:fresco:1.3.0'
compile 'com.facebook.fresco:animated-gif:1.3.0'

Then I initialized it in application class,

Fresco.initialize(getApplicationContext());

Then I added SimpleDraweeView to layout file,

<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/imageMessage"
    android:layout_width="180dp"
    android:layout_height="180dp"
    />

Then I added the code in my activity,

        SimpleDraweeView gif = (SimpleDraweeView) row.findViewById(R.id.imageMessage);

        ImageRequest request = ImageRequestBuilder.newBuilderWithSource (Uri.parse(url.get(position)))
                .setProgressiveRenderingEnabled (true)
                .build ();
        DraweeController controller = Fresco.newDraweeControllerBuilder ()
                .setImageRequest (request)
                .setAutoPlayAnimations (true)

                .build ();

        gif.setController (controller);

But it's not loading images, I also tried different urls but same result, So what I'm missing...

Bucky
  • 39
  • 1
  • 5

1 Answers1

0

i was facing same issue but not with gif. below is the code which load images, don't forget to initialize fresco.

       Fresco.initialize(context);

         SimpleDraweeView  iv_image = (SimpleDraweeView)itemView.findViewById(R.id.iv_image);
         iv_image.setImageURI(Uri.parse("your image url here"));

`

and here is xml

 <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/iv_image"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                fresco:actualImageScaleType="centerCrop"
                fresco:placeholderImage="@drawable/iv_car"
                fresco:viewAspectRatio="1.22"/>