public static void LoadImage(Activity activity, int imageUri, ImageView image, ImageStyle style, ImagePlaceholders imagePlaceholders, bool compress = false, RequestOptions options = null) { try { if (image == null || activity?.IsDestroyed != false) { return; } var newImage = Glide.With(activity); options ??= GetOptions(style, imagePlaceholders); switch (compress) { case true when style != ImageStyle.RoundedCrop: options.Override(AppSettings.ImagePostSize); break; } switch (compress) { case true: options.Override(AppSettings.ImagePostSize); break; } newImage.Load(imageUri).Apply(options).Into(image); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void SetImage(Activity mContext, ImageView GelenView, string URLL, bool isCenterInsade = false, int PlaceHolderAndErrorImages = Resource.Mipmap.logononbg, bool setResize = false) { var Me = DataBase.MEMBER_DATA_GETIR()[0]; try { //val file: File = Glide.with(activity).asFile().load(url).submit().get() //val path: String = file.path RequestOptions options = new RequestOptions() .InvokeDiskCacheStrategy(Com.Bumptech.Glide.Load.Engine.DiskCacheStrategy.All) .CenterCrop() .Placeholder(PlaceHolderAndErrorImages) .Error(PlaceHolderAndErrorImages); if (setResize) { options.Override(500, 500); } if (isCenterInsade) { options.CenterInside(); } mContext.RunOnUiThread(delegate() { Glide.With(mContext) .Load("https://contentoapp.co/app/" + URLL) .Apply(options).Into(GelenView); }); } catch { } }
private RequestOptions GetRequestOptions() { var options = new RequestOptions(); if (placeholder != null) { options = options.Placeholder(placeholder); } if (downScaleType == DownScaleType.FixSize) { options = options.Override(downScale); } if (Circle) { options = options.CircleCrop(); } return(options); }
private RequestOptions GetRequestFileOptions() { var options = new RequestOptions(); options.SkipMemoryCache(true); options.InvokeDiskCacheStrategy(DiskCacheStrategy.None); if (placeholder != null) { options = options.Placeholder(placeholder); } if (downScaleType == DownScaleType.FixSize) { options = options.Override(downScale); } if (Circle) { options = options.CircleCrop(); } return(options); }
public static void LoadImage(Activity activity, string imageUri, ImageView image, ImageStyle style, ImagePlaceholders imagePlaceholders, RequestOptions options = null) { try { if (image == null) { return; } if (string.IsNullOrEmpty(imageUri) || string.IsNullOrWhiteSpace(imageUri)) { imageUri = "blackdefault"; } imageUri = imageUri.Replace(" ", ""); var newImage = Glide.With(activity); if (options == null) { options = GetOptions(style, imagePlaceholders); } if (AppSettings.CompressImage && style != ImageStyle.RoundedCrop) { if (imageUri.Contains("avatar") || imageUri.Contains("Avatar")) { options.Override(AppSettings.AvatarSize); } else if (imageUri.Contains("gif")) { options.Override(AppSettings.ImageSize); } else { options.Override(AppSettings.ImageSize); } } if (AppSettings.CompressImage) { options.Override(AppSettings.ImageSize); } if (imageUri.Contains("no_profile_image") || imageUri.Contains("blackdefault") || imageUri.Contains("no_profile_image_circle") || imageUri.Contains("ImagePlacholder") || imageUri.Contains("ImagePlacholder_circle") || imageUri.Contains("Grey_Offline") || imageUri.Contains("d-avatar")) { if (imageUri.Contains("no_profile_image_circle")) { newImage.Load(Resource.Drawable.no_profile_image_circle).Apply(options).Into(image); } else if (imageUri.Contains("no_profile_image") || imageUri.Contains("d-avatar")) { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder")) { newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder_circle")) { newImage.Load(Resource.Drawable.ImagePlacholder_circle).Apply(options).Into(image); } else if (imageUri.Contains("blackdefault")) { newImage.Load(Resource.Drawable.blackdefault).Apply(options).Into(image); } else { newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image); } } else if (!string.IsNullOrEmpty(imageUri) && imageUri.Contains("http")) { newImage.Load(imageUri).Apply(options).Into(image); } else if (!string.IsNullOrEmpty(imageUri) && (imageUri.Contains("file://") || imageUri.Contains("content://") || imageUri.Contains("storage") || imageUri.Contains("/data/user/0/"))) { File file2 = new File(imageUri); var photoUri = FileProvider.GetUriForFile(activity, activity.PackageName + ".fileprovider", file2); RequestOptions option = style == ImageStyle.CircleCrop ? new RequestOptions().CircleCrop() : new RequestOptions(); newImage.Load(photoUri).Apply(option).Into(image); } else { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } } catch (Exception e) { Console.WriteLine(e); } }
public static void LoadImage(Activity activity, string imageUri, ImageView image, ImageStyle style, ImagePlaceholders imagePlaceholders, bool compress = true, RequestOptions options = null) { try { if (image == null) { return; } if (string.IsNullOrEmpty(imageUri) || string.IsNullOrWhiteSpace(imageUri)) { imageUri = "blackdefault"; } imageUri = imageUri.Replace(" ", ""); var newImage = Glide.With(activity); if (options == null) { options = GetOptions(style, imagePlaceholders); } if (compress) { options.Override(200); } if (imageUri.Contains("no_profile_image") || imageUri.Contains("blackdefault") || imageUri.Contains("no_profile_image_circle") || imageUri.Contains("ImagePlacholder") || imageUri.Contains("ImagePlacholder_circle") || imageUri.Contains("Grey_Offline") || imageUri.Contains("d-avatar")) { if (imageUri.Contains("no_profile_image_circle")) { newImage.Load(Resource.Drawable.no_profile_image_circle).Apply(options).Into(image); } else if (imageUri.Contains("no_profile_image") || imageUri.Contains("d-avatar")) { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder")) { newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder_circle")) { newImage.Load(Resource.Drawable.ImagePlacholder_circle).Apply(options).Into(image); } else if (imageUri.Contains("blackdefault")) { newImage.Load(Resource.Drawable.blackdefault).Apply(options).Into(image); } else if (imageUri.Contains("Grey_Offline")) { newImage.Load(Resource.Drawable.Grey_Offline).Apply(options).Into(image); } } else if (!string.IsNullOrEmpty(imageUri) && imageUri.Contains("http")) { newImage.Load(imageUri).Apply(options).Into(image); } else if (!string.IsNullOrEmpty(imageUri) && (imageUri.Contains("file://") || imageUri.Contains("content://") || imageUri.Contains("storage") || imageUri.Contains("/data/user/0/"))) { var file = Uri.FromFile(new File(imageUri)); newImage.Load(file.Path).Apply(options).Into(image); } else { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } } catch (Exception e) { Console.WriteLine(e); } }
public static void LoadImage(Activity activity, string imageUri, ImageView image, ImageStyle style, ImagePlaceholders imagePlaceholders, bool compress = false, RequestOptions options = null) { try { if (string.IsNullOrEmpty(imageUri) || string.IsNullOrWhiteSpace(imageUri) || image == null || activity?.IsDestroyed != false) { return; } imageUri = imageUri.Replace(" ", ""); var newImage = Glide.With(activity); options ??= GetOptions(style, imagePlaceholders); if (compress && style != ImageStyle.RoundedCrop) { if (imageUri.Contains("avatar") || imageUri.Contains("Avatar")) { options.Override(AppSettings.AvatarPostSize); } else if (imageUri.Contains("gif")) { options.Override(AppSettings.ImagePostSize); } else { options.Override(AppSettings.ImagePostSize); } } if (compress) { options.Override(AppSettings.ImagePostSize); } if (imageUri.Contains("no_profile_image") || imageUri.Contains("blackdefault") || imageUri.Contains("no_profile_image_circle") || imageUri.Contains("ImagePlacholder") || imageUri.Contains("ImagePlacholder_circle") || imageUri.Contains("Grey_Offline") || imageUri.Contains("Image_File") || imageUri.Contains("Audio_File") || imageUri.Contains("addImage") || imageUri.Contains("d-group") || imageUri.Contains("d-cover") || imageUri.Contains("d-avatar") || imageUri.Contains("user_anonymous")) { if (imageUri.Contains("no_profile_image_circle")) { newImage.Load(Resource.Drawable.no_profile_image_circle).Apply(options).Into(image); } else if (imageUri.Contains("no_profile_image") || imageUri.Contains("d-avatar")) { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder")) { newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder_circle")) { newImage.Load(Resource.Drawable.ImagePlacholder_circle).Apply(options).Into(image); } else if (imageUri.Contains("blackdefault")) { newImage.Load(Resource.Drawable.blackdefault).Apply(options).Into(image); } else if (imageUri.Contains("Grey_Offline")) { newImage.Load(Resource.Drawable.Grey_Offline).Apply(options).Into(image); } else if (imageUri.Contains("Image_File")) { newImage.Load(Resource.Drawable.Image_File).Apply(options).Into(image); } else if (imageUri.Contains("Audio_File")) { newImage.Load(Resource.Drawable.Audio_File).Apply(options).Into(image); } else if (imageUri.Contains("addImage")) { newImage.Load(Resource.Drawable.addImage).Apply(options).Into(image); } else if (imageUri.Contains("d-group")) { newImage.Load(Resource.Drawable.default_group).Apply(options).Into(image); } else if (imageUri.Contains("d-page")) { newImage.Load(Resource.Drawable.default_page).Apply(options).Into(image); } else if (imageUri.Contains("d-cover")) { newImage.Load(Resource.Drawable.Cover_image).Apply(options).Into(image); } else if (imageUri.Contains("user_anonymous")) { newImage.Load(Resource.Drawable.user_anonymous).Apply(options).Into(image); } } else if (!string.IsNullOrEmpty(imageUri) && imageUri.Contains("http")) { newImage.Load(imageUri).Apply(options).Into(image); } else if (!string.IsNullOrEmpty(imageUri) && (imageUri.Contains("file://") || imageUri.Contains("content://") || imageUri.Contains("storage") || imageUri.Contains("/data/user/0/"))) { File file2 = new File(imageUri); var photoUri = FileProvider.GetUriForFile(activity, activity.PackageName + ".fileprovider", file2); RequestOptions option = style == ImageStyle.CircleCrop ? new RequestOptions().CircleCrop() : new RequestOptions(); Glide.With(activity).Load(photoUri).Apply(option).Into(image); } else { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public static void LoadImage(Activity activity, string imageUri, ImageView image, ImageStyle style, ImagePlaceholders imagePlaceholders, RequestOptions options = null) { try { if (string.IsNullOrEmpty(imageUri) || string.IsNullOrWhiteSpace(imageUri) || image == null) { return; } imageUri = imageUri.Replace(" ", ""); var newImage = Glide.With(activity); if (options == null) { options = GetOptions(style, imagePlaceholders); } if (AppSettings.CompressImage && style != ImageStyle.RoundedCrop) { if (imageUri.Contains("avatar") || imageUri.Contains("Avatar")) { options.Override(AppSettings.AvatarSize); } else if (imageUri.Contains("gif")) { options.Override(AppSettings.ImageSize); } else { options.Override(AppSettings.ImageSize); } } if (AppSettings.CompressImage) { options.Override(AppSettings.ImageSize); } if (imageUri.Contains("FirstImageOne") || imageUri.Contains("FirstImageTwo") || imageUri.Contains("no_profile_image") || imageUri.Contains("no_profile_image_circle") || imageUri.Contains("ImagePlacholder") || imageUri.Contains("ImagePlacholder_circle") || imageUri.Contains("d-avatar") || imageUri.Contains("Grey_Offline") || imageUri.Contains("addImage")) { if (imageUri.Contains("no_profile_image_circle") || imageUri.Contains("d-avatar.jpg")) { newImage.Load(Resource.Drawable.no_profile_image_circle).Apply(options).Into(image); } else if (imageUri.Contains("no_profile_image") || imageUri.Contains("d-avatar.jpg")) { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder")) { newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder_circle")) { newImage.Load(Resource.Drawable.ImagePlacholder_circle).Apply(options).Into(image); } else if (imageUri.Contains("FirstImageOne")) { newImage.Load(Resource.Drawable.FirstImageOne).Apply(options).Into(image); } else if (imageUri.Contains("FirstImageTwo")) { newImage.Load(Resource.Drawable.FirstImageTwo).Apply(options).Into(image); } else if (imageUri.Contains("addImage.jpg")) { newImage.Load(Resource.Drawable.addImage).Apply(options).Into(image); } else if (imageUri.Contains("Grey_Offline")) { newImage.Load(Resource.Drawable.Grey_Offline).Apply(options).Into(image); } } else if (!string.IsNullOrEmpty(imageUri) && imageUri.Contains("http")) { newImage.Load(imageUri).Apply(options).Into(image); } else if (!string.IsNullOrEmpty(imageUri) && (imageUri.Contains("file://") || imageUri.Contains("content://") || imageUri.Contains("storage") || imageUri.Contains("/data/user/0/"))) { var file = Uri.FromFile(new File(imageUri)); newImage.Load(file.Path).Apply(options).Into(image); } else { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } } catch (Exception e) { Console.WriteLine(e); } }
public static void LoadImage(Activity activity, string imageUri, ImageView image, ImageStyle style, ImagePlaceholders imagePlaceholders, bool compress = true, RequestOptions options = null) { try { if (string.IsNullOrEmpty(imageUri) || string.IsNullOrWhiteSpace(imageUri) || image == null) { return; } imageUri = imageUri.Replace(" ", ""); var newImage = Glide.With(activity); if (options == null) { options = GetOptions(style, imagePlaceholders); } if (compress) { options.Override(AppSettings.ImagePostSize); } if (imageUri.Contains("no_profile_image") || imageUri.Contains("blackdefault") || imageUri.Contains("no_profile_image_circle") || imageUri.Contains("ImagePlacholder") || imageUri.Contains("ImagePlacholder_circle") || imageUri.Contains("Grey_Offline") || imageUri.Contains("d-group") || imageUri.Contains("d-cover") || imageUri.Contains("d-avatar") || imageUri.Contains("EmbedVideo_File") || imageUri.Contains("FirstBackground") || imageUri.Contains("loginBackground") || imageUri.Contains("ForgetPasswordBackground")) { if (imageUri.Contains("no_profile_image")) { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } else if (imageUri.Contains("no_profile_image_circle")) { newImage.Load(Resource.Drawable.no_profile_image_circle).Apply(options).Into(image); } else if (imageUri.Contains("d-avatar")) { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder")) { newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image); } else if (imageUri.Contains("ImagePlacholder_circle")) { newImage.Load(Resource.Drawable.ImagePlacholder_circle).Apply(options).Into(image); } else if (imageUri.Contains("blackdefault")) { newImage.Load(Resource.Drawable.blackdefault).Apply(options).Into(image); } else if (imageUri.Contains("Grey_Offline")) { newImage.Load(Resource.Drawable.Grey_Offline).Apply(options).Into(image); } else if (imageUri.Contains("d-group")) { newImage.Load(Resource.Drawable.default_group).Apply(options).Into(image); } else if (imageUri.Contains("d-cover")) { newImage.Load(Resource.Drawable.Cover_image).Apply(options).Into(image); } else if (imageUri.Contains("EmbedVideo_File")) { newImage.Load(Resource.Drawable.EmbedVideo_File).Apply(options).Into(image); } else if (imageUri.Contains("FirstBackground")) { newImage.Load(Resource.Drawable.FirstBackground).Apply(options).Into(image); } else if (imageUri.Contains("loginBackground")) { newImage.Load(Resource.Drawable.loginBackground).Apply(options).Into(image); } else if (imageUri.Contains("ForgetPasswordBackground")) { newImage.Load(Resource.Drawable.ForgetPasswordBackground).Apply(options).Into(image); } else { newImage.Load(Resource.Drawable.ImagePlacholder).Apply(options).Into(image); } } else if (!string.IsNullOrEmpty(imageUri) && imageUri.Contains("http")) { newImage.Load(imageUri).Apply(options).Into(image); } else if (!string.IsNullOrEmpty(imageUri) && (imageUri.Contains("file://") || imageUri.Contains("content://") || imageUri.Contains("storage") || imageUri.Contains("/data/user/0/"))) { File file2 = new File(imageUri); var photoUri = FileProvider.GetUriForFile(activity, activity.PackageName + ".fileprovider", file2); RequestOptions option = style == ImageStyle.CircleCrop ? new RequestOptions().CircleCrop() : new RequestOptions(); Glide.With(activity).Load(photoUri).Apply(option).Into(image); } else { newImage.Load(Resource.Drawable.no_profile_image).Apply(options).Into(image); } } catch (Exception e) { Console.WriteLine(e); } }