示例#1
0
        public Task <ImageDownloadResult> DownloadAsync(NSUrl url, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, CancellationToken token = default(CancellationToken))
        {
            var tcs = new TaskCompletionSource <ImageDownloadResult> ();

            SDWebImageOperation operation = null;

            operation = Download(url, options, progress, (image, error, cacheType, finished) => {
                if (token.IsCancellationRequested)
                {
                    operation.Cancel();
                    tcs.TrySetCanceled();
                    return;
                }
                if (finished)
                {
                    if (image == null)
                    {
                        tcs.TrySetException(new NSErrorException(error));
                        return;
                    }
                    tcs.TrySetResult(new ImageDownloadResult(image, cacheType));
                }
            });

            return(tcs.Task);
        }
示例#2
0
        public Task <ImageDownloadResult> DownloadAsync(string url, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, CancellationToken token = default(CancellationToken))
        {
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new Exception(String.Format("Malformed url: {0}", url));
            }

            return(DownloadAsync(NSUrl.FromString(url), options, progress, token));
        }
示例#3
0
        public SDWebImageOperation Download(string url, SDWebImageOptions options, SDWebImageDownloaderProgressBlock progress, SDWebImageCompletedWithFinishedBlock completed)
        {
            // TEMP - remove after Xamarin.iOS update (7.0.2 or whatever)
#if DEBUG
            completed(new UIImage(), null, 0, true);
            return(null);
#endif
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new Exception(String.Format("Malformed url: {0}", url));
            }
            return(Download(NSUrl.FromString(url), options, progress, completed));
        }
示例#4
0
        public static Task<ImageDownloadResult> SetBackgroundImageAsync(this UIButton button, NSUrl url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None)
        {
            var tcs = new TaskCompletionSource<ImageDownloadResult> ();

            SDWebImageManager.SharedManager.SetBackgroundImage (button, url, state, placeholder, options, (image, error, cacheType) => {
                if (image == null) {
                    tcs.SetException (new NSErrorException (error));
                    return;
                }
                tcs.SetResult (new ImageDownloadResult (image, cacheType));
            });

            return tcs.Task;
        }
示例#5
0
 public static void SetImage(this UIButton button, NSUrl url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageCompletedBlock completed = null)
 {
     SDWebImageManager.SharedManager.SetImage (button, url, state, placeholder, options, completed);
 }
示例#6
0
        public static Task <ImageDownloadResult> SetImageAsync(this UIImageView view, string url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null)
        {
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new Exception(String.Format("Malformed url: {0}", url));
            }

            return(SetImageAsync(view, NSUrl.FromString(url), placeholder, options, progress));
        }
示例#7
0
        public static Task <ImageDownloadResult> SetImageAsync(this UIImageView view, NSUrl url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null)
        {
            var tcs = new TaskCompletionSource <ImageDownloadResult> ();

            SDWebImageManager.SharedManager.SetImage(view, url, placeholder, options, progress, (image, error, cacheType) => {
                if (image == null)
                {
                    tcs.SetException(new NSErrorException(error));
                    return;
                }
                tcs.SetResult(new ImageDownloadResult(image, cacheType));
            });

            return(tcs.Task);
        }
示例#8
0
 public void Download(string url, NSObject del, SDWebImageOptions options, SDWebImageSuccessBlock success, SDWebImageFailureBlock failure)
 {
     if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) return;
     Download (NSUrl.FromString (url), del, options, success, failure);
 }
示例#9
0
        public static Task<ImageDownloadResult> SetImageAsync(this UIImageView view, string url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null)
        {
            if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) throw new Exception (String.Format ("Malformed url: {0}", url));

            return SetImageAsync (view, NSUrl.FromString (url), placeholder, options, progress);
        }
示例#10
0
 public static void SetImage(this UIImageView view, NSUrl url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, SDWebImageCompletedBlock completed = null)
 {
     SDWebImageManager.SharedManager.SetImage(view, url, placeholder, options, progress, completed);
 }
示例#11
0
 public SDWebImageOperation Download(string url, SDWebImageOptions options, SDWebImageDownloaderProgressBlock progress, SDWebImageCompletedWithFinishedBlock completed)
 {
     // TEMP - remove after Xamarin.iOS update (7.0.2 or whatever)
     #if DEBUG
     completed (new UIImage(), null, 0, true);
     return null;
     #endif
     if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) throw new Exception (String.Format ("Malformed url: {0}", url));
     return Download (NSUrl.FromString (url), options, progress, completed);
 }
示例#12
0
        public static Task <ImageDownloadResult> SetBackgroundImageAsync(this UIButton button, NSUrl url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None)
        {
            var tcs = new TaskCompletionSource <ImageDownloadResult> ();

            SDWebImageManager.SharedManager.SetBackgroundImage(button, url, state, placeholder, options, (image, error, cacheType) => {
                if (image == null)
                {
                    tcs.SetException(new NSErrorException(error));
                    return;
                }
                tcs.SetResult(new ImageDownloadResult(image, cacheType));
            });

            return(tcs.Task);
        }
