title: How to get position of last clicked item in recycler view on focus changed in Kotlin
body: <p>I have an issue, I need to get last clicked item position on focus change in recycler view in Kotlin.</p>
  <p>For example: If my Recycler view contains 4 Edit text items. I entered a value on 2nd position. when i am clicking on last position, i need to get the position of 2nd Item. But the issue now is, when i am clicking on last position, which is 4th, i am getting that position on focus change only. Please find the below code of mine.</p>
  <pre><code>
            itemBinding.root.itemCount.setOnFocusChangeListener { view, hasfocus -&gt;
                  if (hasfocus) {
                      if (hasfocus &amp;&amp; isTouched &amp;&amp; (selectedPosition != position)) {
                          isTouched = false
                          itemBinding.scan.performClick()
                      }
                  }
                  if(!ignoreUpdate &amp;&amp; isFrom == &quot;countScreen&quot;) {
                      updateCountItem(itemResponse, selectedPosition, false)
                  }
              }
      
      
                  itemBinding.root.itemCount.setOnTouchListener { view, motionEvent -&gt;
                      mRecyclerView!!.post {
                          selectedPosition = adapterPosition
                          listener.onFocusChange(layoutPosition, &quot;countScreen&quot;)
                      }
                      false
                  }
      
      
      private fun updateCountItem(itemResponse: ScanItemModel, position: Int, isCount: Boolean) {
          ignoreUpdate = true
          selectedPosition = position
          itemBinding.root.itemCount.selectAll()
          isTouched = true
      
          if (!itemDetailBinding.root.itemCount.text.toString().equals(&quot;&quot;)) {
              var a = 0
              var b = 0
              if (itemBinding.itemCount.text.toString().equals(&quot;&quot;)) {
                  a = 0
              } else {
                  a = itemBinding.itemCount.text.toString().toInt()
              }
              if (itemResponse.total != null) {
                  if (itemResponse.total!! &gt;= 0) {
                      b = itemResponse.total!!
                  } else {
                      b = 0
                  }
              }
              val sum = a.plus(b)
              if (sum &lt; 3) {
                  if (itemResponse.total != null) {
                      itemResponse.total = sum
                  } else {
                      itemResponse.total = sum
                  }
      
                  itemBinding.root.totalCount.setText(itemResponse.total.toString())
                  isOnBind = true
                  listener.quantityChanged(
                      position,
                      itemResponse
                  )
                  isOnBind = false
      
                  itemBinding.root.itemCount.text.clear()
                  ignoreUpdate = false
              } else {
                  if (itemResponse.total != null) {
                      itemResponse.total = sum
                  } else {
                      itemResponse.total = sum
                  }
      
                  itemBinding.root.itemCount.setText(scanItemResponse.total.toString())
                  isOnBind = true
                  listener.countQuantityChanged(
                      position,
                      itemResponse
                  )
                  isOnBind = false
      
                  itemBinding.root.itemCount.text.clear()
                  ignoreUpdate = false
              }
          } else {
              ignoreUpdate = false
          }
      }
  
  </code></pre>
  <p>Kindly help me on this. Any help would be deeply appreciated. Thanks and Regards in advance. :) :)</p>