Codewaves / Sticky-Header-Grid

Sticky header grid layout manager for RecycleView
MIT License
116 stars 33 forks source link

clicking an item affects another item #16

Open HussamShams opened 6 years ago

HussamShams commented 6 years ago

Hi,

There's nothing wrong with the grid but when I click an item - say section 0, item 10 - the onClick action is triggered on section 0, item 0! I log the section and position and they're always correct. here's the onBindItemViewHolder method:

`public void onBindItemViewHolder(ItemViewHolder viewHolder, final int section, final int position) { final SubjectViewHolder holder = (SubjectViewHolder) viewHolder; Subject subject = subjects.get(section).get(position);

    holder.tvName.setText(subject.getNameEn());

    Glide.with(context)
            .load(subject.isSelected() ? R.drawable.ic_star_selected : R.drawable.ic_star)
            .into(holder.ivSelection);

    holder.tvName.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.e("CLICK", "SEC: " + section + " POS: " + position);
            Flubber.with()
            .animation(Flubber.AnimationPreset.POP)
            .duration(600)
            .createFor(holder.tvName)
            .start();
        }
    });`

How can I fix this?