示例#13
0
 public static void SetBackgroundImage(this UIButton button, NSUrl url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageCompletedBlock completed = null)
 {
     SDWebImageManager.SharedManager.SetBackgroundImage(button, url, state, placeholder, options, completed);
 }
示例#14
0
 public static void SetImage(this UIImageView view, string url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, SDWebImageCompletedBlock completed = null)
 {
     if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) return;
     SDWebImageManager.SharedManager.SetImage (view, NSUrl.FromString (url), placeholder, options, progress, completed);
 }
示例#15
0
 public static void SetImage(this UIImageView view, NSUrl url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, SDWebImageCompletedBlock completed = null)
 {
     SDWebImageManager.SharedManager.SetImage (view, url, placeholder, options, progress, completed);
 }
示例#16
0
        public static Task<ImageDownloadResult> SetBackgroundImageAsync(this UIButton button, string url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None)
        {
            if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) throw new Exception (String.Format ("Malformed url: {0}", url));

            return SetImageAsync (button, NSUrl.FromString (url), state, placeholder, options);
        }
示例#17
0
        public Task<ImageDownloadResult> DownloadAsync(string url, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, CancellationToken token = default(CancellationToken))
        {
            if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) throw new Exception (String.Format ("Malformed url: {0}", url));

            return DownloadAsync (NSUrl.FromString (url), options, progress, token);
        }
示例#18
0
        public Task<ImageDownloadResult> DownloadAsync(NSUrl url, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, CancellationToken token = default(CancellationToken))
        {
            var tcs = new TaskCompletionSource<ImageDownloadResult> ();

            SDWebImageOperation operation = null;

            operation = Download (url, options, progress, (image, error, cacheType, finished) => {
                if (token.IsCancellationRequested) {
                    operation.Cancel ();
                    tcs.TrySetCanceled ();
                    return;
                }
                if (finished) {
                    if (image == null) {
                        tcs.TrySetException (new NSErrorException (error));
                        return;
                    }
                    tcs.TrySetResult (new ImageDownloadResult (image, cacheType));
                }
            });

            return tcs.Task;
        }
示例#19
0
 public static void SetBackgroundImage(this UIButton button, string url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageCompletedBlock completed = null)
 {
     if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
     {
         return;
     }
     SDWebImageManager.SharedManager.SetBackgroundImage(button, NSUrl.FromString(url), state, placeholder, options, completed);
 }
示例#20
0
 public static void SetImage(this UIButton button, string url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageCompletedBlock completed = null)
 {
     if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) return;
     SDWebImageManager.SharedManager.SetImage (button, NSUrl.FromString (url), state, placeholder, options, completed);
 }
示例#21
0
        public static Task <ImageDownloadResult> SetBackgroundImageAsync(this UIButton button, string url, UIControlState state, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None)
        {
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new Exception(String.Format("Malformed url: {0}", url));
            }

            return(SetImageAsync(button, NSUrl.FromString(url), state, placeholder, options));
        }
示例#22
0
        public static Task<ImageDownloadResult> SetImageAsync(this UIImageView view, NSUrl url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null)
        {
            var tcs = new TaskCompletionSource<ImageDownloadResult> ();

            SDWebImageManager.SharedManager.SetImage (view, url, placeholder, options, progress, (image, error, cacheType) => {
                if (image == null) {
                    tcs.SetException (new NSErrorException (error));
                    return;
                }
                tcs.SetResult (new ImageDownloadResult (image, cacheType));
            });

            return tcs.Task;
        }
示例#23
0
 public SDWebImageOperation DownloadWithURL(NSUrl url, SDWebImageOptions options, SDWebImageDownloaderProgressHandler progressHandler, SDWebImageCompletedWithFinishedHandler completedHandler)
 {
     return new SDWebImageOperation (DownloadWithURL_ (url, options, progressHandler, completedHandler));
 }
示例#24
0
 public void Download(string url, NSObject del, SDWebImageOptions options)
 {
     if (!Uri.IsWellFormedUriString (url, UriKind.Absolute)) return;
     Download (NSUrl.FromString (url), del, options);
 }
示例#25
0
 public static void SetImage(this UIImageView view, string url, UIImage placeholder = null, SDWebImageOptions options = SDWebImageOptions.None, SDWebImageDownloaderProgressBlock progress = null, SDWebImageCompletedBlock completed = null)
 {
     if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
     {
         return;
     }
     SDWebImageManager.SharedManager.SetImage(view, NSUrl.FromString(url), placeholder, options, progress, completed);
 }
示例#26
0
 public SDWebImageOperation DownloadWithURL(NSUrl url, SDWebImageOptions options, SDWebImageDownloaderProgressHandler progressHandler, SDWebImageCompletedWithFinishedHandler completedHandler)
 {
     return(new SDWebImageOperation(DownloadWithURL_(url, options, progressHandler, completedHandler)));
 }