How to make multiple views in recyclerview item clickable?
<p>I have this adapter class where I have an object with a list in it.</p>

<pre><code>public class ProductAdapter extends RecyclerView.Adapter&lt;ProductAdapter.ProductViewHolder&gt; {
private Context context;
private Shop shop;

public ProductAdapter(Context context, Shop shop) {
    this.context = context;
    this.shop = shop;
}

@Override
public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    View v = inflater.inflate(R.layout.product_row, parent, false);
    return new ProductViewHolder(v);
}

@Override
public void onBindViewHolder(ProductViewHolder holder, int position) {
    holder.tvProductTitle.setText(shop.products.get(position).getTitle());
    holder.tvProductDescription.setText(shop.products.get(position).getDescription());
    Glide.with(context)
            .load(shop.products.get(position).getImageUrl())
            .placeholder(android.R.drawable.ic_menu_upload_you_tube)
            .error(android.R.drawable.stat_notify_error)
            .diskCacheStrategy(DiskCacheStrategy.RESULT)
            .into(holder.ivProduct);
}

@Override
public int getItemCount() {
    if (shop.products != null) {
        return shop.products.size();
    }
    return 0;
}

public static class ProductViewHolder extends RecyclerView.ViewHolder {
    private TextView tvProductTitle, tvProductDescription;
    private ImageView ivProduct;

    public ProductViewHolder(View itemView) {
        super(itemView);
        tvProductTitle = (TextView) itemView.findViewById(R.id.tvProductTitle);
        tvProductDescription = (TextView) itemView.findViewById(R.id.tvProductDescription);
        ivProduct = (ImageView) itemView.findViewById(R.id.ivProduct);
    }
}

public interface ClickListener {
    void onClick(View v, int position);

    void onLongClick(View v, int position);
}

public static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
    private GestureDetector gestureDetector;
    private ProductAdapter.ClickListener clickListener;

    public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ProductAdapter.ClickListener clickListener) {
        this.clickListener = clickListener;
        gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                return true;
            }

            @Override
            public void onLongPress(MotionEvent e) {
                View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
                if (child != null &amp;&amp; clickListener != null) {
                    clickListener.onLongClick(child, recyclerView.getChildAdapterPosition(child));
                }
            }
        });
    }

    @Override
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
        View child = rv.findChildViewUnder(e.getX(), e.getY());
        if (child != null &amp;&amp; clickListener != null &amp;&amp; gestureDetector.onTouchEvent(e)) {
            clickListener.onClick(child, rv.getChildAdapterPosition(child));
        }
        return false;
    }

    @Override
    public void onTouchEvent(RecyclerView rv, MotionEvent e) {

    }

    @Override
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

    }
}
</code></pre>

<p>I use this adapter in my fragment where I can click an item from the recyclerview which will open another activity with the selected product and it's parametars. Instead of clicking the whole item, I would like to click on part of it (lets say imageview) which will do the same as it is doing now. But, I would also like to put a checkbox in the recyclerview item itself which will have different function. At the moment, I can't use an intent in the adapter class. The way it is set up now I can only click the whole item. How can I make it work like I explained above?</p>

<pre><code>public class ProductsFragment extends android.support.v4.app.Fragment {
private RecyclerView rvProduct;
private RecyclerView.LayoutManager layoutManager;
private ProductAdapter productAdapter;

public static ProductsFragment newInstance(Bundle args) {
    ProductsFragment fragment = new ProductsFragment();
    fragment.setArguments(args);
    return fragment;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_products, container, false);
    rvProduct = (RecyclerView) v.findViewById(R.id.rvProduct);
    rvProduct.setHasFixedSize(true);
    layoutManager = new GridLayoutManager(getContext(), 2);
    rvProduct.setLayoutManager(layoutManager);
    Bundle bundle = getArguments();
    final Shop shop = (Shop) bundle.getSerializable("shop");
    productAdapter = new ProductAdapter(getContext(), shop);
    rvProduct.setAdapter(productAdapter);
    productAdapter.notifyDataSetChanged();

    rvProduct.addOnItemTouchListener(new ProductAdapter.RecyclerTouchListener(getContext(), rvProduct, new ProductAdapter.ClickListener() {
        @Override
        public void onClick(View v, int position) {
            Intent details = new Intent(getContext(), ProductDetailsActivity.class);
            details.putExtra("product", shop.products.get(position));
            startActivity(details);
        }

        @Override
        public void onLongClick(View v, int position) {

        }
    }));
    return v;
}
}
</code></pre>

<p><strong>EDIT:</strong>
I've managed to do this, please tell me if this is right and efficient way:</p>

<pre><code>holder.tvProductTitle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(context, ProductDetailsActivity.class);
            i.putExtra("product", shop.products.get(position));
            context.startActivity(i);
        }
    });
</code></pre>