SHARE
TWEET

Untitled

a guest Feb 20th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.         private List<Post> post;
  3.  
  4.         public PostAdapter(List<Post> post)
  5.         {
  6.             this.post = post;
  7.         }
  8.  
  9.         public override int ItemCount => this.post.Count;
  10.  
  11.         public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
  12.         {
  13.             var postHolder = (PostHolder)holder;
  14.  
  15.             postHolder.ProfileImage.SetImageResource(this.post[position].ImgProfileImage);
  16.             postHolder.Nome.Text = this.post[position].TvNome;
  17.             postHolder.Publicacao.SetImageResource(this.post[position].ImgPublicacao);
  18.             postHolder.Titulo.Text = this.post[position].TvTitulo;
  19.             postHolder.SubTitulo.Text = this.post[position].TvSubTitulo;
  20.             postHolder.Gostos.Text = this.post[position].TvGostos;
  21.            
  22.  
  23.         }
  24.  
  25.         public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
  26.         {
  27.             var inflater = LayoutInflater.From(parent.Context);
  28.             var view = inflater.Inflate(Resource.Layout.card_post, parent, false);
  29.  
  30.             return new PostHolder(view, OnCloseClick, OnLikeClick);
  31.         }
  32.  
  33.         private void OnCloseClick(int position)
  34.         {
  35.             this.post.RemoveAt(position);
  36.             NotifyItemRemoved(position);
  37.         }
  38.  
  39.         private void OnLikeClick(int position)
  40.         {
  41.             this.post[position].AddLike();
  42.             NotifyItemChanged(position);
  43.         }
  44.     }
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top