title: How to Stop Swiping the item in Recycler view after reaching some distance
body: <p>I have a Recycler View in android. I have attached an <code>ItemTouchHelper</code> to it.I have enabled only swiping from left to right.</p>
  
  <p>So when i swipe any item of Recycler view , the item starts moving towards right and on the left i draw a text. 
  This is fine . 
  My requirement is that, I want allow user to swipe only to some distance , and when that distance is reached and user release the touch, the item being swiped should go back to its position towards left.</p>
  
  <p>Problem is that , when i swipe left to right the view gets fully swiped out of the screen . How can i restrict it to be swiped only to some distance ?
  How do i do it ?</p>
  
  <p>Here is my code for the item touch callback:</p>
  
  <pre><code>private void initSwipe(){
      ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
              @Override
              public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                  return false;
              }
  
              @Override
              public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                  int position = viewHolder.getAdapterPosition();
              }
  
          @Override
          public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
              ViewHolder viewHolder1 = (ViewHolder)viewHolder;
              int position = viewHolder1.getAdapterPosition();
              MyItem item = dataList.get(position);
              if (item==null )return;
              if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE){
  
                  View itemView = viewHolder.itemView;
                  float height = (float) itemView.getBottom() - (float) itemView.getTop();
                  float width = height / 3;
                  Paint p = new Paint();
                  Paint textPaint = new Paint();
                  textPaint.setColor(Color.WHITE);
                  textPaint.setTextSize(20);
  
                  if(dX &gt; 0) {
                      p.setColor(Color.parseColor("#000000"));
                      RectF background = new RectF((float) itemView.getLeft(), (float) itemView.getTop(), dX,(float) itemView.getBottom());
                      c.drawRect(background,p);
                      //RectF icon_dest = new RectF((float) itemView.getLeft() + width ,(float) itemView.getTop() + width,(float) itemView.getLeft()+ 2*width,(float)itemView.getBottom() - width);
                      //c.drawBitmap(icon,null,icon_dest,p);
                      c.drawText(item.getDate(),(float)(itemView.getLeft() + width),(float)(itemView.getBottom() - width), textPaint);
                  }
              }
              super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
          }
      };
      ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
      itemTouchHelper.attachToRecyclerView(myRecycler);
  }`
  </code></pre>