From 259d4531172c6be74b3a5260e71846959563945c Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 24 Jun 2019 11:15:33 +0200 Subject: [PATCH] Improve code --- .../android/ui/view/ContextMenuRecyclerView.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/view/ContextMenuRecyclerView.kt b/app/src/main/java/net/pokeranalytics/android/ui/view/ContextMenuRecyclerView.kt index f64fda66..a473357d 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/view/ContextMenuRecyclerView.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/view/ContextMenuRecyclerView.kt @@ -20,9 +20,11 @@ class ContextMenuRecyclerView : RecyclerView { } override fun showContextMenuForChild(originalView: View): Boolean { + val longPressPosition = getChildAdapterPosition(originalView) - if (longPressPosition >= 0) { - val longPressId = adapter!!.getItemId(longPressPosition) + val longPressId = adapter?.getItemId(longPressPosition) + + if (longPressPosition >= 0 && longPressId != null) { mContextMenuInfo = RecyclerViewContextMenuInfo(longPressPosition, longPressId) return super.showContextMenuForChild(originalView) }