示例#1
0
        private void PerformRetry(BitmapHunter hunter)
        {
            if (hunter.Cancelled)
            {
                return;
            }

            if (m_Service.IsShutdown)
            {
                PerformError(hunter);
                return;
            }

            bool hasConnectivity   = m_NetworkInfo != null && m_NetworkInfo.IsConnectedOrConnecting;
            bool shouldRetryHunter = hunter.ShouldRetry(m_AirplaneMode, m_NetworkInfo);

            if (shouldRetryHunter)
            {
                if (hasConnectivity)
                {
                    hunter.Future = m_Service.Submit(hunter);
                }
                else
                {
                    PerformError(hunter);
                }
            }
            else
            {
                PerformError(hunter);
            }
        }
示例#2
0
        void PerformComplete(BitmapHunter hunter)
        {
            if (!hunter.SkipCache)
            {
                m_Cache.Set(hunter.Key, hunter.Result);
            }

            m_Hunters.Remove(hunter.Key);
            Batch(hunter);
        }
示例#3
0
 internal async void DispatchFailed(BitmapHunter hunter)
 {
     await Task.Factory.StartNew(() =>
     {
         lock (m_Lock)
         {
             m_Hunters.Remove(hunter.Key);
         }
         Batch(hunter);
     });
 }
示例#4
0
        void Batch(BitmapHunter hunter)
        {
            if (hunter.Cancelled)
            {
                return;
            }

            m_Batch.Add(hunter);
            if (!m_Handler.HasMessages(HunterDelayNextBatch))
            {
                m_Handler.SendEmptyMessageDelayed(HunterDelayNextBatch, BatchDelay);
            }
        }
示例#5
0
        private void Batch(BitmapHunter hunter)
        {
            if (hunter.IsCancelled)
            {
                return;
            }

            lock (m_Lock)
            {
                m_Batch.Add(hunter);
            }

            Task.Delay(BatchDelay).ContinueWith((t) => PerformBatchComplete());
        }
示例#6
0
        public Bitmap Get()
        {
            if (m_Deferred)
            {
                throw new InvalidOperationException("Fit cannot be used with get");
            }

            if (!m_Data.HasImage)
            {
                return(null);
            }

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

            Action <Bitmap, Drawable> getAction = new GetAction <Bitmap, Drawable>(m_Picasso, request, m_SkipCache, key);

            return(BitmapHunter.ForRequest(m_Picasso, getAction, m_Picasso.Dispatcher, m_Picasso.Cache).Hunt());
        }
示例#7
0
        internal async void DispatchSubmit(Action <UIImage, UIImage> action)
        {
            await Task.Factory.StartNew(() =>
            {
                lock (m_Lock)
                {
                    BitmapHunter hunter;
                    if (m_Hunters.TryGetValue(action.Key, out hunter))
                    {
                        hunter.Attach(action);
                        return;
                    }

                    hunter = BitmapHunter.ForRequest(action.Picasso, action, this, m_Cache);
                    hunter.Run();
                    m_Hunters.Add(action.Key, hunter);
                }
            });
        }
示例#8
0
        void PerformSubmit(Action <Bitmap, Drawable> action)
        {
            BitmapHunter hunter;

            if (m_Hunters.TryGetValue(action.Key, out hunter))
            {
                hunter.Attach(action);
                return;
            }

            if (m_Service.IsShutdown)
            {
                return;
            }

            hunter        = BitmapHunter.ForRequest(action.Picasso, action, this, m_Cache);
            hunter.Future = m_Service.Submit(hunter);
            m_Hunters.Add(action.Key, hunter);
        }
示例#9
0
 internal void DispatchFailed(BitmapHunter hunter)
 {
     m_Handler.SendMessage(m_Handler.ObtainMessage(HunterDecodeFailed, hunter));
 }
示例#10
0
 public void DispatchRetry(BitmapHunter hunter)
 {
     m_Handler.SendMessage(m_Handler.ObtainMessage(HunterRetry, hunter));
 }
示例#11
0
 internal void DispatchComplete(BitmapHunter hunter)
 {
     m_Handler.SendMessage(m_Handler.ObtainMessage(HunterComplete, hunter));
 }
示例#12
0
 void PerformError(BitmapHunter hunter)
 {
     m_Hunters.Remove(hunter.Key);
     Batch(hunter);
 }