protected ImageLoaderTaskBase(IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, bool clearCacheOnOutOfMemory, bool verboseLoadingCancelledLogging)
        {
            _verboseLoadingCancelledLogging = verboseLoadingCancelledLogging;
            _clearCacheOnOutOfMemory = clearCacheOnOutOfMemory;
            CancellationToken = new CancellationTokenSource();
            Parameters = parameters;
            NumberOfRetryNeeded = parameters.RetryCount;
            MainThreadDispatcher = mainThreadDispatcher;
            Logger = miniLogger;
            ConfigureParameters();

            _hasCustomCacheKey = !string.IsNullOrWhiteSpace(Parameters.CustomCacheKey);
            _keys = new ConcurrentDictionary<string, string>();

            _transformationsKey = new Lazy<string>(() =>
            {
                if (Parameters.Transformations == null || Parameters.Transformations.Count == 0)
                    return string.Empty;

                return ";" + string.Join(";", Parameters.Transformations.Select(t => t.Key));
            });

            _downsamplingKey = new Lazy<string>(() =>
            {
                if (Parameters.DownSampleSize == null)
                    return string.Empty;

                return string.Concat(";", Parameters.DownSampleSize.Item1, "x", Parameters.DownSampleSize.Item2);
            });

            _rawKey = new Lazy<string>(() => GetKeyInternal(null, true));

            _streamKey = new Lazy<string>(() => "Stream" + GetNextStreamIndex());
        }
Exemplo n.º 2
0
        public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, Func<Image> getNativeControl, Action<WriteableBitmap, bool> doWithImage)
            : base(mainThreadDispatcher, miniLogger, parameters)
        {
            _getNativeControl = getNativeControl;
            _doWithImage = doWithImage;

            DownloadCache = downloadCache;
        }
Exemplo n.º 3
0
		public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, Func<UIView> getNativeControl, Action<UIImage, bool> doWithImage, nfloat imageScale)
			: base(mainThreadDispatcher, miniLogger, parameters)
		{
			_getNativeControl = getNativeControl;
			_doWithImage = doWithImage;
			_imageScale = imageScale;
			DownloadCache = downloadCache;
		}
		protected ImageLoaderTaskBase(IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters)
		{
			CancellationToken = new CancellationTokenSource();
			Parameters = parameters;
			NumberOfRetryNeeded = parameters.RetryCount;
			MainThreadDispatcher = mainThreadDispatcher;
			Logger = miniLogger;
			ConfigureParameters();
		}
Exemplo n.º 5
0
		public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, nfloat imageScale, ITarget<UIImage, ImageLoaderTask> target, bool clearCacheOnOutOfMemory)
			: base(mainThreadDispatcher, miniLogger, parameters, true, clearCacheOnOutOfMemory)
		{
			if (target == null)
				throw new ArgumentNullException(nameof(target));
			
			_target = target;
			DownloadCache = downloadCache;
		}
Exemplo n.º 6
0
		public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, ImageView imageView)
			: base(mainThreadDispatcher, miniLogger, parameters)
		{
			CancellationToken = new CancellationTokenSource();
			Context = Android.App.Application.Context.ApplicationContext;
			DownloadCache = downloadCache;
			_imageWeakReference = new WeakReference<ImageView>(imageView);

			UseFadeInBitmap = true;
		}
Exemplo n.º 7
0
		public ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, TaskParameter parameters, ImageView imageView)
			: base(mainThreadDispatcher, miniLogger, parameters, true)
		{
			DownloadCache = downloadCache;

			if (imageView != null)
			{
				_imageWeakReference = new WeakReference<ImageView>(imageView);
			}
		}
		public static IDataResolver GetResolver(ImageSource source, TaskParameter parameter, IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher)
		{
			switch (source)
			{
				case ImageSource.ApplicationBundle:
				case ImageSource.Filepath:
					return new FilePathDataResolver(source);
				case ImageSource.CompiledResource:
					return new AssetCatalogDataResolver(mainThreadDispatcher);
				case ImageSource.Url:
					return new UrlDataResolver(parameter, downloadCache);
				default:
					throw new ArgumentException("Unknown type of ImageSource");
			}
		}
		public AssetCatalogDataResolver(IMainThreadDispatcher mainThreadDispatcher)
		{
			_mainThreadDispatcher = mainThreadDispatcher;
		}
Exemplo n.º 10
0
		/// <summary>
		/// This constructor is useful for child classes only. It can help when having a totally different loading logic.
		/// </summary>
		/// <param name="miniLogger">Logger</param>
		/// <param name="key">Key.</param>
		/// <param name="imageView">Image view.</param>
		protected ImageLoaderTask(IDownloadCache downloadCache, IMainThreadDispatcher mainThreadDispatcher, IMiniLogger miniLogger, string key, ImageView imageView)
			: this(downloadCache, mainThreadDispatcher, miniLogger, TaskParameter.FromFile(key), imageView)
		{
		}