0

I have a listview with some thumbnail and I have followed this tutorial to increase his performance. http://android-developers.blogspot.it/2010/07/multithreading-for-performance.html

The performance is much increased, but now I would try to make more beautiful to see In particular I would show a placeholder until the async task will have finished to download the image.

This is my current drawable :

static class DownloadedDrawable extends ColorDrawable {
    private final WeakReference<BitmapDownloaderTask> bitmapDownloaderTaskReference;

    public DownloadedDrawable(BitmapDownloaderTask bitmapDownloaderTask) {
        super(Color.BLACK);
        bitmapDownloaderTaskReference =
            new WeakReference<BitmapDownloaderTask>(bitmapDownloaderTask);
    }

    public BitmapDownloaderTask getBitmapDownloaderTask() {
        return bitmapDownloaderTaskReference.get();
    }
     }

which will result in the ImageView displaying a black background while its download is in progress.

But now instead a black image I want to show a png placeholder that I have in drawable resources. In which way I can edit my code to reach the goal ?

Thanks to all :)

aeroxr1
  • 1,014
  • 1
  • 14
  • 36
  • 1
    Do you want to write your own code? if not i recommend using Glide library which have a placeholder and many other implementations effectively. – ugur Sep 16 '16 at 20:42
  • Hi ! Thanks to the answer :) Yes before to use external library I would writing my own code because I want to do practice. However I have seen different wonderful libraries like for example picasso. What do you think of that library ? – aeroxr1 Sep 16 '16 at 20:50
  • 1
    picasso is also perfect. u can check this post to see comparisons http://stackoverflow.com/questions/29363321/picasso-v-s-imageloader-v-s-fresco-vs-glide – ugur Sep 16 '16 at 20:57
  • Thanks :) however do you have some suggestion to me to create it on my own ? – aeroxr1 Sep 16 '16 at 20:59
  • i dont think u need a DownloadedDrawable class. You can set your imageview's src before start downloading and change with downloaded when download completed. – ugur Sep 16 '16 at 21:32

0 Answers0