Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package codelabs.ambarrukmo.adapter;
- import android.content.Context;
- import android.support.annotation.NonNull;
- import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.TextView;
- import java.util.ArrayList;
- import butterknife.BindView;
- import butterknife.ButterKnife;
- import codelabs.ambarrukmo.R;
- import codelabs.ambarrukmo.model.CategoryListPromo;
- public class MultipleCategoryVerticalAdapter extends RecyclerView.Adapter<MultipleCategoryVerticalAdapter.Holder> implements MultipleCategoryHorizontalAdapter.MultipleHorizontalOnListClick {
- ArrayList<CategoryListPromo.DATABean> categoryListPromos = new ArrayList<>();
- Context context;
- MultipleVerticalClick multipleVerticalClick;
- public MultipleCategoryVerticalAdapter (Context context,MultipleVerticalClick multipleVerticalClick){
- this.context= context;
- this.multipleVerticalClick = multipleVerticalClick;
- }
- public void setList(ArrayList<CategoryListPromo.DATABean> categoryListPromos) {
- this.categoryListPromos = categoryListPromos;
- notifyDataSetChanged();
- }
- @NonNull
- @Override
- public Holder onCreateViewHolder(@NonNull ViewGroup viewGroup, int position) {
- View view = LayoutInflater.from(context).inflate(R.layout.item_multiple_category,viewGroup,false);
- return new Holder(view);
- }
- @Override
- public void onBindViewHolder(@NonNull Holder holder, int position) {
- CategoryListPromo.DATABean data = categoryListPromos.get(position);
- holder.tvCategory.setText(data.getCategory_txt());
- MultipleCategoryHorizontalAdapter multipleCategoryHorizontalAdapter = new MultipleCategoryHorizontalAdapter(context, this);
- LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL, false);
- // holder.rvListCategory.setLayoutManager(linearLayoutManager);
- // holder.rvListCategory.setAdapter(multipleCategoryHorizontalAdapter);
- // multipleCategoryHorizontalAdapter.setList(data.getPromotions());
- }
- @Override
- public int getItemCount() {
- return categoryListPromos.size();
- }
- public class Holder extends RecyclerView.ViewHolder implements View.OnClickListener {
- @BindView(R.id.tv_category)
- TextView tvCategory;
- @BindView(R.id.tv_view_all_catg)
- TextView tvViewAll;
- @BindView(R.id.rv_list_category)
- RecyclerView rvListCategory;
- public Holder(@NonNull View view) {
- super(view);
- ButterKnife.bind(this,view);
- }
- @Override
- public void onClick(View v) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement