// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { Position = position; var item = SubscriptionsList[Position]; if (item != null) { if (item.Type == ItemType.Channel) { if (viewHolder is SubscriptionsAdapterViewHolder holder) { if (ChannelAdapter == null) { ChannelAdapter = new ChannelAdapter(ActivityContext) { ChannelList = new ObservableCollection <UserDataObject>() }; LinearLayoutManager layoutManager = new LinearLayoutManager(ActivityContext, LinearLayoutManager.Horizontal, false); holder.MRecycler.SetLayoutManager(layoutManager); holder.MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <UserDataObject>(ActivityContext, ChannelAdapter, sizeProvider, 10); holder.MRecycler.AddOnScrollListener(preLoader); holder.MRecycler.SetAdapter(ChannelAdapter); ChannelAdapter.ItemClick += ChannelAdapterOnOnItemClick; } if (item.ChannelList.Count > 0) { if (ChannelAdapter.ChannelList.Count == 0) { ChannelAdapter.ChannelList = new ObservableCollection <UserDataObject>(item.ChannelList); ChannelAdapter.NotifyDataSetChanged(); } else if (ChannelAdapter.ChannelList != null && ChannelAdapter.ChannelList.Count != item.ChannelList.Count) { ChannelAdapter.ChannelList = new ObservableCollection <UserDataObject>(item.ChannelList); ChannelAdapter.NotifyDataSetChanged(); } } holder.MainLinear.Visibility = ViewStates.Visible; holder.MoreText.Visibility = ChannelAdapter.ChannelList?.Count >= 5 ? ViewStates.Visible : ViewStates.Invisible; holder.TitleText.Text = ActivityContext.GetString(Resource.String.Lbl_All_Channal); } } else if (item.Type == ItemType.Video) { if (viewHolder is VideoRowAdapterViewHolder videoRow) { GlideImageLoader.LoadImage(ActivityContext, item.VideoData.Thumbnail, videoRow.VideoImage, ImageStyle.CenterCrop, ImagePlaceholders.Drawable); videoRow.TxtDuration.Text = Methods.FunString.SplitStringDuration(item.VideoData.Duration); videoRow.TxtTitle.Text = Methods.FunString.DecodeString(item.VideoData.Title); videoRow.TxtChannelName.Text = AppTools.GetNameFinal(item.VideoData.Owner); videoRow.TxtViewsCount.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(item.VideoData.Views)) + " " + ActivityContext.GetText(Resource.String.Lbl_Views); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, videoRow.MenueView, IonIconsFonts.AndroidMoreVertical); //Verified if (item.VideoData.Owner.Verified == "1") { videoRow.IconVerified.Visibility = ViewStates.Visible; FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, videoRow.IconVerified, IonIconsFonts.CheckmarkCircled); } else { videoRow.IconVerified.Visibility = ViewStates.Gone; } if (!videoRow.MenueView.HasOnClickListeners) { videoRow.MenueView.Click += (sender, args) => { ContextThemeWrapper ctw = new ContextThemeWrapper(ActivityContext, Resource.Style.PopupMenuStyle); PopupMenu popup = new PopupMenu(ctw, videoRow.MenueView); popup.MenuInflater.Inflate(Resource.Menu.Video_More_Menue, popup.Menu); popup.Show(); popup.MenuItemClick += (o, eventArgs) => { try { var id = eventArgs.Item.ItemId; switch (id) { case Resource.Id.menu_AddWatchLater: LibrarySynchronizer.AddToWatchLater(item.VideoData); break; case Resource.Id.menu_AddPlaylist: LibrarySynchronizer.AddToPlaylist(item.VideoData); break; case Resource.Id.menu_Remove: OnMenuRemove_Click(item.VideoData); break; case Resource.Id.menu_Share: LibrarySynchronizer.ShareVideo(item.VideoData); break; case Resource.Id.menu_Report: LibrarySynchronizer.AddReportVideo(item.VideoData); break; } } catch (Exception exception) { Console.WriteLine(exception); } }; } } ; //Set Badge on videos AppTools.ShowGlobalBadgeSystem(videoRow.VideoType, item.VideoData); } } } } catch (Exception exception) { Console.WriteLine(exception); } }