Exemplo n.º 1
0
 public static void Download(string url, ImageView imageView, Resources resources, Bitmap placeholder)
 {
     if(CancelPotentialDownload(url, imageView))
     {
         var task = new DownloadImageTask(imageView);
         var drawable = new AsyncDrawable(resources, placeholder, task);
         imageView.SetImageDrawable(drawable);
         task.Execute(url);
     }
 }
Exemplo n.º 2
0
 public static void Download(string url, ImageView imageView, Resources resources, Bitmap placeholder)
 {
     if (CancelPotentialDownload(url, imageView))
     {
         var task     = new DownloadImageTask(imageView);
         var drawable = new AsyncDrawable(resources, placeholder, task);
         imageView.SetImageDrawable(drawable);
         task.Execute(url);
     }
 }
Exemplo n.º 3
0
        private static bool CancelPotentialDownload(string url, ImageView imageView)
        {
            DownloadImageTask task = GetTask(imageView);

            if (task != null)
            {
                string bitmapData = task.Url;
                if (bitmapData != url)
                {
                    task.Cancel(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
        protected override void OnPostExecute(Java.Lang.Object result)
        {
            Bitmap bitmap = result as Bitmap;

            if (IsCancelled)
            {
                bitmap = null;
            }
            if (imgRef != null && bitmap != null)
            {
                ImageView         img  = (ImageView)imgRef.Target;
                DownloadImageTask task = BitmapUtils.GetTask(img);

                if (this == task && img != null)
                {
                    img.SetImageBitmap(bitmap);
                }
            }
        }
Exemplo n.º 5
0
 public AsyncDrawable(Resources resources, Bitmap bitmap, DownloadImageTask task)
     : base(resources, bitmap)
 {
     taskRef = new WeakReference(task);
 }
 public AsyncDrawable(Resources resources, Bitmap bitmap, DownloadImageTask task)
     : base(resources, bitmap)
 {
     taskRef = new WeakReference(task);
 }