public NewsFeedAdapter(Activity context, PRecyclerView recyclerView) { try { ActivityContext = context; MainRecyclerView = recyclerView; PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(ActivityContext) { Orientation = LinearLayoutManager.Vertical }; mLayoutManager.SetPreloadItemCount(5); MainRecyclerView.SetLayoutManager(mLayoutManager); MainRecyclerView.GetLayoutManager().ItemPrefetchEnabled = true; FullGlideRequestBuilder = Glide.With(context).AsDrawable().SetDiskCacheStrategy(DiskCacheStrategy.Automatic).SkipMemoryCache(true).Override(550).Placeholder(new ColorDrawable(Color.ParseColor("#efefef"))); FixedPreloadSizeProvider sizeProvider = new FixedPreloadSizeProvider(10, 10); RecyclerViewPreloader <PostsObject> preLoader = new RecyclerViewPreloader <PostsObject>(context, this, sizeProvider, 8); MainRecyclerView.AddOnScrollListener(preLoader); MainRecyclerView.SetAdapter(this); PixelNewsFeedList = new ObservableCollection <PostsObject>(); ReadMoreOption = new ReadMoreOption.Builder(ActivityContext) .TextLength(200, ReadMoreOption.TypeCharacter) .MoreLabel(ActivityContext.GetText(Resource.String.Lbl_ReadMore)) .LessLabel(ActivityContext.GetText(Resource.String.Lbl_ReadLess)) .MoreLabelColor(Color.ParseColor(AppSettings.MainColor)) .LessLabelColor(Color.ParseColor(AppSettings.MainColor)) .LabelUnderLine(true) .Build(); ClickListeners = new SocialIoClickListeners(context); } catch (Exception e) { Console.WriteLine(e); } }
private void InitComponent(View view) { try { MRecycler = view.FindViewById <PRecyclerView>(Resource.Id.HashtagRecyler); EmptyStateLayout = view.FindViewById <ViewStub>(Resource.Id.viewStub); ProgressBarLoader = view.FindViewById <ProgressBar>(Resource.Id.sectionProgress); SwipeRefreshLayout = (SpringView)view.FindViewById(Resource.Id.material_style_ptr_frame); SwipeRefreshLayout.SetType(SpringView.Type.Overlap); SwipeRefreshLayout.Header = new PixelDefaultHeader(Activity); SwipeRefreshLayout.Footer = new PixelDefaultFooter(Activity); SwipeRefreshLayout.Enable = true; SwipeRefreshLayout.SetListener(this); } catch (Exception e) { Console.WriteLine(e); } }
private void InitComponent(View view) { try { AppBarLayout = view.FindViewById <AppBarLayout>(Resource.Id.appBarLayout); AppBarLayout.SetExpanded(false); StoryRecycler = view.FindViewById <RecyclerView>(Resource.Id.StoryRecyler); TxtAppName = view.FindViewById <TextView>(Resource.Id.Appname); TxtAppName.Text = AppSettings.ApplicationName; TxtAppName.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black); ImageChat = view.FindViewById <ImageView>(Resource.Id.chatbutton); ImageChat.Click += ImageChatOnClick; SwipeRefreshLayout = (SpringView)view.FindViewById(Resource.Id.material_style_ptr_frame); SwipeRefreshLayout.SetType(SpringView.Type.Overlap); SwipeRefreshLayout.Header = new PixelDefaultHeader(Activity); SwipeRefreshLayout.Footer = new PixelDefaultFooter(Activity); SwipeRefreshLayout.Enable = true; SwipeRefreshLayout.SetListener(this); SwipeRefreshLayout.OnFinishFreshAndLoad();//check this RecyclerFeed = view.FindViewById <PRecyclerView>(Resource.Id.RecylerFeed); ProgressBar = view.FindViewById <ProgressBar>(Resource.Id.sectionProgress); ProgressBar.Visibility = ViewStates.Visible; EmptyStateLayout = view.FindViewById <ViewStub>(Resource.Id.viewStub); EmptyStateLayout.Visibility = ViewStates.Gone; } catch (Exception e) { Console.WriteLine(e); } }
public ApiPostUpdaterHelper(HomeActivity activity, PRecyclerView mainRecyclerView, Handler mainHandler) { MainRecyclerView = mainRecyclerView; MainHandler = mainHandler; Activity = activity; }
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); } }