public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { if (position >= 0) { int itemViewType = viewHolder.ItemViewType; PostsObject item = PixelNewsFeedList[position]; if (item == null) { return; } item.Mp4 = Methods.FunString.StringNullRemover(item.Mp4); switch (itemViewType) { case (int)NativeFeedType.Video: { if (viewHolder is Holders.VideoAdapterViewHolder holder) { if (item.MediaSet.Count > 0) { if (!string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { FullGlideRequestBuilder.Load(item.MediaSet[0]?.Extra).Into(holder.VideoImage); } 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.VideoImage); } else { Glide.With(ActivityContext) .AsBitmap() .Placeholder(Resource.Drawable.blackdefault) .Error(Resource.Drawable.blackdefault) .Load(item.MediaSet[0]?.File) // or URI/path .Into(holder.VideoImage); //image view to set thumbnail to } } else { FullGlideRequestBuilder.Load(vidoePlaceHolderImage).Into(holder.VideoImage); } } //GlideImageLoader.LoadImage(ActivityContext, imageUri,holder.VideoImage, ImageStyle.FitCenter, ImagePlaceholders.Color); } holder.MainView.Tag = holder; if (AppSettings.SetTabDarkTheme) { holder.MainPost.SetBackgroundResource(Resource.Drawable.Shape_Radius_Black_Btn); } SetDataDynamicForViewHolder(holder.ItemView, holder.Username, holder.UserAvatar, holder.Description, holder.Likeicon, holder.Favicon, holder.CommentCount, holder.LikeCount, holder.ViewMoreComment, holder.TimeText, holder.Commenticon, holder.Moreicon, holder.ShareIcon, holder.IsPromoted, item); if (!holder.PlayControl.HasOnClickListeners) { holder.PlayControl.Click += (sender, args) => { try { PRecyclerView.GetInstance()?.PlayVideo(!PRecyclerView.GetInstance().CanScrollVertically(1), holder, item); } catch (Exception e) { Console.WriteLine(e); } } } ; } break; } case (int)NativeFeedType.Youtube: { if (viewHolder is Holders.YoutubeAdapterViewHolder holder) { if (item.MediaSet.Count > 0) { if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; } FullGlideRequestBuilder.Load(item.MediaSet[0]?.Extra).Into(holder.VideoThumble); //GlideImageLoader.LoadImage(ActivityContext, item.MediaSet[0]?.Extra, holder.VideoThumble, ImageStyle.FitCenter, ImagePlaceholders.Color); } if (AppSettings.SetTabDarkTheme) { holder.MainPost.SetBackgroundResource(Resource.Drawable.Shape_Radius_Black_Btn); } SetDataDynamicForViewHolder(holder.ItemView, holder.Username, holder.UserAvatar, holder.Description, holder.Likeicon, holder.Favicon, holder.CommentCount, holder.LikeCount, holder.ViewMoreComment, holder.TimeText, holder.Commenticon, holder.Moreicon, holder.ShareIcon, holder.IsPromoted, item); if (!holder.PlayButton.HasOnClickListeners) { holder.PlayButton.Click += (sender, args) => ClickListeners.OnPlayYoutubeButtonClicked(new YoutubeVideoClickEventArgs { Holder = holder, NewsFeedClass = item, Position = position, View = holder.MainView }); } } break; } case (int)NativeFeedType.Photo: { if (viewHolder is Holders.PhotoAdapterViewHolder holder) { if (item.MediaSet.Count > 0) { if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; } FullGlideRequestBuilder.Load(item.MediaSet[0]?.File).Into(holder.Image); //GlideImageLoader.LoadImage(ActivityContext, item.MediaSet[0]?.File, holder.Image, ImageStyle.FitCenter, ImagePlaceholders.Color); } if (AppSettings.SetTabDarkTheme) { holder.MainPost.SetBackgroundResource(Resource.Drawable.Shape_Radius_Black_Btn); } SetDataDynamicForViewHolder(holder.ItemView, holder.Username, holder.UserAvatar, holder.Description, holder.Likeicon, holder.Favicon, holder.CommentCount, holder.LikeCount, holder.ViewMoreComment, holder.TimeText, holder.Commenticon, holder.Moreicon, holder.ShareIcon, holder.IsPromoted, item); } break; } case (int)NativeFeedType.Gif: { if (viewHolder is Holders.PhotoAdapterViewHolder holder) { if (AppSettings.SetTabDarkTheme) { holder.MainPost.SetBackgroundResource(Resource.Drawable.Shape_Radius_Black_Btn); } if (item.MediaSet.Count > 0) { if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; } FullGlideRequestBuilder.Load(item.MediaSet[0]?.File).Into(holder.Image); //GlideImageLoader.LoadImage(ActivityContext, item.MediaSet[0]?.File,holder.Image, ImageStyle.FitCenter, ImagePlaceholders.Color); } SetDataDynamicForViewHolder(holder.ItemView, holder.Username, holder.UserAvatar, holder.Description, holder.Likeicon, holder.Favicon, holder.CommentCount, holder.LikeCount, holder.ViewMoreComment, holder.TimeText, holder.Commenticon, holder.Moreicon, holder.ShareIcon, holder.IsPromoted, item); } break; } case (int)NativeFeedType.MultiPhoto: { if (viewHolder is Holders.MultiPhotoAdapterViewHolder holderMulti) { List <string> list = item.MediaSet.Select(image => image.File).ToList(); if (AppSettings.SetTabDarkTheme) { holderMulti.MainPost.SetBackgroundResource(Resource.Drawable.Shape_Radius_Black_Btn); } holderMulti.ViewPagerLayout.Adapter = new MultiImagePagerAdapter(ActivityContext, list); holderMulti.ViewPagerLayout.CurrentItem = 0; holderMulti.CircleIndicatorView.SetViewPager(holderMulti.ViewPagerLayout); SetDataDynamicForViewHolder(holderMulti.ItemView, holderMulti.Username, holderMulti.UserAvatar, holderMulti.Description, holderMulti.Likeicon, holderMulti.Favicon, holderMulti.CommentCount, holderMulti.LikeCount, holderMulti.ViewMoreComment, holderMulti.TimeText, holderMulti.Commenticon, holderMulti.Moreicon, holderMulti.ShareIcon, holderMulti.IsPromoted, item); } break; } case (int)NativeFeedType.Funding: { HolderFunding = viewHolder as Holders.FundingViewHolder; BindFundingModel(HolderFunding, ListUtils.FundingList); break; } case (int)NativeFeedType.AdMob: { Holders.AdMobAdapterViewHolder holder = viewHolder as Holders.AdMobAdapterViewHolder; new Handler(Looper.MainLooper).Post(new Runnable(() => { BindAdMob(holder); }) ); break; } default: { if (viewHolder is Holders.PhotoAdapterViewHolder holder) { if (AppSettings.SetTabDarkTheme) { holder.MainPost.SetBackgroundResource(Resource.Drawable.Shape_Radius_Black_Btn); } if (item.MediaSet.Count > 0) { if (string.IsNullOrEmpty(item.MediaSet[0]?.Extra)) { item.MediaSet[0].Extra = item.MediaSet[0]?.File; } FullGlideRequestBuilder.Load(item.MediaSet[0]?.File).Into(holder.Image); //GlideImageLoader.LoadImage(ActivityContext, item.MediaSet[0]?.File,holder.Image, ImageStyle.FitCenter, ImagePlaceholders.Color); } SetDataDynamicForViewHolder(holder.ItemView, holder.Username, holder.UserAvatar, holder.Description, holder.Likeicon, holder.Favicon, holder.CommentCount, holder.LikeCount, holder.ViewMoreComment, holder.TimeText, holder.Commenticon, holder.Moreicon, holder.ShareIcon, holder.IsPromoted, item); } break; } } } } catch (Exception exception) { Console.WriteLine(exception); } }