예제 #1
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (holder.GetType() == typeof(DummyLoadingViewHolder))
            {
                return;
            }

            Post currentPost = GetPost(position);

            RecyclerViewHolder currentViewHolder = (RecyclerViewHolder)holder;

            // update data
            #pragma warning disable CS0618
            currentViewHolder.Title.TextFormatted = Html.FromHtml(currentPost.Title.Rendered);

            // author
            MediaAuthor author = currentPost.Embedded.Author.FirstOrDefault();

            currentViewHolder.Author.Text = author != null ? author.Name : "Unknown";

            Glide.With(context)
            .Load(currentPost.Embedded.WpFeaturedMedia.FirstOrDefault().SourceUrl)
            .Apply(glideOptions)
            .Into(currentViewHolder.ThumbnailImage);
        }
예제 #2
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            switch ((ViewType)viewType)
            {
            default:
            case ViewType.Post:
                View newsItemView =
                    LayoutInflater.FromContext(context).Inflate(Resource.Layout.PostCardViewItem, parent, false);

                RecyclerViewHolder newHolder = new RecyclerViewHolder(newsItemView);
                newHolder.ItemClick += (o, e) => OnItemClick(e);

                return(newHolder);

            case ViewType.DummyLoadingPost:
                View loadingItemView =
                    LayoutInflater.FromContext(context).Inflate(Resource.Layout.ProgressbarViewItem, parent, false);

                DummyLoadingViewHolder newLoadingHolder = new DummyLoadingViewHolder(loadingItemView);

                return(newLoadingHolder);
            }
        }