コード例 #1
0
        private Bitmap ApplyCustomTransformations(List <ITransformation <Bitmap> > transformations, Bitmap result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            for (int i = 0; i < transformations.Count; i++)
            {
                ITransformation <Bitmap> transformation = transformations[i];
                Bitmap newResult = transformation.Transform(result);

                if (newResult == null)
                {
                    StringBuilder builder = new StringBuilder()
                                            .Append("Transformation ")
                                            .Append(transformation.Key)
                                            .Append(" returned null after ")
                                            .Append(i)
                                            .Append(" previous transformation(s).\n\nTransformation list:\n");
                    foreach (ITransformation <Bitmap> t in transformations)
                    {
                        builder.Append(t.Key).Append('\n');
                    }
                    Picasso.RunOnPicassoThread(() =>
                    {
                        throw new NullReferenceException(builder.ToString());
                    });
                    return(null);
                }

                if (newResult == result && result.IsRecycled)
                {
                    Picasso.RunOnPicassoThread(() =>
                    {
                        throw new IllegalStateException("Transformation " +
                                                        transformation.Key + " return input Bitmap but recycled it.");
                    });
                    return(null);
                }

                // If the transformation returned a new bitmap ensure they recycled the original.
                if (newResult != result && !result.IsRecycled)
                {
                    Picasso.RunOnPicassoThread(() =>
                    {
                        throw new IllegalStateException("Transformation "
                                                        + transformation.Key
                                                        + " mutated input Bitmap but failed to recycle the original.");
                    });
                    return(null);
                }

                result = newResult;
            }

            return(result);
        }
コード例 #2
0
ファイル: Dispatcher.cs プロジェクト: nagyist/PicassoSharp
 private void PerformBatchComplete()
 {
     BitmapHunter[] copy;
     lock (m_Lock)
     {
         copy = m_Batch.ToArray();
         m_Batch.Clear();
     }
     Picasso.BatchComplete(copy);
 }
コード例 #3
0
        internal RequestCreator(Picasso picasso, Uri uri, int resourceId)
        {
            if (picasso.IsShutdown)
            {
                throw new Exception("Picasso instance shutdown. Cannot submit new requests");
            }

            m_Data = new Request <Bitmap> .Builder(uri, resourceId);

            m_Picasso = picasso;
        }
コード例 #4
0
        internal RequestCreator(Picasso picasso, Uri uri)
        {
            if (picasso.IsShutdown)
            {
                throw new Exception("Picasso instance shutdown. Cannot submit new requests");
            }

            m_RequestBuilder = new Request <UIImage> .Builder(uri);

            m_Picasso = picasso;
        }
コード例 #5
0
 public UIImageViewAction(
     Picasso picasso,
     UIImageView target,
     Request <UIImage> data,
     bool skipCache,
     string key,
     UIImage errorImage,
     System.Action onSuccessListener,
     System.Action onFailureListener,
     System.Action onFinishListener)
     : base(picasso, target, data, skipCache, FadeMode.Never, key, errorImage, onSuccessListener, onFailureListener, onFinishListener)
 {
 }
コード例 #6
0
ファイル: Picasso.cs プロジェクト: nagyist/PicassoSharp
 public static Picasso With(Context context)
 {
     return(s_Instance ?? (s_Instance = new Builder(context).Build()));
 }
コード例 #7
0
 public ImageViewAction(Picasso picasso, ImageView target, Request <Bitmap> request, bool skipCache, FadeMode fadeMode, string key, Drawable errorImage, System.Action onSuccessListener, System.Action onFailureListener, System.Action onFinishListener)
     : base(picasso, target, request, skipCache, fadeMode, key, errorImage, onSuccessListener, onFailureListener, onFinishListener)
 {
     m_Picasso = picasso;
 }