Advertisement
ricky_yulianto

Untitled

Jul 11th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. package codelabs.ambarrukmo.adapter;
  2.  
  3. import android.content.Context;
  4. import android.support.annotation.NonNull;
  5. import android.support.v7.widget.LinearLayoutManager;
  6. import android.support.v7.widget.RecyclerView;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.widget.TextView;
  11.  
  12. import java.util.ArrayList;
  13.  
  14. import butterknife.BindView;
  15. import butterknife.ButterKnife;
  16. import codelabs.ambarrukmo.R;
  17. import codelabs.ambarrukmo.model.CategoryListPromo;
  18.  
  19. public class MultipleCategoryVerticalAdapter extends RecyclerView.Adapter<MultipleCategoryVerticalAdapter.Holder> implements MultipleCategoryHorizontalAdapter.MultipleHorizontalOnListClick {
  20.  
  21. ArrayList<CategoryListPromo.DATABean> categoryListPromos = new ArrayList<>();
  22. Context context;
  23. MultipleVerticalClick multipleVerticalClick;
  24.  
  25. public MultipleCategoryVerticalAdapter (Context context,MultipleVerticalClick multipleVerticalClick){
  26. this.context= context;
  27. this.multipleVerticalClick = multipleVerticalClick;
  28. }
  29. public void setList(ArrayList<CategoryListPromo.DATABean> categoryListPromos) {
  30. this.categoryListPromos = categoryListPromos;
  31. notifyDataSetChanged();
  32. }
  33.  
  34. @NonNull
  35. @Override
  36. public Holder onCreateViewHolder(@NonNull ViewGroup viewGroup, int position) {
  37. View view = LayoutInflater.from(context).inflate(R.layout.item_multiple_category,viewGroup,false);
  38. return new Holder(view);
  39. }
  40.  
  41. @Override
  42. public void onBindViewHolder(@NonNull Holder holder, int position) {
  43. CategoryListPromo.DATABean data = categoryListPromos.get(position);
  44. holder.tvCategory.setText(data.getCategory_txt());
  45. MultipleCategoryHorizontalAdapter multipleCategoryHorizontalAdapter = new MultipleCategoryHorizontalAdapter(context, this);
  46. LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL, false);
  47. // holder.rvListCategory.setLayoutManager(linearLayoutManager);
  48. // holder.rvListCategory.setAdapter(multipleCategoryHorizontalAdapter);
  49. // multipleCategoryHorizontalAdapter.setList(data.getPromotions());
  50. }
  51.  
  52.  
  53. @Override
  54. public int getItemCount() {
  55. return categoryListPromos.size();
  56. }
  57.  
  58. public class Holder extends RecyclerView.ViewHolder implements View.OnClickListener {
  59.  
  60. @BindView(R.id.tv_category)
  61. TextView tvCategory;
  62. @BindView(R.id.tv_view_all_catg)
  63. TextView tvViewAll;
  64. @BindView(R.id.rv_list_category)
  65. RecyclerView rvListCategory;
  66.  
  67. public Holder(@NonNull View view) {
  68. super(view);
  69. ButterKnife.bind(this,view);
  70. }
  71.  
  72. @Override
  73. public void onClick(View v) {
  74.  
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement