Exemplo n.º 1
0
        public static RequestOptions GetRequestOptions(ImageStyle style, ImagePlaceholders imagePlaceholders)
        {
            try
            {
                var options = new RequestOptions();


                switch (style)
                {
                case ImageStyle.CenterCrop:
                    options.CenterCrop();
                    break;

                case ImageStyle.FitCenter:
                    options.FitCenter();
                    break;

                case ImageStyle.CircleCrop:
                    options.CircleCrop();
                    break;

                case ImageStyle.RoundedCrop:
                    options.Transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(25)))
                    .SetPriority(Priority.High).Override(450)
                    .SetUseAnimationPool(false).SetDiskCacheStrategy(DiskCacheStrategy.All)
                    .Error(Resource.Drawable.ImagePlacholder_circle)
                    .Placeholder(Resource.Drawable.ImagePlacholder_circle);
                    break;

                default:
                    options.CenterCrop();
                    break;
                }


                switch (imagePlaceholders)
                {
                case ImagePlaceholders.Color:
                    var color = Methods.FunString.RandomColor();
                    options.Placeholder(new ColorDrawable(Color.ParseColor(color))).Fallback(new ColorDrawable(Color.ParseColor(color)));
                    break;

                case ImagePlaceholders.Drawable:
                    options.Placeholder(Resource.Drawable.ImagePlacholder).Fallback(Resource.Drawable.ImagePlacholder);
                    break;
                }

                return(options);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new RequestOptions());
            }
        }
Exemplo n.º 2
0
        public static RequestOptions GetRequestOptions(ImageStyle style, ImagePlaceholders imagePlaceholders)
        {
            try
            {
                var options = new RequestOptions();


                switch (style)
                {
                case ImageStyle.CenterCrop:
                    options.CenterCrop();
                    break;

                case ImageStyle.FitCenter:
                    options.FitCenter();
                    break;

                case ImageStyle.CircleCrop:
                    options.CircleCrop();
                    break;

                case ImageStyle.RoundedCrop:
                    options.Transform(new MultiTransformation(new CenterCrop(), new RoundedCorners(20)));
                    break;

                default:
                    options.CenterCrop();
                    break;
                }


                switch (imagePlaceholders)
                {
                case ImagePlaceholders.Color:
                    var color = Methods.FunString.RandomColor();
                    options.Placeholder(new ColorDrawable(Color.ParseColor(color))).Fallback(new ColorDrawable(Color.ParseColor(color)));
                    break;

                case ImagePlaceholders.Drawable:
                    options.Placeholder(Resource.Drawable.ImagePlacholder).Fallback(Resource.Drawable.ImagePlacholder);
                    break;
                }

                return(options);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(new RequestOptions());
            }
        }