コード例 #1
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));
        }
コード例 #2
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);
 }
コード例 #3
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);
 }
コード例 #4
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));
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
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));
        }
コード例 #8
0
ファイル: Extra.cs プロジェクト: stampsy/sdwebimage-monotouch
 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);
 }
コード例 #9
0
ファイル: Extra.cs プロジェクト: stampsy/sdwebimage-monotouch
        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;
        }
コード例 #10
0
ファイル: Extra.cs プロジェクト: stampsy/sdwebimage-monotouch
 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
ファイル: Extra.cs プロジェクト: stampsy/sdwebimage-monotouch
        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);
        }
コード例 #12
0
ファイル: Extra.cs プロジェクト: stampsy/sdwebimage-monotouch
        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;
        }
コード例 #13
0
ファイル: Extra.cs プロジェクト: stampsy/sdwebimage-monotouch
 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);
 }
コード例 #14
0
ファイル: Extra.cs プロジェクト: stampsy/sdwebimage-monotouch
        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);
        }