public override void Set(ImageLoaderTask task, UIImage image, bool isLocalOrFromCache, bool isLoadingPlaceholder) { var control = Control; if (control == null) { return; } var parameters = task.Parameters; bool isFadeAnimationEnabled = parameters.FadeAnimationEnabled ?? ImageService.Instance.Config.FadeAnimationEnabled; bool isFadeAnimationEnabledForCached = isFadeAnimationEnabled && (parameters.FadeAnimationForCachedImages ?? ImageService.Instance.Config.FadeAnimationForCachedImages); if (!isLoadingPlaceholder && isFadeAnimationEnabled && (!isLocalOrFromCache || (isLocalOrFromCache && isFadeAnimationEnabledForCached))) { // fade animation double fadeDuration = (double)((parameters.FadeAnimationDuration.HasValue ? parameters.FadeAnimationDuration.Value : ImageService.Instance.Config.FadeAnimationDuration)) / 1000; UIView.Transition(control, fadeDuration, UIViewAnimationOptions.TransitionCrossDissolve | UIViewAnimationOptions.BeginFromCurrentState, () => { control.Image = image; }, () => { }); } else { control.Image = image; } }
private static IScheduledWork Into(this TaskParameter parameters, Func<Image> getNativeControl, Action<WriteableBitmap, bool> doWithImage) { var task = new ImageLoaderTask(ImageService.Config.DownloadCache, new MainThreadDispatcher(), ImageService.Config.Logger, parameters, getNativeControl, doWithImage); ImageService.LoadImage(task); return task; }
public AsyncDrawable(Resources res, Bitmap bitmap, ImageLoaderTask imageLoaderTask) : base(res, bitmap) { if (imageLoaderTask == null) throw new ArgumentNullException("Parameter 'imageLoaderTask' cannot be null"); _imageLoaderTaskReference = new WeakReference<ImageLoaderTask>(imageLoaderTask); }
private bool UsesSameNativeControl(ImageLoaderTask task) { var currentControl = _getNativeControl(); var control = task._getNativeControl(); if (currentControl == null || control == null || currentControl.Handle == IntPtr.Zero || control.Handle == IntPtr.Zero) return false; return currentControl.Handle == control.Handle; }
public override void Set(ImageLoaderTask task, UIImage image, bool isLocalOrFromCache, bool isLoadingPlaceholder) { var control = Control; if (control == null) { return; } control.SetImage(image, UIControlState.Normal); }
private bool UsesSameNativeControl(ImageLoaderTask task) { var currentControl = _getNativeControl(); var control = task._getNativeControl(); if (currentControl == null || control == null) return false; return currentControl == control; }
public override void SetAsEmpty(ImageLoaderTask task) { var control = Control; if (control == null) { return; } control.SetImage(null, UIControlState.Normal); }
public override void SetAsEmpty(ImageLoaderTask task) { var control = Control; if (control == null) { return; } control.Image = null; }
public override void Set(ImageLoaderTask task, UIImage image, bool isLocalOrFromCache, bool isLoadingPlaceholder) { var control = Control; if (control == null) { return; } control.Image = image; }
private bool UsesSameNativeControl(ImageLoaderTask task) { ImageView currentControl; _imageWeakReference.TryGetTarget(out currentControl); ImageView control; task._imageWeakReference.TryGetTarget(out control); if (currentControl == null || control == null || currentControl.Handle == IntPtr.Zero || control.Handle == IntPtr.Zero) return false; return currentControl.Handle == control.Handle; }
private bool UsesSameNativeControl(ImageLoaderTask task) { var currentControl = _getNativeControl(); var control = task._getNativeControl(); if (currentControl == null || control == null) { return(false); } return(currentControl == control); }
private bool UsesSameNativeControl(ImageLoaderTask task) { var currentControl = _getNativeControl(); var control = task._getNativeControl(); if (currentControl == null || control == null || currentControl.Handle == IntPtr.Zero || control.Handle == IntPtr.Zero) { return(false); } return(currentControl.Handle == control.Handle); }
private bool UsesSameNativeControl(ImageLoaderTask task) { ImageView currentControl; _imageWeakReference.TryGetTarget(out currentControl); ImageView control; task._imageWeakReference.TryGetTarget(out control); if (currentControl == null || control == null || currentControl.Handle == IntPtr.Zero || control.Handle == IntPtr.Zero) { return(false); } return(currentControl.Handle == control.Handle); }
public override bool UsesSameNativeControl(ImageLoaderTask task) { var otherTarget = task._target as IUIViewTarget <TControl>; if (otherTarget == null) { return(false); } var control = Control; var otherControl = otherTarget.Control; if (control == null || otherControl == null) { return(false); } return(control.Handle == otherControl.Handle); }
public AsyncDrawable(Resources res, Bitmap bitmap, ImageLoaderTask imageLoaderTask) : base(res, bitmap) { _imageLoaderTaskReference = new WeakReference<ImageLoaderTask>(imageLoaderTask); }
/// <summary> /// Loads the image into given imageView using defined parameters. /// </summary> /// <param name="parameters">Parameters for loading the image.</param> /// <param name="imageView">Image view that should receive the image.</param> public static IScheduledWork Into(this TaskParameter parameters, ImageViewAsync imageView) { var task = new ImageLoaderTask(ImageService.Config.DownloadCache, new MainThreadDispatcher(), ImageService.Config.Logger, parameters, imageView); ImageService.LoadImage(task); return task; }
private static IScheduledWork Into(this TaskParameter parameters, Func<UIView> getNativeControl, Action<UIImage, bool> doWithImage, float imageScale = -1f) { var task = new ImageLoaderTask(ImageService.Config.DownloadCache, new MainThreadDispatcher(), ImageService.Config.Logger, parameters, getNativeControl, doWithImage, imageScale); ImageService.LoadImage(task); return task; }
/// <summary> /// Invalidate the image corresponding to given parameters from given caches. /// </summary> /// <param name="parameters">Image parameters.</param> /// <param name="cacheType">Cache type.</param> public static void Invalidate(this TaskParameter parameters, CacheType cacheType) { using (var task = new ImageLoaderTask(ImageService.Config.DownloadCache, new MainThreadDispatcher(), ImageService.Config.Logger, parameters, null, null, 1)) { var key = task.GetKey(); ImageService.Invalidate(key, cacheType); } }
public override bool IsTaskValid(ImageLoaderTask task) { return(IsValid); }
public AsyncDrawable(Resources res, Bitmap bitmap, ImageLoaderTask imageLoaderTask) : base(res, bitmap) { _imageLoaderTaskReference = new WeakReference <ImageLoaderTask>(imageLoaderTask); }
private static ImageLoaderTask CreateTask(this TaskParameter parameters, ImageViewAsync imageView) { var task = new ImageLoaderTask(ImageService.Config.DownloadCache, new MainThreadDispatcher(), ImageService.Config.Logger, parameters, imageView); return task; }