public IList GetPreloadItems(int p0) { try { var d = new List <string>(); var item = FeaturedList[p0]; if (item == null) { return(d); } var type = NewsFeedAdapter.GetPostType(item); switch (type) { case NativeFeedType.Video: case NativeFeedType.Youtube: d.Add(item.MediaSet[0]?.Extra); break; case NativeFeedType.Gif: case NativeFeedType.Photo: if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; } d.Add(item.MediaSet[0]?.Extra); break; case NativeFeedType.MultiPhoto: { foreach (var image in item.MediaSet) { if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; image.Extra = image.File; } d.Add(image.Extra); } break; } } return(d); } catch (Exception e) { Console.WriteLine(e); var d = new List <string>(); return(d); } }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (viewHolder is ExploreAdapterViewHolder holder) { var item = FeaturedList[position]; if (item != null) { item.Mp4 = Methods.FunString.StringNullRemover(item.Mp4); var type = NewsFeedAdapter.GetPostType(item); if (type == NativeFeedType.Video) { FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.PlayIcon, IonIconsFonts.Play); holder.PlayIcon.Visibility = ViewStates.Visible; FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.TypeIcon, IonIconsFonts.Videocamera); holder.TypeIcon.Visibility = ViewStates.Visible; } else if (type == NativeFeedType.Gif) { if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra) && !item.MediaSet[0].Extra.Contains("http")) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; } holder.TypeIcon.Text = ActivityContext.GetText(Resource.String.Lbl_Gif); FontUtils.SetFont(holder.TypeIcon, Fonts.SfSemibold); holder.PlayIcon.Visibility = ViewStates.Gone; holder.TypeIcon.Visibility = ViewStates.Visible; } else if (type == NativeFeedType.MultiPhoto || type == NativeFeedType.Photo) { if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra) && !item.MediaSet[0].Extra.Contains("http")) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; } holder.PlayIcon.Visibility = ViewStates.Gone; holder.TypeIcon.Visibility = ViewStates.Gone; } else if (type == NativeFeedType.Youtube) { FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.PlayIcon, IonIconsFonts.Play); holder.PlayIcon.Visibility = ViewStates.Visible; FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.TypeIcon, IonIconsFonts.SocialYoutube); holder.TypeIcon.Visibility = ViewStates.Visible; } if (type == NativeFeedType.Video) { if (!string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { FullGlideRequestBuilder.Load(item.MediaSet[0]?.Extra).Into(holder.Image); } else { var fileName = item.MediaSet[0].File.Split('/').Last(); var fileNameWithoutExtension = fileName.Split('.').First(); item.MediaSet[0].Extra = Methods.Path.FolderDcimImage + "/" + fileNameWithoutExtension + ".png"; var vidoePlaceHolderImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimImage, fileNameWithoutExtension + ".png"); if (vidoePlaceHolderImage == "File Dont Exists") { var bitmapImage = Methods.MultiMedia.Retrieve_VideoFrame_AsBitmap(ActivityContext, item.MediaSet[0]?.File); if (bitmapImage != null) { Methods.MultiMedia.Export_Bitmap_As_Image(bitmapImage, fileNameWithoutExtension, Methods.Path.FolderDcimImage); FullGlideRequestBuilder.Load(bitmapImage).Into(holder.Image); } else { Glide.With(ActivityContext) .AsBitmap() .Apply(new RequestOptions().Placeholder(Resource.Drawable.blackdefault).Error(Resource.Drawable.blackdefault)) .Load(item.MediaSet[0]?.File) // or URI/path .Into(holder.Image); //image view to set thumbnail to } } else { FullGlideRequestBuilder.Load(vidoePlaceHolderImage).Into(holder.Image); } } } else { var imageUri = item.MediaSet[0]?.File; if (imageUri != null) { FullGlideRequestBuilder.Load(imageUri).Into(holder.Image); } // GlideImageLoader.LoadImage(ActivityContext, imageUri, holder.Image, ImageStyle.CenterCrop, ImagePlaceholders.Color); } } } } catch (Exception exception) { Console.WriteLine(exception); } }