示例#1
0
        public void Into(ITarget <Bitmap, Drawable, Drawable> target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (m_OnStartListener != null)
            {
                m_OnStartListener();
            }

            target.OnPrepareLoad(m_PlaceholderDrawable);

            Request <Bitmap> request = CreateRequest();
            string           key     = Utils.CreateKey(request);

            Action <Bitmap, Drawable> action = new TargetAction <Bitmap, Drawable, Drawable>(
                m_Picasso,
                target,
                request,
                m_SkipCache,
                key,
                m_ErrorDrawable,
                m_OnSuccessListener,
                m_OnFailureListener,
                m_OnFinishListener);

            if (!m_SkipCache)
            {
                Bitmap cachedImage = m_Picasso.QuickMemoryCacheCheck(key);
                if (cachedImage != null && !cachedImage.IsRecycled)
                {
                    m_Picasso.CancelRequest(target);
                    action.Complete(cachedImage, LoadedFrom.Memory);
                    return;
                }
            }

            m_Picasso.EnqueueAndSubmit(action);
        }
示例#2
0
        public void Into(ITarget <UIImage, UIImage, UIImage> target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (m_OnStartListener != null)
            {
                m_OnStartListener();
            }

            target.OnPrepareLoad(m_PlaceholderImage);

            Request <UIImage> request = m_RequestBuilder.Build();
            string            key     = Utils.CreateKey(request);

            var action = new TargetAction <UIImage, UIImage, UIImage> (
                m_Picasso,
                target,
                request,
                m_SkipCache,
                key,
                m_ErrorImage,
                m_OnSuccessListener,
                m_OnFailureListener,
                m_OnFinishListener);

            if (!m_SkipCache)
            {
                UIImage cachedImage = m_Picasso.Cache.Get(key);
                if (cachedImage != null)
                {
                    m_Picasso.CancelRequest(target);
                    action.Complete(cachedImage, LoadedFrom.Memory);
                    return;
                }
            }

            m_Picasso.EnqueueAndSubmit(action);
        }