title: Getting problem in OnTouch and onClick Events in my Adapter class of my Recycler View
body: <p>I was working on my app. In the main screen of my App I have a Horizontal RecyclerView which loads image and name below the image from the Firebase. I want to send the user to another activity when the user clicks on the image and I want to highlight the image also. </p>
  
  <p>My problem is I have used OnTouch method in my Adapter class to highlight the image ,  but when i do this it only highlight the image when clicked. I want to send the user to another activity and I want to highlight the image also. So for this , I used <strong>intent</strong> in my code.
  But when I use intent in my code then it successfully sends the user to another activity but the problem is after going to another activity when user clicks back then the image is still highlighted. </p>
  
  <p>So the conclusion is I am getting problem in my code I want that when user clicks image then it highlight the image and sends the user to new activity without any bug.</p>
  
  <p>Here is my code: -</p>
  
  <pre><code>public class TrendingSongsAdapter extends RecyclerView.Adapter&lt;TrendingSongsAdapter.ViewHolder&gt; {
  
      public static final String TAG = "RecyclerViewAdaper";
  //    private ArrayList&lt;String&gt; mNames = new ArrayList&lt;&gt;();
  //    private ArrayList&lt;String&gt; mImageUrls = new ArrayList&lt;&gt;();
  
      private List&lt;Upload&gt; mUploads;
  
      private OnItemListener mOnItemListener;
  
      private Context mContext;
  
      public TrendingSongsAdapter(Context context, List&lt;Upload&gt; uploads, OnItemListener onItemListener) {
  //        mNames = names ;
  //        mImageUrls = imageUrls;
          mUploads = uploads;
          mContext = context;
          this.mOnItemListener = onItemListener;
      }
  
      @NonNull
      @Override
      public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  
          View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.trending_song_items_view, parent, false);
  
  
          return new ViewHolder(view, mOnItemListener);
      }
  
      @SuppressLint("ClickableViewAccessibility")
      @Override
      public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
  
  
          Upload uploadCurrent = mUploads.get(position);
  
          holder.name.setText(uploadCurrent.getName());
  
          Glide.with(mContext)
                  .asBitmap()
                  .load(uploadCurrent.getImageUri())
                  .centerCrop()
                  .into(holder.image);
          holder.image.setOnTouchListener(new View.OnTouchListener() {
              Rect rect;
  
              @Override
              public boolean onTouch(View view, MotionEvent motionEvent) {
  
  
                  if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                      holder.image.setColorFilter(Color.argb(50, 0, 0, 0));
                      rect = new Rect(view.getLeft(), view.getRight(), view.getTop(), view.getBottom());
                  }
                  if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                      holder.image.setColorFilter(Color.argb(0, 0, 0, 0));
                  }
                  if (motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
                      if (!rect.contains(view.getLeft() + (int) motionEvent.getX(), view.getTop() + (int) motionEvent.getY())) {
                          holder.image.setColorFilter(Color.argb(0, 0, 0, 0));
                      }
                  }
  
  
  
                  Intent intent = new Intent(mContext , D.class);
                  mContext.startActivity(intent);
  
  
  
                  return false;
  
              }
  
  
  
          });
  
  
      }
  
  
      @Override
      public int getItemCount() {
          return mUploads.size();
      }
  
      public interface OnItemListener {
  
          void onItemClick(int position);
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
  
          ImageView image;
          TextView name;
  
          OnItemListener onItemListener;
  
          public ViewHolder(View itemview, OnItemListener onItemListener) {
              super(itemview);
  
              image = itemview.findViewById(R.id.image_view);
              name = itemview.findViewById(R.id.name);
              this.onItemListener = onItemListener;
  
              itemview.setOnClickListener(this);
  
          }
  
          @Override
          public void onClick(View view) {
              onItemListener.onItemClick(getAdapterPosition());
          }
      }
  
  }
  </code></pre>
  
  <p>Please help me if you have any solution.</p>
  
  <p>Thanks for reading my question.</p>