Example #1
0
        public BitmapWorkerTask GetBitmapWorkerTask()
        {
            BitmapWorkerTask task = null;

            bitmapWorkerTaskReference.TryGetTarget(out task);
            return(task);
        }
Example #2
0
 public static void StartNew(ImageView imageView, string url, Resources resources)
 {
     if (CancelPotentialWork(url, imageView))
     {
         BitmapWorkerTask task          = new BitmapWorkerTask(imageView, resources);
         AsyncDrawable    asyncDrawable =
             new AsyncDrawable(resources, null, task);
         imageView.SetImageDrawable(asyncDrawable);
         task.Execute(url);
     }
 }
Example #3
0
        static bool CancelPotentialWork(string url, ImageView imageView)
        {
            BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

            if (bitmapWorkerTask != null)
            {
                string bitmapUrl = bitmapWorkerTask.url;
                if (bitmapUrl == "" || bitmapUrl != url)
                {
                    bitmapWorkerTask.Cancel(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Example #4
0
        protected override void OnPostExecute(Bitmap bitmap)
        {
            if (IsCancelled)
            {
                bitmap = null;
            }

            if (imageViewReference != null && bitmap != null)
            {
                ImageView imageView = null;
                imageViewReference.TryGetTarget(out imageView);
                BitmapWorkerTask bitmapWorkerTask =
                    getBitmapWorkerTask(imageView);
                if (this == bitmapWorkerTask && imageView != null)
                {
                    imageView.SetImageDrawable(new BitmapDrawable(bitmap));
                }
            }
        }
Example #5
0
 public AsyncDrawable(Resources res, Bitmap bitmap, BitmapWorkerTask bitmapWorkerTask) : base(res, bitmap)
 {
     bitmapWorkerTaskReference =
         new WeakReference <BitmapWorkerTask>(bitmapWorkerTask);
 }