SHARE
TWEET

Untitled

a guest Sep 17th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.movieku.adapter;
  2.  
  3. import android.content.Context;
  4. import android.support.annotation.NonNull;
  5. import android.support.v7.widget.RecyclerView;
  6. import android.view.LayoutInflater;
  7. import android.view.View;
  8. import android.view.ViewGroup;
  9. import android.widget.ImageView;
  10. import android.widget.TextView;
  11.  
  12. import com.bumptech.glide.Glide;
  13. import com.bumptech.glide.request.RequestOptions;
  14. import com.example.movieku.R;
  15. import com.example.movieku.data.Movie;
  16.  
  17. import java.util.ArrayList;
  18.  
  19. public class RecyclerMovieAdapter extends RecyclerView.Adapter<RecyclerMovieAdapter.CategoryViewHolder> {
  20.     //public RecyclerMovieAdapter(Context context) {
  21.        // this.context = context;
  22.    // }
  23.  
  24.  
  25.     private Context context;
  26.     private ArrayList<Movie> listMovie = new ArrayList<>();
  27.  
  28.  
  29.  
  30.  
  31.  
  32.     public ArrayList<Movie> getListMovie() {
  33.  
  34.         return listMovie;
  35.     }
  36.     public void setListTvShow(ArrayList<Movie> listMovie) {
  37.  
  38.         this.listMovie = listMovie;
  39.     }
  40.  
  41.  
  42.  
  43.     @NonNull
  44.     @Override
  45.     public CategoryViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int position) {
  46.         View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_movie, viewGroup, false);
  47.         return new CategoryViewHolder(view);
  48.     }
  49.  
  50.     @Override
  51.     public void onBindViewHolder(@NonNull CategoryViewHolder categoryViewHolder, int position) {
  52.  
  53.         categoryViewHolder.bind(listMovie.get(position));
  54.  
  55.  
  56.     }
  57.  
  58.     @Override
  59.     public int getItemCount() {
  60.  
  61.         return listMovie.size();
  62.     }
  63.     public void setData(ArrayList<Movie> item) {
  64.         this.listMovie=item;
  65.         this.listMovie.addAll(item);
  66.         notifyDataSetChanged();
  67.     }
  68.  
  69.     public class CategoryViewHolder extends RecyclerView.ViewHolder {
  70.  
  71.         TextView movieTitle;
  72.         TextView movieDate;
  73.         TextView movieDescription;
  74.         ImageView moviePoster;
  75.         CategoryViewHolder(View itemView) {
  76.             super(itemView);
  77.             movieTitle = itemView.findViewById(R.id.movie_title);
  78.             movieDate = itemView.findViewById(R.id.movie_date);
  79.             movieDescription = itemView.findViewById(R.id.movie_description);
  80.             moviePoster = itemView.findViewById(R.id.movie_poster);
  81.  
  82.         }
  83.         void bind(Movie Items) {
  84.             movieTitle.setText(Items.getTitle());
  85.             movieDate.setText(Items.getReleaseDate());
  86.             movieDescription.setText(Items.getOverview());
  87.             Glide.with(context)
  88.                     .load(Items.getPosterPath())
  89.                   .apply(new RequestOptions().override(120, 155))
  90.                    .into(moviePoster);
  91.         }
  92.     }
  93. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top