/* * public void UpdateImage(UIImage photo) * { * photoImg.Image = photo; * //Asset = asset; * }*/ public void UpdateCell(Post post) { _currentPost = post; var thumbnail = post.Media[0].Thumbnails?[256]; ImageUrl = string.IsNullOrEmpty(thumbnail) ? post.Media[0].Url : thumbnail; _bodyImage?.RemoveFromSuperview(); _bodyImage = new UIImageView(); _bodyImage.ClipsToBounds = true; _bodyImage.UserInteractionEnabled = true; _bodyImage.ContentMode = UIViewContentMode.ScaleAspectFill; _bodyImage.Frame = new CGRect(new CGPoint(0, 0), Constants.CellSize); _bodyImage.BackgroundColor = UIColor.FromRGB(244, 244, 246); ContentView.AddSubview(_bodyImage); _scheduledWork?.Cancel(); _scheduledWork = ImageService.Instance.LoadUrl(ImageUrl) .Retry(2) .FadeAnimation(false) .WithCache(FFImageLoading.Cache.CacheType.All) .WithPriority(LoadingPriority.Highest) .DownSample(300) /* .DownloadProgress((f)=> * { * })*/ .Into(_bodyImage); }
public void UpdateCell(Post post) { _currentPost = post; _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .FadeAnimation(false, false, 0) .DownSample(200) .Into(avatar); } else { avatar.Image = UIImage.FromBundle("ic_noavatar"); } commentText.Text = _currentPost.Body; loginLabel.Text = _currentPost.Author; likeLabel.Text = _currentPost.NetVotes.ToString(); costLabel.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); //costLabel.Hidden = true; //!BasePresenter.User.IsNeedRewards; likeButton.Selected = _currentPost.Vote; likeButton.Enabled = true; timestamp.Text = _currentPost.Created.ToPostTime(); likeLabel.Text = $"{_currentPost.NetLikes} {(_currentPost.NetLikes == 1 ? Localization.Messages.Like : Localization.Messages.Likes)}"; LayoutIfNeeded(); }
public void UpdateIconImage(CipherViewCell cipherCell) { if (_currentTask != null && !_currentTask.IsCancelled && !_currentTask.IsCompleted) { _currentTask.Cancel(); } var cipher = cipherCell.Cipher; var iconImage = cipherCell.GetIconImage(cipher); if (iconImage.Item2 != null) { IconImage.SetImageResource(Resource.Drawable.login); IconImage.Visibility = ViewStates.Visible; Icon.Visibility = ViewStates.Gone; _currentTask = ImageService.Instance.LoadUrl(iconImage.Item2).DownSample(64).Into(IconImage); IconImage.Key = iconImage.Item2; } else { IconImage.Visibility = ViewStates.Gone; Icon.Visibility = ViewStates.Visible; Icon.Text = iconImage.Item1; } }
public void UpdateCell(Post post) { _currentPost = post; ImageUrl = post.Media[0].Thumbnails.Micro; _bodyImage?.RemoveFromSuperview(); CreateImageView(); _scheduledWork?.Cancel(); _scheduledWork = ImageService.Instance.LoadUrl(ImageUrl) .Retry(2) .FadeAnimation(false) .WithCache(FFImageLoading.Cache.CacheType.All) .WithPriority(LoadingPriority.Highest) .DownSample(250) /* .DownloadProgress((f)=> * { * })*/ .Into(_bodyImage); if (post.Media.Length > 1) { ContentView.BringSubviewToFront(_galleryImage); } }
public override void UpdateCell(Post post) { if (!isInitialized) { widthConstraint.Constant = heightConstraint.Constant = Constants.CellSideSize; isInitialized = true; } var thumbnail = post.Media[0].Thumbnails?[256]; ImageUrl = string.IsNullOrEmpty(thumbnail) ? post.Media[0].Url : thumbnail; photoImg.Image = null; _scheduledWork?.Cancel(); if (ImageUrl != null) { _scheduledWork = ImageService.Instance.LoadUrl(ImageUrl, Constants.ImageCacheDuration) .Retry(5) .WithPriority(LoadingPriority.High) /* .DownloadProgress((DownloadProgress obj) => * { * Debug.WriteLine(obj.Current + " of " + obj.Total); * })*/ .FadeAnimation(false) .DownSample(width: _downSampleWidth) .Into(photoImg); } }
public static IScheduledWork SetSettings(this TaskParameter task, ImageViewAsync imageview, int placeholder, int?downsampleSize = null, ITransformation transformation = null) { if (downsampleSize != null) { task = task.DownSampleInDip(downsampleSize ?? 0); } if (transformation != null) { task = task.Transform(transformation); } IScheduledWork work = null; task.Success((size, loadingResult) => { System.Diagnostics.Debug.WriteLine(loadingResult); }); work = task.Retry(5, 300) .ErrorPlaceholder(placeholder.ToString(), ImageSource.CompiledResource) .LoadingPlaceholder(placeholder.ToString(), ImageSource.CompiledResource) .Error(exception => { System.Diagnostics.Debug.WriteLine("------------------------------------------------------------------------------------------------------"); System.Diagnostics.Debug.WriteLine($"Error: {exception.ToString()}"); System.Diagnostics.Debug.WriteLine("------------------------------------------------------------------------------------------------------"); }).Into(imageview); return(work); }
async void UpdateImage(Image imageView, CachedImage image, CachedImage previousImage) { CancelIfNeeded(); if (image == null || imageView == null) { return; } var ffSource = await ImageSourceBinding.GetImageSourceBinding(image.Source, image).ConfigureAwait(false); if (ffSource == null) { if (_lastImageSource == null) { return; } _lastImageSource = null; imageView.Source = null; return; } if (previousImage != null && !ffSource.Equals(_lastImageSource)) { _lastImageSource = null; imageView.Source = null; } image.SetIsLoading(true); var placeholderSource = await ImageSourceBinding.GetImageSourceBinding(image.LoadingPlaceholder, image).ConfigureAwait(false); var errorPlaceholderSource = await ImageSourceBinding.GetImageSourceBinding(image.ErrorPlaceholder, image).ConfigureAwait(false); image.SetupOnBeforeImageLoading(out TaskParameter imageLoader, ffSource, placeholderSource, errorPlaceholderSource); if (imageLoader != null) { var finishAction = imageLoader.OnFinish; var sucessAction = imageLoader.OnSuccess; imageLoader.Finish((work) => { finishAction?.Invoke(work); ImageLoadingSizeChanged(image, false); }); imageLoader.Success((imageInformation, loadingResult) => { sucessAction?.Invoke(imageInformation, loadingResult); _lastImageSource = ffSource; }); imageLoader.LoadingPlaceholderSet(() => ImageLoadingSizeChanged(image, true)); _currentTask = imageLoader.Into(imageView); } }
void UpdateBitmap(CachedImageView imageView, CachedImage image, CachedImage previousImage) { CancelIfNeeded(); if (image == null || imageView == null || imageView.Handle == IntPtr.Zero || _isDisposed) { return; } var ffSource = ImageSourceBinding.GetImageSourceBinding(image.Source, image); if (ffSource == null) { if (_lastImageSource == null) { return; } _lastImageSource = null; imageView.SetImageResource(global::Android.Resource.Color.Transparent); return; } if (previousImage != null && !ffSource.Equals(_lastImageSource)) { _lastImageSource = null; imageView.SkipInvalidate(); Control.SetImageResource(global::Android.Resource.Color.Transparent); } image.SetIsLoading(true); var placeholderSource = ImageSourceBinding.GetImageSourceBinding(image.LoadingPlaceholder, image); var errorPlaceholderSource = ImageSourceBinding.GetImageSourceBinding(image.ErrorPlaceholder, image); TaskParameter imageLoader; image.SetupOnBeforeImageLoading(out imageLoader, ffSource, placeholderSource, errorPlaceholderSource); if (imageLoader != null) { var finishAction = imageLoader.OnFinish; var sucessAction = imageLoader.OnSuccess; imageLoader.Finish((work) => { finishAction?.Invoke(work); ImageLoadingFinished(image); }); imageLoader.Success((imageInformation, loadingResult) => { sucessAction?.Invoke(imageInformation, loadingResult); _lastImageSource = ffSource; }); _currentTask = imageLoader.Into(imageView); } }
private async void UpdateImage(Image imageView, CachedImage image, CachedImage previousImage) { CancelIfNeeded(); if (image == null || imageView == null || _isDisposed) { return; } ImageSourceBinding ffSource = await ImageSourceBinding.GetImageSourceBinding(image.Source, image) .ConfigureAwait(continueOnCapturedContext: false); if (ffSource == null) { if (_lastImageSource != null) { _lastImageSource = null; imageView.Source = null; } return; } if (previousImage != null && !ffSource.Equals(_lastImageSource)) { _lastImageSource = null; imageView.Source = null; } image.SetIsLoading(isLoading: true); ImageSourceBinding placeholderSource = await ImageSourceBinding.GetImageSourceBinding(image.LoadingPlaceholder, image).ConfigureAwait(continueOnCapturedContext: false); ImageSourceBinding errorPlaceholderSource = await ImageSourceBinding.GetImageSourceBinding(image.ErrorPlaceholder, image).ConfigureAwait(continueOnCapturedContext: false); image.SetupOnBeforeImageLoading(out var imageLoader, ffSource, placeholderSource, errorPlaceholderSource); if (imageLoader != null) { Action <IScheduledWork> finishAction = imageLoader.OnFinish; Action <ImageInformation, LoadingResult> sucessAction = imageLoader.OnSuccess; imageLoader.Finish(delegate(IScheduledWork work) { finishAction?.Invoke(work); ImageLoadingSizeChanged(image, isLoading: false); }); imageLoader.Success(delegate(ImageInformation imageInformation, LoadingResult loadingResult) { sucessAction?.Invoke(imageInformation, loadingResult); _lastImageSource = ffSource; }); imageLoader.LoadingPlaceholderSet(delegate { ImageLoadingSizeChanged(image, isLoading: true); }); if (!_isDisposed) { _currentTask = imageLoader.Into(imageView); } } }
void CancelIfNeeded() { try { var taskToCancel = _currentTask; if (taskToCancel != null && !taskToCancel.IsCancelled) { taskToCancel.Cancel(); } _currentTask = null; } catch (Exception) { } }
public void Cancel() { try { IScheduledWork scheduledWork = _scheduledWork; if (scheduledWork != null && !scheduledWork.IsCancelled) { scheduledWork.Cancel(); } } catch (Exception) { } }
public void UpdateCell(Post post) { _currentPost = post; _bodyImage?.RemoveFromSuperview(); CreateImageView(); _scheduledWork?.Cancel(); _scheduledWork = ImageLoader.Load(_currentPost.Media[0].Url, _bodyImage, 2, LoadingPriority.Highest, microUrl: _currentPost.Media[0].Thumbnails.Micro); if (post.Media.Length > 1) { ContentView.BringSubviewToFront(_galleryImage); } }
void UpdateImage() { if (IsDisposed) { return; } CancelIfNeeded(); var ffSource = ImageSourceBinding.GetImageSourceBinding(Element.Source, Element); if (ffSource == null) { Control.Source = null; return; } Element.SetIsLoading(true); Control.Source = null; var placeholderSource = ImageSourceBinding.GetImageSourceBinding(Element.LoadingPlaceholder, Element); var errorPlaceholderSource = ImageSourceBinding.GetImageSourceBinding(Element.ErrorPlaceholder, Element); TaskParameter imageLoader; Element.SetupOnBeforeImageLoading(out imageLoader, ffSource, placeholderSource, errorPlaceholderSource); if (imageLoader != null) { var finishAction = imageLoader.OnFinish; var sucessAction = imageLoader.OnSuccess; imageLoader.Success((imageInformation, loadingResult) => { sucessAction?.Invoke(imageInformation, loadingResult); }); imageLoader.Finish((work) => { finishAction?.Invoke(work); OnLoadFinished(); }); _currentTask = imageLoader.Into(Control); } }
public void UpdateCell(UserFriend user) { _currentUser = user; _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentUser.Avatar)) { _scheduledWorkAvatar = ImageLoader.Load(_currentUser.Avatar, avatar, placeHolder: "ic_noavatar.png"); } else { avatar.Image = UIImage.FromBundle("ic_noavatar"); } userName.Text = _currentUser.Author; name.Text = _currentUser.Name; progressBar.StopAnimating(); }
public override void UpdateCell(Post post) { if (!isInitialized) { widthConstraint.Constant = heightConstraint.Constant = Constants.CellSideSize; isInitialized = true; } ImageUrl = post.Media[0].Url; photoImg.Image = null; _scheduledWork?.Cancel(); if (ImageUrl != null) { _scheduledWork = ImageService.Instance.LoadUrl(ImageUrl, Constants.ImageCacheDuration) .Retry(5) .FadeAnimation(false) .DownSample(width: _downSampleWidth) .Into(photoImg); } }
public void UpdateCell(UserFriend user) { _current = user; avatar.Image = UIImage.FromFile("ic_user_placeholder.png"); _scheduledWorkAvatar?.Cancel(); _scheduledWorkAvatar = ImageLoader.Load(_current.Avatar, avatar, placeHolder: "ic_noavatar.png"); if (!string.IsNullOrEmpty(_current.Name)) { username.Text = _current.Name; usernameHeight.Constant = 18; } else { usernameHeight.Constant = 0; } powerLabel.Text = $"{_current.Reputation}%"; login.Text = _current.Author; }
public void UpdateCell(UserFriend user) { _currentUser = user; _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentUser.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentUser.Avatar, TimeSpan.FromDays(30)) .FadeAnimation(false, false, 0) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .DownSample(200) .Into(avatar); } else { avatar.Image = UIImage.FromBundle("ic_noavatar"); } userName.Text = _currentUser.Author; name.Text = _currentUser.Name; progressBar.StopAnimating(); }
public void UpdateCell(UserFriend user) { _current = user; avatar.Image = UIImage.FromFile("ic_user_placeholder.png"); _scheduledWorkAvatar?.Cancel(); _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_current.Avatar, TimeSpan.FromDays(30)) .Retry(2, 200) .FadeAnimation(false, false, 0) .DownSample(width: (int)avatar.Frame.Width) .Into(avatar); if (!string.IsNullOrEmpty(_current.Name)) { username.Text = _current.Name; usernameHeight.Constant = 18; } else { usernameHeight.Constant = 0; } powerLabel.Text = $"{_current.Reputation}%"; login.Text = _current.Author; }
private async void UpdateSource() { ((Xamarin.Forms.IElementController)Element).SetValueFromRenderer(CachedImage.IsLoadingPropertyKey, true); Xamarin.Forms.ImageSource source = Element.Source; Cancel(); TaskParameter imageLoader = null; var ffSource = await ImageSourceBinding.GetImageSourceBinding(source).ConfigureAwait(false); if (ffSource == null) { if (Control != null) { Control.Source = null; } ImageLoadingFinished(Element); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.Instance.LoadUrl(ffSource.Path, Element.CacheDuration); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.Instance.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.Instance.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.Instance.LoadFile(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Stream) { imageLoader = ImageService.Instance.LoadStream(ffSource.Stream); } if (imageLoader != null) { // CustomKeyFactory if (Element.CacheKeyFactory != null) { var bindingContext = Element.BindingContext; imageLoader.CacheKey(Element.CacheKeyFactory.GetKey(source, bindingContext)); } // LoadingPlaceholder if (Element.LoadingPlaceholder != null) { var placeholderSource = await ImageSourceBinding.GetImageSourceBinding(Element.LoadingPlaceholder).ConfigureAwait(false); if (placeholderSource != null) { imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // ErrorPlaceholder if (Element.ErrorPlaceholder != null) { var placeholderSource = await ImageSourceBinding.GetImageSourceBinding(Element.ErrorPlaceholder).ConfigureAwait(false); if (placeholderSource != null) { imageLoader.ErrorPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // Downsample if (Element.DownsampleToViewSize && (Element.Width > 0 || Element.Height > 0)) { if (Element.Height > Element.Width) { imageLoader.DownSample(height: Element.Height.PointsToPixels()); } else { imageLoader.DownSample(width: Element.Width.PointsToPixels()); } } else if (Element.DownsampleToViewSize && (Element.WidthRequest > 0 || Element.HeightRequest > 0)) { if (Element.HeightRequest > Element.WidthRequest) { imageLoader.DownSample(height: Element.HeightRequest.PointsToPixels()); } else { imageLoader.DownSample(width: Element.WidthRequest.PointsToPixels()); } } else if ((int)Element.DownsampleHeight != 0 || (int)Element.DownsampleWidth != 0) { if (Element.DownsampleHeight > Element.DownsampleWidth) { imageLoader.DownSample(height: Element.DownsampleUseDipUnits ? Element.DownsampleHeight.PointsToPixels() : (int)Element.DownsampleHeight); } else { imageLoader.DownSample(width: Element.DownsampleUseDipUnits ? Element.DownsampleWidth.PointsToPixels() : (int)Element.DownsampleWidth); } } // RetryCount if (Element.RetryCount > 0) { imageLoader.Retry(Element.RetryCount, Element.RetryDelay); } // TransparencyChannel if (Element.TransparencyEnabled.HasValue) { imageLoader.TransparencyChannel(Element.TransparencyEnabled.Value); } // FadeAnimation if (Element.FadeAnimationEnabled.HasValue) { imageLoader.FadeAnimation(Element.FadeAnimationEnabled.Value); } // TransformPlaceholders if (Element.TransformPlaceholders.HasValue) { imageLoader.TransformPlaceholders(Element.TransformPlaceholders.Value); } // Transformations if (Element.Transformations != null && Element.Transformations.Count > 0) { imageLoader.Transform(Element.Transformations); } imageLoader.WithPriority(Element.LoadingPriority); if (Element.CacheType.HasValue) { imageLoader.WithCache(Element.CacheType.Value); } if (Element.LoadingDelay.HasValue) { imageLoader.Delay(Element.LoadingDelay.Value); } var element = Element; imageLoader.Finish((work) => { element.OnFinish(new CachedImageEvents.FinishEventArgs(work)); ImageLoadingFinished(element); }); imageLoader.Success((imageInformation, loadingResult) => element.OnSuccess(new CachedImageEvents.SuccessEventArgs(imageInformation, loadingResult))); imageLoader.Error((exception) => element.OnError(new CachedImageEvents.ErrorEventArgs(exception))); imageLoader.DownloadStarted((downloadInformation) => element.OnDownloadStarted(new CachedImageEvents.DownloadStartedEventArgs(downloadInformation))); _currentTask = imageLoader.Into(Control); } }
private void UpdateBitmap(CachedImage previous = null) { if (previous == null || !object.Equals(previous.Source, Element.Source)) { Xamarin.Forms.ImageSource source = Element.Source; var imageView = Control; if (imageView == null) { return; } ((IElementController)Element).SetValueFromRenderer(CachedImage.IsLoadingPropertyKey, true); if (Element != null && object.Equals(Element.Source, source) && !_isDisposed) { Cancel(); TaskParameter imageLoader = null; var ffSource = ImageSourceBinding.GetImageSourceBinding(source); if (ffSource == null) { if (imageView != null) { imageView.SetImageDrawable(null); } ImageLoadingFinished(Element); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.Instance.LoadUrl(ffSource.Path, Element.CacheDuration); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.Instance.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.Instance.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.Instance.LoadFile(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Stream) { imageLoader = ImageService.Instance.LoadStream(ffSource.Stream); } if (imageLoader != null) { // CustomKeyFactory if (Element.CacheKeyFactory != null) { var bindingContext = Element.BindingContext; imageLoader.CacheKey(Element.CacheKeyFactory.GetKey(source, bindingContext)); } // LoadingPlaceholder if (Element.LoadingPlaceholder != null) { var placeholderSource = ImageSourceBinding.GetImageSourceBinding(Element.LoadingPlaceholder); if (placeholderSource != null) { imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // ErrorPlaceholder if (Element.ErrorPlaceholder != null) { var placeholderSource = ImageSourceBinding.GetImageSourceBinding(Element.ErrorPlaceholder); if (placeholderSource != null) { imageLoader.ErrorPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // Downsample if (Element.DownsampleToViewSize && (Element.Width > 0 || Element.Height > 0)) { if (Element.Height > Element.Width) { imageLoader.DownSample(height: Element.Height.DpToPixels()); } else { imageLoader.DownSample(width: Element.Width.DpToPixels()); } } else if (Element.DownsampleToViewSize && (Element.WidthRequest > 0 || Element.HeightRequest > 0)) { if (Element.HeightRequest > Element.WidthRequest) { imageLoader.DownSample(height: Element.HeightRequest.DpToPixels()); } else { imageLoader.DownSample(width: Element.WidthRequest.DpToPixels()); } } else if ((int)Element.DownsampleHeight != 0 || (int)Element.DownsampleWidth != 0) { if (Element.DownsampleHeight > Element.DownsampleWidth) { imageLoader.DownSample(height: Element.DownsampleUseDipUnits ? Element.DownsampleHeight.DpToPixels() : (int)Element.DownsampleHeight); } else { imageLoader.DownSample(width: Element.DownsampleUseDipUnits ? Element.DownsampleWidth.DpToPixels() : (int)Element.DownsampleWidth); } } // RetryCount if (Element.RetryCount > 0) { imageLoader.Retry(Element.RetryCount, Element.RetryDelay); } // TransparencyChannel if (Element.TransparencyEnabled.HasValue) { imageLoader.TransparencyChannel(Element.TransparencyEnabled.Value); } // FadeAnimation if (Element.FadeAnimationEnabled.HasValue) { imageLoader.FadeAnimation(Element.FadeAnimationEnabled.Value); } // TransformPlaceholders if (Element.TransformPlaceholders.HasValue) { imageLoader.TransformPlaceholders(Element.TransformPlaceholders.Value); } // Transformations if (Element.Transformations != null && Element.Transformations.Count > 0) { imageLoader.Transform(Element.Transformations); } imageLoader.WithPriority(Element.LoadingPriority); var element = Element; imageLoader.Finish((work) => { element.OnFinish(new CachedImageEvents.FinishEventArgs(work)); ImageLoadingFinished(element); }); imageLoader.Success((imageInformation, loadingResult) => element.OnSuccess(new CachedImageEvents.SuccessEventArgs(imageInformation, loadingResult))); imageLoader.Error((exception) => element.OnError(new CachedImageEvents.ErrorEventArgs(exception))); _currentTask = imageLoader.Into(imageView); } } } }
private async void LoadImage() { if (_currentTask != null) _currentTask.Cancel(); TaskParameter imageLoader = null; var ffSource = await FFImageSourceBinding.GetImageSourceBinding(Source); if (ffSource == null) { if (internalImage != null) { await MainThreadDispatcher.Instance.PostAsync(() => { internalImage.Source = null; }); } } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.LoadUrl(ffSource.Path, TimeSpan.FromDays(CacheDuration)); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.LoadFile(ffSource.Path); } if (imageLoader != null) { // CustomKeyFactory if (CacheKeyFactory != null) { var dataContext = DataContext; imageLoader.CacheKey(CacheKeyFactory.GetKey(Source, dataContext)); } // LoadingPlaceholder if (LoadingPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(LoadingPlaceholder); if (placeholderSource != null) imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } // ErrorPlaceholder if (ErrorPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(ErrorPlaceholder); if (placeholderSource != null) imageLoader.ErrorPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } // Downsample if (DownsampleToViewSize && (Width > 0 || Height > 0)) { if (Height > Width) { imageLoader.DownSample(height: Height.PointsToPixels()); } else { imageLoader.DownSample(width: Width.PointsToPixels()); } } else if (DownsampleToViewSize && (MinWidth > 0 || MinHeight > 0)) { if (MinHeight > MinWidth) { imageLoader.DownSample(height: MinHeight.PointsToPixels()); } else { imageLoader.DownSample(width: MinWidth.PointsToPixels()); } } else if ((int)DownsampleHeight != 0 || (int)DownsampleWidth != 0) { if (DownsampleHeight > DownsampleWidth) { imageLoader.DownSample(height: DownsampleUseDipUnits ? DownsampleHeight.PointsToPixels() : (int)DownsampleHeight); } else { imageLoader.DownSample(width: DownsampleUseDipUnits ? DownsampleWidth.PointsToPixels() : (int)DownsampleWidth); } } // Downsample mode imageLoader.DownSampleMode(DownsampleMode); // RetryCount if (RetryCount > 0) { imageLoader.Retry(RetryCount, RetryDelay); } // FadeAnimation imageLoader.FadeAnimation(FadeAnimationEnabled); // TransformPlaceholders imageLoader.TransformPlaceholders(TransformPlaceholders); // Transformations if (Transformations != null && Transformations.Count != 0) { imageLoader.Transform(Transformations); } imageLoader.Finish((work) => OnFinish(new Args.FinishEventArgs(work))); imageLoader.Success((imageSize, loadingResult) => OnSuccess(new Args.SuccessEventArgs(imageSize, loadingResult))); imageLoader.Error((exception) => OnError(new Args.ErrorEventArgs(exception))); _currentTask = imageLoader.Into(internalImage); } }
public FinishEventArgs(IScheduledWork scheduledWork) { ScheduledWork = scheduledWork; }
protected virtual void UpdateImageLoadingTask() { var ffSource = GetImageSourceBinding(ImagePath, ImageStream); var placeholderSource = GetImageSourceBinding(LoadingPlaceholderImagePath, null); Cancel(); TaskParameter imageLoader = null; if (ffSource == null) { _internalImage.Source = null; IsLoading = false; return; } IsLoading = true; if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.Instance.LoadUrl(ffSource.Path, CacheDuration); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.Instance.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.Instance.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.Instance.LoadFile(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Stream) { imageLoader = ImageService.Instance.LoadStream(ffSource.Stream); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.EmbeddedResource) { imageLoader = ImageService.Instance.LoadEmbeddedResource(ffSource.Path); } if (imageLoader != null) { // LoadingPlaceholder if (placeholderSource != null) { if (placeholderSource != null) { imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // ErrorPlaceholder if (!string.IsNullOrWhiteSpace(ErrorPlaceholderImagePath)) { var errorPlaceholderSource = GetImageSourceBinding(ErrorPlaceholderImagePath, null); if (errorPlaceholderSource != null) { imageLoader.ErrorPlaceholder(errorPlaceholderSource.Path, errorPlaceholderSource.ImageSource); } } if (CustomDataResolver != null) { imageLoader.WithCustomDataResolver(CustomDataResolver); imageLoader.WithCustomLoadingPlaceholderDataResolver(CustomLoadingPlaceholderDataResolver); imageLoader.WithCustomErrorPlaceholderDataResolver(CustomErrorPlaceholderDataResolver); } // Downsample if ((int)DownsampleHeight != 0 || (int)DownsampleWidth != 0) { if (DownsampleUseDipUnits) { imageLoader.DownSampleInDip((int)DownsampleWidth, (int)DownsampleHeight); } else { imageLoader.DownSample((int)DownsampleWidth, (int)DownsampleHeight); } } // RetryCount if (RetryCount > 0) { imageLoader.Retry(RetryCount, RetryDelay); } if (BitmapOptimizations.HasValue) { imageLoader.BitmapOptimizations(BitmapOptimizations.Value); } // FadeAnimation if (FadeAnimationEnabled.HasValue) { imageLoader.FadeAnimation(FadeAnimationEnabled.Value, duration: FadeAnimationDuration); } // FadeAnimationForCachedImages if (FadeAnimationEnabled.HasValue && FadeAnimationForCachedImages.HasValue) { imageLoader.FadeAnimation(FadeAnimationEnabled.Value, FadeAnimationForCachedImages.Value, FadeAnimationDuration); } // TransformPlaceholders if (TransformPlaceholders.HasValue) { imageLoader.TransformPlaceholders(TransformPlaceholders.Value); } // Transformations if (Transformations != null && Transformations.Count > 0) { imageLoader.Transform(Transformations); } if (InvalidateLayoutAfterLoaded.HasValue) { imageLoader.InvalidateLayout(InvalidateLayoutAfterLoaded.Value); } imageLoader.WithPriority(LoadingPriority); if (CacheType.HasValue) { imageLoader.WithCache(CacheType.Value); } if (LoadingDelay > 0) { imageLoader.Delay(LoadingDelay); } imageLoader.Finish((work) => { IsLoading = false; OnFinish?.Invoke(this, new Args.FinishEventArgs(work)); }); imageLoader.Success((imageInformation, loadingResult) => { OnSuccess?.Invoke(this, new Args.SuccessEventArgs(imageInformation, loadingResult)); _lastImageSource = ffSource; }); if (OnError != null) { imageLoader.Error((ex) => OnError?.Invoke(this, new Args.ErrorEventArgs(ex))); } if (OnDownloadStarted != null) { imageLoader.DownloadStarted((downloadInformation) => OnDownloadStarted(this, new Args.DownloadStartedEventArgs(downloadInformation))); } if (OnDownloadProgress != null) { imageLoader.DownloadProgress((progress) => OnDownloadProgress(this, new Args.DownloadProgressEventArgs(progress))); } if (OnFileWriteFinished != null) { imageLoader.FileWriteFinished((info) => OnFileWriteFinished(this, new Args.FileWriteFinishedEventArgs(info))); } if (!string.IsNullOrWhiteSpace(CustomCacheKey)) { imageLoader.CacheKey(CustomCacheKey); } SetupOnBeforeImageLoading(imageLoader); _scheduledWork = imageLoader.Into(_internalImage); } }
public void UpdateCell(Post post) { _currentPost = post; _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .FadeAnimation(false, false, 0) .DownSample(200) .Into(avatar); } else { avatar.Image = UIImage.FromBundle("ic_noavatar"); } if (_currentPost.VoteChanging) { Animate(); } else { likeButton.Transform = CGAffineTransform.MakeScale(1f, 1f); likeButton.Selected = _currentPost.Vote; likeButton.Enabled = true; } commentText.Text = _currentPost.Body; loginLabel.Text = _currentPost.Author; //costLabel.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); timestamp.Text = _currentPost.Created.ToPostTime(); likeLabel.Text = AppSettings.LocalizationManager.GetText(_currentPost.NetLikes == 1 ? LocalizationKeys.Like : LocalizationKeys.Likes, _currentPost.NetLikes); flagLabel.Text = AppSettings.LocalizationManager.GetText(_currentPost.NetFlags == 1 ? LocalizationKeys.Flag : LocalizationKeys.Flags, _currentPost.NetFlags); if (!_isInitialized) { avatar.Layer.CornerRadius = avatar.Frame.Size.Width / 2; var tap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); var costTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); var replyTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Reply, _currentPost); }); var likersTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Voters, _currentPost); }); var flagersTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Flagers, _currentPost); }); replyButton.AddGestureRecognizer(replyTap); profileTapView.AddGestureRecognizer(tap); costLabel.AddGestureRecognizer(costTap); likeLabel.AddGestureRecognizer(likersTap); flagLabel.AddGestureRecognizer(flagersTap); commentText.Font = Helpers.Constants.Regular14; loginLabel.Font = Helpers.Constants.Semibold14; likeLabel.Font = Helpers.Constants.Regular12; costLabel.Font = Helpers.Constants.Regular12; replyButton.Font = Helpers.Constants.Regular12; timestamp.Font = Helpers.Constants.Regular12; likeButton.TouchDown += LikeTap; RightSwipeSettings.Transition = MGSwipeTransition.Border; deleteButton = MGSwipeButton.ButtonWithTitle("", UIImage.FromBundle("ic_delete"), UIColor.FromRGB(250, 250, 250), 26, (tableCell) => { CellAction?.Invoke(ActionType.Delete, _currentPost); return(true); }); editButton = MGSwipeButton.ButtonWithTitle("", UIImage.FromBundle("ic_edit"), UIColor.FromRGB(250, 250, 250), 26, (arg0) => { CellAction?.Invoke(ActionType.Edit, _currentPost); return(true); }); flagButton = MGSwipeButton.ButtonWithTitle("", UIImage.FromBundle("ic_flag"), UIColor.FromRGB(250, 250, 250), 26, (arg0) => { CellAction?.Invoke(ActionType.Flag, _currentPost); return(true); }); _isInitialized = true; if (!AppSettings.User.IsAuthenticated) { replyButton.Hidden = true; replyHiddenConstraint.Active = true; replyVisibleConstraint.Active = false; } } if (_currentPost.NetFlags > 0) { flagLabel.Hidden = false; flagVisibleConstraint.Active = true; flagHiddenConstraint.Active = false; } else { flagVisibleConstraint.Active = false; flagHiddenConstraint.Active = true; flagLabel.Hidden = true; } if (_currentPost.NetLikes > 0) { likeLabel.Hidden = false; flagVisibleConstraint.Active = true; likeHiddenConstraint.Active = false; } else { likeLabel.Hidden = true; flagVisibleConstraint.Active = false; likeHiddenConstraint.Active = true; } var rightButtons = new List <MGSwipeButton>(); if (_currentPost.Author != AppSettings.User.Login) { rightButtons.Add(flagButton); } else if (_currentPost.CashoutTime > DateTime.Now) { rightButtons.Insert(0, deleteButton); //rightButtons.Insert(1, editButton); } RightButtons = rightButtons.ToArray(); }
public nfloat UpdateCell(Post post, CellSizeHelper variables) { _currentPost = post; likesMargin = leftMargin; _avatarImage?.RemoveFromSuperview(); _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30)); _avatarImage.Layer.CornerRadius = _avatarImage.Frame.Size.Width / 2; _avatarImage.ClipsToBounds = true; _avatarImage.ContentMode = UIViewContentMode.ScaleAspectFill; _contentView.AddSubview(_avatarImage); _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .FadeAnimation(false) .DownSample(200) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Normal) .Into(_avatarImage); } else { _avatarImage.Image = UIImage.FromBundle("ic_noavatar"); } _author.Text = _currentPost.Author; _timestamp.Text = _currentPost.Created.ToPostTime(); _photoScroll.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, UIScreen.MainScreen.Bounds.Width, variables.PhotoHeight); _photoScroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width * _currentPost.Media.Length, variables.PhotoHeight); foreach (var subview in _photoScroll.Subviews) { subview.RemoveFromSuperview(); } for (int i = 0; i < _scheduledWorkBody.Length; i++) { _scheduledWorkBody[i]?.Cancel(); } _scheduledWorkBody = new IScheduledWork[_currentPost.Media.Length]; _bodyImage = new UIImageView[_currentPost.Media.Length]; for (int i = 0; i < _currentPost.Media.Length; i++) { _bodyImage[i] = new UIImageView(); _bodyImage[i].ClipsToBounds = true; _bodyImage[i].UserInteractionEnabled = true; _bodyImage[i].ContentMode = UIViewContentMode.ScaleAspectFill; _bodyImage[i].Frame = new CGRect(UIScreen.MainScreen.Bounds.Width * i, 0, UIScreen.MainScreen.Bounds.Width, variables.PhotoHeight); _photoScroll.AddSubview(_bodyImage[i]); _scheduledWorkBody[i] = ImageService.Instance.LoadUrl(_currentPost.Media[i].Url) .Retry(2) .FadeAnimation(false) .WithCache(FFImageLoading.Cache.CacheType.All) .WithPriority(LoadingPriority.Highest) /* .DownloadProgress((f)=> * { * })*/ .Into(_bodyImage[i]); } if (_currentPost.TopLikersAvatars.Any() && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0])) { _firstLikerImage?.RemoveFromSuperview(); _firstLikerImage = new UIImageView(); _contentView.AddSubview(_firstLikerImage); _firstLikerImage.Layer.CornerRadius = likersCornerRadius; _firstLikerImage.ClipsToBounds = true; _firstLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _firstLikerImage.Frame = new CGRect(leftMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkfirst?.Cancel(); _scheduledWorkfirst = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[0], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .DownSample(width: 100) .FadeAnimation(false) .WithPriority(LoadingPriority.Lowest) .Into(_firstLikerImage); likesMargin = _firstLikerImage.Frame.Right + likesMarginConst; } else if (_firstLikerImage != null) { _firstLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1])) { _secondLikerImage?.RemoveFromSuperview(); _secondLikerImage = new UIImageView(); _contentView.AddSubview(_secondLikerImage); _secondLikerImage.Layer.CornerRadius = likersCornerRadius; _secondLikerImage.ClipsToBounds = true; _secondLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _secondLikerImage.Frame = new CGRect(_firstLikerImage.Frame.Right - likersMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorksecond?.Cancel(); _scheduledWorksecond = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[1], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_secondLikerImage); likesMargin = _secondLikerImage.Frame.Right + likesMarginConst; } else if (_secondLikerImage != null) { _secondLikerImage.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2])) { _thirdLikerImage?.RemoveFromSuperview(); _thirdLikerImage = new UIImageView(); _contentView.AddSubview(_thirdLikerImage); _thirdLikerImage.Layer.CornerRadius = likersCornerRadius; _thirdLikerImage.ClipsToBounds = true; _thirdLikerImage.ContentMode = UIViewContentMode.ScaleAspectFill; _thirdLikerImage.Frame = new CGRect(_secondLikerImage.Frame.Right - likersMargin, _photoScroll.Frame.Bottom + likersY, likersImageSide, likersImageSide); _scheduledWorkthird?.Cancel(); _scheduledWorkthird = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[2], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .FadeAnimation(false) .Into(_thirdLikerImage); likesMargin = _thirdLikerImage.Frame.Right + likesMarginConst; } else if (_thirdLikerImage != null) { _thirdLikerImage.Hidden = true; } nfloat flagMargin = 0; if (_currentPost.NetLikes != 0) { _likes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Likes, _currentPost.NetLikes); var likesWidth = _likes.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _likes.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, likesWidth.Width, underPhotoPanelHeight); flagMargin = flagsMarginConst; } else { _likes.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, 0, 0); } _likersTapView.Frame = new CGRect(leftMargin, _photoScroll.Frame.Bottom, _likes.Frame.Right - leftMargin, _likes.Frame.Height); if (_currentPost.NetFlags != 0) { _flags.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Flags, _currentPost.NetFlags); var flagsWidth = _flags.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); _flags.Frame = new CGRect(likesMargin + _likes.Frame.Width + flagMargin, _photoScroll.Frame.Bottom, flagsWidth.Width, underPhotoPanelHeight); } else { _flags.Frame = new CGRect(likesMargin, _photoScroll.Frame.Bottom, 0, 0); } _like.Frame = new CGRect(_contentView.Frame.Width - likeButtonWidthConst, _photoScroll.Frame.Bottom, likeButtonWidthConst, underPhotoPanelHeight); _like.Transform = CGAffineTransform.MakeScale(1f, 1f); if (_currentPost.VoteChanging) { Animate(); } else { _like.Layer.RemoveAllAnimations(); _like.LayoutIfNeeded(); _like.Image = _currentPost.Vote ? UIImage.FromBundle("ic_like_active") : UIImage.FromBundle("ic_like"); _like.UserInteractionEnabled = true; } _verticalSeparator.Frame = new CGRect(_contentView.Frame.Width - likeButtonWidthConst - 1, _photoScroll.Frame.Bottom + underPhotoPanelHeight / 2 - verticalSeparatorHeight / 2, 1, verticalSeparatorHeight); /* * _rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); * var rewardWidth = _rewards.SizeThatFits(new CGSize(0, underPhotoPanelHeight)); * _rewards.Frame = new CGRect(_verticalSeparator.Frame.Left - rewardWidth.Width, _photoScroll.Frame.Bottom, rewardWidth.Width, underPhotoPanelHeight); */ _topSeparator.Frame = new CGRect(0, _photoScroll.Frame.Bottom + underPhotoPanelHeight, UIScreen.MainScreen.Bounds.Width, 1); _attributedLabel.SetText(variables.Text); _attributedLabel.Frame = new CGRect(new CGPoint(leftMargin, _topSeparator.Frame.Bottom + 15), new CGSize(UIScreen.MainScreen.Bounds.Width - leftMargin * 2, variables.TextHeight)); _comments.Text = _currentPost.Children == 0 ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment) : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children); _comments.Frame = new CGRect(leftMargin - 5, _attributedLabel.Frame.Bottom + 5, _comments.SizeThatFits(new CGSize(10, 20)).Width + 10, 20 + 10); _bottomSeparator.Frame = new CGRect(0, _comments.Frame.Bottom + 10, UIScreen.MainScreen.Bounds.Width, 1); return(_bottomSeparator.Frame.Bottom); //for constant size checking //var constantsSize = _bottomSeparator.Frame.Bottom - _attributedLabel.Frame.Height - _bodyImage.Frame.Height; }
void UpdateImage(PImageView imageView, CachedImage image, CachedImage previousImage) { lock (_updateBitmapLock) { CancelIfNeeded(); if (image == null || imageView == null || imageView.Handle == IntPtr.Zero || _isDisposed) { return; } var ffSource = ImageSourceBinding.GetImageSourceBinding(image.Source, image); if (ffSource == null) { if (_lastImageSource == null) { return; } _lastImageSource = null; imageView.Image = null; return; } if (previousImage != null && !ffSource.Equals(_lastImageSource)) { _lastImageSource = null; imageView.Image = null; } image.SetIsLoading(true); var placeholderSource = ImageSourceBinding.GetImageSourceBinding(image.LoadingPlaceholder, image); var errorPlaceholderSource = ImageSourceBinding.GetImageSourceBinding(image.ErrorPlaceholder, image); TaskParameter imageLoader; image.SetupOnBeforeImageLoading(out imageLoader, ffSource, placeholderSource, errorPlaceholderSource); if (imageLoader != null) { var finishAction = imageLoader.OnFinish; var sucessAction = imageLoader.OnSuccess; imageLoader.Finish((work) => { finishAction?.Invoke(work); ImageLoadingSizeChanged(image, false); }); imageLoader.Success((imageInformation, loadingResult) => { sucessAction?.Invoke(imageInformation, loadingResult); _lastImageSource = ffSource; }); imageLoader.LoadingPlaceholderSet(() => ImageLoadingSizeChanged(image, true)); if (!_isDisposed) { _currentTask = imageLoader.Into(imageView); } } } }
private void SetImage(CachedImage oldElement = null) { Xamarin.Forms.ImageSource source = Element.Source; var ffSource = ImageSourceBinding.GetImageSourceBinding(source, Element); var placeholderSource = ImageSourceBinding.GetImageSourceBinding(Element.LoadingPlaceholder, Element); if (oldElement != null && _lastImageSource != null && ffSource != null && !ffSource.Equals(_lastImageSource) && (string.IsNullOrWhiteSpace(placeholderSource?.Path) || placeholderSource?.Stream != null)) { _lastImageSource = null; Control.Image = null; } Element.SetIsLoading(true); Cancel(); TaskParameter imageLoader = null; if (ffSource == null) { if (Control != null) { Control.Image = null; } ImageLoadingFinished(Element); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.Instance.LoadUrl(ffSource.Path, Element.CacheDuration); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.Instance.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.Instance.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.Instance.LoadFile(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Stream) { imageLoader = ImageService.Instance.LoadStream(ffSource.Stream); } if (imageLoader != null) { // CustomKeyFactory if (Element.CacheKeyFactory != null) { var bindingContext = Element.BindingContext; imageLoader.CacheKey(Element.CacheKeyFactory.GetKey(source, bindingContext)); } // LoadingPlaceholder if (Element.LoadingPlaceholder != null) { if (placeholderSource != null) { imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // ErrorPlaceholder if (Element.ErrorPlaceholder != null) { var errorPlaceholderSource = ImageSourceBinding.GetImageSourceBinding(Element.ErrorPlaceholder, Element); if (errorPlaceholderSource != null) { imageLoader.ErrorPlaceholder(errorPlaceholderSource.Path, errorPlaceholderSource.ImageSource); } } // Enable vector image source var vect1 = Element.Source as IVectorImageSource; var vect2 = Element.LoadingPlaceholder as IVectorImageSource; var vect3 = Element.ErrorPlaceholder as IVectorImageSource; if (vect1 != null) { imageLoader.WithCustomDataResolver(vect1.GetVectorDataResolver()); } if (vect2 != null) { imageLoader.WithCustomLoadingPlaceholderDataResolver(vect2.GetVectorDataResolver()); } if (vect3 != null) { imageLoader.WithCustomErrorPlaceholderDataResolver(vect3.GetVectorDataResolver()); } if (Element.CustomDataResolver != null) { imageLoader.WithCustomDataResolver(Element.CustomDataResolver); imageLoader.WithCustomLoadingPlaceholderDataResolver(Element.CustomDataResolver); imageLoader.WithCustomErrorPlaceholderDataResolver(Element.CustomDataResolver); } // Downsample if (Element.DownsampleToViewSize && (Element.Width > 0 || Element.Height > 0)) { if (Element.Height > Element.Width) { imageLoader.DownSampleInDip(height: (int)Element.Height); } else { imageLoader.DownSampleInDip(width: (int)Element.Width); } } else if (Element.DownsampleToViewSize && (Element.WidthRequest > 0 || Element.HeightRequest > 0)) { if (Element.HeightRequest > Element.WidthRequest) { imageLoader.DownSampleInDip(height: (int)Element.HeightRequest); } else { imageLoader.DownSampleInDip(width: (int)Element.WidthRequest); } } else if ((int)Element.DownsampleHeight != 0 || (int)Element.DownsampleWidth != 0) { if (Element.DownsampleHeight > Element.DownsampleWidth) { if (Element.DownsampleUseDipUnits) { imageLoader.DownSampleInDip(height: (int)Element.DownsampleHeight); } else { imageLoader.DownSample(height: (int)Element.DownsampleHeight); } } else { if (Element.DownsampleUseDipUnits) { imageLoader.DownSampleInDip(width: (int)Element.DownsampleWidth); } else { imageLoader.DownSample(width: (int)Element.DownsampleWidth); } } } // RetryCount if (Element.RetryCount > 0) { imageLoader.Retry(Element.RetryCount, Element.RetryDelay); } if (Element.BitmapOptimizations.HasValue) { imageLoader.BitmapOptimizations(Element.BitmapOptimizations.Value); } // FadeAnimation if (Element.FadeAnimationEnabled.HasValue) { imageLoader.FadeAnimation(Element.FadeAnimationEnabled.Value); } // TransformPlaceholders if (Element.TransformPlaceholders.HasValue) { imageLoader.TransformPlaceholders(Element.TransformPlaceholders.Value); } // Transformations if (Element.Transformations != null && Element.Transformations.Count > 0) { imageLoader.Transform(Element.Transformations); } imageLoader.WithPriority(Element.LoadingPriority); if (Element.CacheType.HasValue) { imageLoader.WithCache(Element.CacheType.Value); } if (Element.LoadingDelay.HasValue) { imageLoader.Delay(Element.LoadingDelay.Value); } var element = Element; imageLoader.Finish((work) => { element.OnFinish(new CachedImageEvents.FinishEventArgs(work)); ImageLoadingFinished(element); }); imageLoader.Success((imageInformation, loadingResult) => { element.OnSuccess(new CachedImageEvents.SuccessEventArgs(imageInformation, loadingResult)); _lastImageSource = ffSource; }); imageLoader.Error((exception) => element.OnError(new CachedImageEvents.ErrorEventArgs(exception))); imageLoader.DownloadStarted((downloadInformation) => element.OnDownloadStarted(new CachedImageEvents.DownloadStartedEventArgs(downloadInformation))); imageLoader.DownloadProgress((progress) => element.OnDownloadProgress(new CachedImageEvents.DownloadProgressEventArgs(progress))); imageLoader.FileWriteFinished((fileWriteInfo) => element.OnFileWriteFinished(new CachedImageEvents.FileWriteFinishedEventArgs(fileWriteInfo))); _currentTask = imageLoader.Into(Control); } }
public override void UpdateCell(Post post) { _currentPost = post; avatarImage.Image = null; _scheduledWorkAvatar?.Cancel(); bodyImage.Image = null; _scheduledWorkBody?.Cancel(); var media = _currentPost.Media[0]; _scheduledWorkBody = ImageService.Instance.LoadUrl(media.Url, Helpers.Constants.ImageCacheDuration) //.Retry(5) .FadeAnimation(false) .WithCache(FFImageLoading.Cache.CacheType.All) .DownSample((int)UIScreen.MainScreen.Bounds.Width) .WithPriority(LoadingPriority.Highest) .Into(bodyImage); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .FadeAnimation(false) .DownSample(200) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Normal) .Into(avatarImage); } else { avatarImage.Image = UIImage.FromBundle("ic_noavatar"); } topLikers.Hidden = true; if (_currentPost.TopLikersAvatars.Count() >= 1 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0])) { _scheduledWorkfirst?.Cancel(); firstLiker.Image = null; topLikers.Hidden = false; firstLiker.Hidden = false; _scheduledWorkfirst = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[0], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .DownSample(width: 100) .WithPriority(LoadingPriority.Lowest) .Into(firstLiker); } else { firstLiker.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1])) { _scheduledWorksecond?.Cancel(); secondLiker.Image = null; secondLiker.Hidden = false; _scheduledWorksecond = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[1], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .Into(secondLiker); } else { secondLiker.Hidden = true; } if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2])) { _scheduledWorkthird?.Cancel(); thirdLiker.Image = null; thirdLiker.Hidden = false; _scheduledWorkthird = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[2], TimeSpan.FromDays(30)) .WithCache(FFImageLoading.Cache.CacheType.All) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .WithPriority(LoadingPriority.Lowest) .DownSample(width: 100) .Into(thirdLiker); } else { thirdLiker.Hidden = true; } cellText.Text = _currentPost.Author; rewards.Hidden = !BasePresenter.User.IsNeedRewards; //rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); netVotes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Like, _currentPost.NetVotes); if (_currentPost.VoteChanging) { Animate(); } else { likeButton.Transform = CGAffineTransform.MakeScale(1f, 1f); likeButton.Selected = _currentPost.Vote; } flagButton.Selected = _currentPost.Flag; viewCommentText.Text = _currentPost.Children == 0 ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment) : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children); likeButton.Enabled = true; flagButton.Enabled = true; postTimeStamp.Text = _currentPost.Created.ToPostTime(); imageHeight.Constant = PhotoHeight.Get(media.Size); contentViewWidth.Constant = UIScreen.MainScreen.Bounds.Width; if (!_isButtonBinded) { cellText.Font = Helpers.Constants.Semibold14; postTimeStamp.Font = Helpers.Constants.Regular12; netVotes.Font = Helpers.Constants.Semibold14; rewards.Font = Helpers.Constants.Semibold14; viewCommentText.Font = Helpers.Constants.Regular14; avatarImage.Layer.CornerRadius = avatarImage.Frame.Size.Width / 2; firstLiker.Layer.CornerRadius = firstLiker.Frame.Size.Width / 2; secondLiker.Layer.CornerRadius = secondLiker.Frame.Size.Width / 2; thirdLiker.Layer.CornerRadius = thirdLiker.Frame.Size.Width / 2; attributedLabel = new TTTAttributedLabel(); attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link; var prop = new NSDictionary(); attributedLabel.LinkAttributes = prop; attributedLabel.ActiveLinkAttributes = prop; commentView.AddSubview(attributedLabel); attributedLabel.Font = Helpers.Constants.Regular14; attributedLabel.Lines = 0; attributedLabel.UserInteractionEnabled = true; attributedLabel.Enabled = true; attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 15f); attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 15f); attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 15f); viewCommentText.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, attributedLabel, 5f); attributedLabel.Delegate = new TTTAttributedLabelFeedDelegate(TagAction); UITapGestureRecognizer tap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Preview, _currentPost); }); bodyImage.AddGestureRecognizer(tap); UITapGestureRecognizer imageTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); UITapGestureRecognizer textTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); UITapGestureRecognizer moneyTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); avatarImage.AddGestureRecognizer(imageTap); cellText.AddGestureRecognizer(textTap); rewards.AddGestureRecognizer(moneyTap); UITapGestureRecognizer commentTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Comments, _currentPost); }); viewCommentText.AddGestureRecognizer(commentTap); UITapGestureRecognizer netVotesTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Voters, _currentPost); }); netVotes.AddGestureRecognizer(netVotesTap); flagButton.TouchDown += FlagButton_TouchDown; likeButton.TouchDown += LikeTap; _isButtonBinded = true; Debug.WriteLine("Cell created"); } var noLinkAttribute = new UIStringAttributes { Font = Helpers.Constants.Regular14, ForegroundColor = Helpers.Constants.R15G24B30, }; var at = new NSMutableAttributedString(); at.Append(new NSAttributedString(_currentPost.Title, noLinkAttribute)); if (!string.IsNullOrEmpty(_currentPost.Description)) { at.Append(new NSAttributedString(Environment.NewLine)); at.Append(new NSAttributedString(Environment.NewLine)); at.Append(new NSAttributedString(_currentPost.Description, noLinkAttribute)); } foreach (var tag in _currentPost.Tags) { if (tag == "steepshot") { continue; } var linkAttribute = new UIStringAttributes { Link = new NSUrl(tag), Font = Helpers.Constants.Regular14, ForegroundColor = Helpers.Constants.R231G72B0, }; at.Append(new NSAttributedString($" #{tag}", linkAttribute)); } attributedLabel.SetText(at); }
private async void LoadImage() { if (_currentTask != null) { _currentTask.Cancel(); } TaskParameter imageLoader = null; var ffSource = await FFImageSourceBinding.GetImageSourceBinding(Source).ConfigureAwait(false); if (ffSource == null) { if (internalImage != null) { await MainThreadDispatcher.Instance.PostAsync(() => { internalImage.Source = null; }); } } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.Instance.LoadUrl(ffSource.Path, TimeSpan.FromDays(CacheDuration)); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.Instance.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.Instance.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.Instance.LoadFile(ffSource.Path); } if (imageLoader != null) { // CustomKeyFactory if (CacheKeyFactory != null) { var dataContext = DataContext; imageLoader.CacheKey(CacheKeyFactory.GetKey(Source, dataContext)); } // LoadingPlaceholder if (LoadingPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(LoadingPlaceholder); if (placeholderSource != null) { imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // ErrorPlaceholder if (ErrorPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(ErrorPlaceholder); if (placeholderSource != null) { imageLoader.ErrorPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } } // Downsample if (DownsampleToViewSize && (Width > 0 || Height > 0)) { if (Height > Width) { imageLoader.DownSampleInDip(height: (int)Height); } else { imageLoader.DownSampleInDip(width: (int)Width); } } else if (DownsampleToViewSize && (MinWidth > 0 || MinHeight > 0)) { if (MinHeight > MinWidth) { imageLoader.DownSampleInDip(height: (int)MinHeight); } else { imageLoader.DownSampleInDip(width: (int)MinWidth); } } else if ((int)DownsampleHeight != 0 || (int)DownsampleWidth != 0) { if (DownsampleHeight > DownsampleWidth) { if (DownsampleUseDipUnits) { imageLoader.DownSampleInDip(height: (int)DownsampleHeight); } else { imageLoader.DownSample(height: (int)DownsampleHeight); } } else { if (DownsampleUseDipUnits) { imageLoader.DownSampleInDip(width: (int)DownsampleWidth); } else { imageLoader.DownSample(width: (int)DownsampleWidth); } } } // Downsample mode imageLoader.DownSampleMode(DownsampleMode); // RetryCount if (RetryCount > 0) { imageLoader.Retry(RetryCount, RetryDelay); } // FadeAnimation imageLoader.FadeAnimation(FadeAnimationEnabled); // TransformPlaceholders imageLoader.TransformPlaceholders(TransformPlaceholders); // Transformations if (Transformations != null && Transformations.Count != 0) { imageLoader.Transform(Transformations); } imageLoader.WithPriority(LoadingPriority); imageLoader.WithCache(CacheType); imageLoader.Finish((work) => OnFinish(new Args.FinishEventArgs(work))); imageLoader.Success((imageInformation, loadingResult) => OnSuccess(new Args.SuccessEventArgs(imageInformation, loadingResult))); imageLoader.Error((exception) => OnError(new Args.ErrorEventArgs(exception))); _currentTask = imageLoader.Into(internalImage); } }
private void CleanString(IScheduledWork obj) { _pictureCopy = null; }
public void UpdateCell(Post post) { _currentPost = post; _scheduledWorkAvatar?.Cancel(); if (!string.IsNullOrEmpty(_currentPost.Avatar)) { _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30)) .LoadingPlaceholder("ic_noavatar.png") .ErrorPlaceholder("ic_noavatar.png") .FadeAnimation(false, false, 0) .DownSample(200) .Into(avatar); } else { avatar.Image = UIImage.FromBundle("ic_noavatar"); } if (_currentPost.VoteChanging) { Animate(); } else { likeButton.Transform = CGAffineTransform.MakeScale(1f, 1f); likeButton.Selected = _currentPost.Vote; likeButton.Enabled = true; } commentText.Text = _currentPost.Body; loginLabel.Text = _currentPost.Author; //costLabel.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward); timestamp.Text = _currentPost.Created.ToPostTime(); likeLabel.Text = AppSettings.LocalizationManager.GetText(_currentPost.NetLikes == 1 ? LocalizationKeys.Like : LocalizationKeys.Likes, _currentPost.NetLikes); flagLabel.Text = AppSettings.LocalizationManager.GetText(_currentPost.NetFlags == 1 ? LocalizationKeys.Flag : LocalizationKeys.Flags, _currentPost.NetFlags); if (!_isInitialized) { avatar.Layer.CornerRadius = avatar.Frame.Size.Width / 2; var tap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); var costTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); var replyTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Reply, _currentPost); }); var likersTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Voters, _currentPost); }); var flagersTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Flagers, _currentPost); }); replyButton.AddGestureRecognizer(replyTap); profileTapView.AddGestureRecognizer(tap); costLabel.AddGestureRecognizer(costTap); likeLabel.AddGestureRecognizer(likersTap); flagLabel.AddGestureRecognizer(flagersTap); commentText.Font = Helpers.Constants.Regular14; loginLabel.Font = Helpers.Constants.Semibold14; likeLabel.Font = Helpers.Constants.Regular12; costLabel.Font = Helpers.Constants.Regular12; replyButton.Font = Helpers.Constants.Regular12; timestamp.Font = Helpers.Constants.Regular12; likeButton.TouchDown += LikeTap; otherActionButton.TouchDown += MoreTap; _isInitialized = true; if (!BasePresenter.User.IsAuthenticated) { replyButton.Hidden = true; replyHiddenConstraint.Active = true; replyVisibleConstraint.Active = false; } } if (_currentPost.NetFlags > 0) { flagLabel.Hidden = false; flagVisibleConstraint.Active = true; flagHiddenConstraint.Active = false; } else { flagVisibleConstraint.Active = false; flagHiddenConstraint.Active = true; flagLabel.Hidden = true; } if (_currentPost.NetLikes > 0) { likeLabel.Hidden = false; flagVisibleConstraint.Active = true; likeHiddenConstraint.Active = false; } else { likeLabel.Hidden = true; flagVisibleConstraint.Active = false; likeHiddenConstraint.Active = true; } }
private async void SourcePropertyChanged(string source) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) return; TaskParameter imageLoader = null; var ffSource = await FFImageSourceBinding.GetImageSourceBinding(source); if (ffSource == null) { if (internalImage != null) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { internalImage.Source = null; }); } } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Url) { imageLoader = ImageService.LoadUrl(ffSource.Path, TimeSpan.FromDays(CacheDuration)); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.CompiledResource) { imageLoader = ImageService.LoadCompiledResource(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.ApplicationBundle) { imageLoader = ImageService.LoadFileFromApplicationBundle(ffSource.Path); } else if (ffSource.ImageSource == FFImageLoading.Work.ImageSource.Filepath) { imageLoader = ImageService.LoadFile(ffSource.Path); } if (imageLoader != null) { // LoadingPlaceholder if (LoadingPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(LoadingPlaceholder); if (placeholderSource != null) imageLoader.LoadingPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } // ErrorPlaceholder if (ErrorPlaceholder != null) { var placeholderSource = await FFImageSourceBinding.GetImageSourceBinding(ErrorPlaceholder); if (placeholderSource != null) imageLoader.ErrorPlaceholder(placeholderSource.Path, placeholderSource.ImageSource); } // Downsample if ((int)DownsampleHeight != 0 || (int)DownsampleWidth != 0) { if (DownsampleHeight > DownsampleWidth) { imageLoader.DownSample(height: (int)DownsampleWidth); } else { imageLoader.DownSample(width: (int)DownsampleHeight); } } // RetryCount if (RetryCount > 0) { imageLoader.Retry(RetryCount, RetryDelay); } // TransparencyChannel if (TransparencyEnabled.HasValue) imageLoader.TransparencyChannel(TransparencyEnabled.Value); // FadeAnimation if (FadeAnimationEnabled.HasValue) imageLoader.FadeAnimation(FadeAnimationEnabled.Value); // Transformations if (Transformations != null) { imageLoader.Transform(Transformations); } _currentTask = imageLoader.Into(internalImage); } }