Avoid crash in TransferDetailsAdapter.

- This is the adapter that populates the list of transactions in the TransactionsFragment, the crash was happening when the user tapped two or more items in the list at the same time. When that happens only the first item tapped opens its corresponding eReceipt correctly but the remaining ones throw an excpeption which was not being handled correctly and causing a crash.
This commit is contained in:
Severiano Jaramillo 2019-08-21 14:40:38 -05:00
parent 39a3e6b7d4
commit 6482b31971

View file

@ -1,6 +1,7 @@
package cy.agorise.bitsybitshareswallet.adapters
import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -158,7 +159,14 @@ class TransfersDetailsAdapter(private val context: Context) :
// Open the eReceipt when a transaction is tapped
viewHolder.rootView.setOnClickListener { v ->
val action = TransactionsFragmentDirections.eReceiptAction(transferDetail.id)
try {
v.findNavController().navigate(action)
} catch (ignored: IllegalArgumentException) {
// This exception is being ignored because it happens when a user taps two or
// more items on the list at the same time, only the first navigates correctly and
// the remaining produce an exception.
Log.d("TransfersDetailsAdapter", "Ignoring IllegalArgumentException")
}
}
}