title: Android RecyclerView Swipe to delete with Icon only drawed on first element
body: <p>Everything works great, but one thing is not really working.
  The delete icon is only rendered on the first element of the recycler view list as you can see in the image.</p>
  
  <p><a href="https://i.stack.imgur.com/fT50o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fT50o.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/jdzqt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jdzqt.png" alt="enter image description here"></a></p>
  
  <p>Here is my code of the ItemTouchHelper class:</p>
  
  <pre><code>class ItemSwipeCallback(val context: Context) : ItemTouchHelper.Callback() {
      private val listeners = ArrayList&lt;OnItemSwipe&gt;()
  
      private val paint = Paint()
      val theme = context.themeId
      val icon = ContextCompat.getDrawable(context, R.drawable.ic_delete_filled_white_24dp)!!
  
      override fun onMove(
          recyclerView: RecyclerView,
          viewHolder: RecyclerView.ViewHolder,
          target: RecyclerView.ViewHolder): Boolean {
  
          return true
      }
  
      override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
          val direction = context.sharedPreferences.getInt(Preferences.SWIPE_DIRECTION, Preferences.SWIPE_VALUE_RIGHT)
  
          return when (direction) {
              Preferences.SWIPE_VALUE_RIGHT -&gt; makeMovementFlags(0, ItemTouchHelper.RIGHT)
              Preferences.SWIPE_VALUE_LEFT -&gt; makeMovementFlags(0, ItemTouchHelper.LEFT)
              else -&gt; makeMovementFlags(0, ItemTouchHelper.RIGHT)
          }
      }
  
      override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
          listeners.forEach { it.onSwiped(viewHolder.layoutPosition, direction) }
      }
  
      override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder,
              dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
  
          super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
  
          if (dX != 0f &amp;&amp; isCurrentlyActive) {
              val itemView = viewHolder.itemView
              paint.color = Color.parseColor("#D32F2F")
              val top = (itemView.height - icon.intrinsicHeight) / 2
              val left = itemView.width - icon.intrinsicWidth - top
  
              if (theme == Preferences.THEME_VALUE_DARK) {
                  icon.setTint(Color.BLACK)
              } else {
                  icon.setTint(Color.WHITE)
              }
  
              if (dX &lt; 0) {
                  val background = RectF(itemView.right.toFloat() + dX, itemView.top.toFloat(),
                      itemView.right.toFloat(), itemView.bottom.toFloat())
                  c.drawRect(background, paint)
                  icon.setBounds(left, top, left + icon.intrinsicWidth, top + icon.intrinsicHeight)
              } else {
                  val background = RectF(itemView.left.toFloat() + dX, itemView.top.toFloat(),
                      itemView.left.toFloat(), itemView.bottom.toFloat())
                  c.drawRect(background, paint)
                  icon.setBounds(top, top, top + icon.intrinsicWidth, top + icon.intrinsicHeight)
              }
              icon.draw(c)
          }
      }
  
      fun addOnItemSwipeListener(onItemSwipe: OnItemSwipe) {
          listeners.add(onItemSwipe)
      }
  }
  </code></pre>
  
  <p>Maybe the icon which is loaded on the head of the class is only usable once? I tried already to convert it into a Bitmap and use it. I also tried loading it in the onChildDraw function.</p>