title: How to handle multiple layout clicks in recyclerView in Android
body: <p>In our app we have list of messages. We are switching to <code>RecyclerView</code>.
  Our messages can consist from texts, images. 
  Sample message can look like this.
  <img src="https://i.stack.imgur.com/MghzL.png" alt="enter image description here"></p>
  
  <p>To handle clicks use this class:</p>
  
  <pre><code>public class RecyclerViewItemClickListener implement  RecyclerView.OnItemTouchListener {
  
      public static interface OnItemClickListener {
          public void onItemClick(View view, int position);
          public void onItemLongClick(View view, int position);
      }
  
      private OnItemClickListener mListener;
      private GestureDetector mGestureDetector;
  
      public RecyclerViewItemClickListener(Context context, final RecyclerView recyclerView, OnItemClickListener listener) {
          mListener = listener;
          mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
              @Override
              public boolean onSingleTapUp(MotionEvent e) {
                  return true;
              }
  
              @Override
              public void onLongPress(MotionEvent e)
              {
                  View childView = recyclerView.findChildViewUnder(e.getX(), e.getY());
                  if(childView != null &amp;&amp; mListener != null)
                  {
                      mListener.onItemLongClick(childView, recyclerView.getChildAdapterPosition(childView));
                  }
              }
          });
      }
  
      @Override
      public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
          View childView = view.findChildViewUnder(e.getX(), e.getY());
          if (childView != null &amp;&amp; mListener != null &amp;&amp; mGestureDetector.onTouchEvent(e)) {
              mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
          }
          return false;
      }
  
      @Override
      public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
      }
  }
  </code></pre>
  
  <p>and we implement this clicks in activity like this:</p>
  
  <pre><code>chatView.setLongClickable(true);
          chatView.addOnItemTouchListener(
                  new RecyclerViewItemClickListener(this, chatView, new RecyclerViewItemClickListener.OnItemClickListener() {
                      @Override public void onItemClick(View view, int position) {
  
                          //handleSingleClick(view, position);
  
                      }
                      @Override
                      public void onItemLongClick(View view, int position)
                      {
                          handleLongPress(position);
                      }
                  })
          );
  </code></pre>
  
  <p>Clicks for message is working, now I want also handle <code>userAvatar</code> clicks from same <code>GestureDetection</code>. Is it possible to detect which list item layout was clicked from <code>GestureDetector</code>?</p>
  
  <p>In other words, can I get <code>GestureDetecter</code> clicked child. In my case click is set to whole item(avatar, text message, image). Can I detect which element inside this item was clicked(for example I want catch avatar click).</p>