From 7dfc4ef3a1229c4af7a53d0ae3024ef09e5b318b Mon Sep 17 00:00:00 2001 From: CraZyLegenD Date: Mon, 17 Jun 2019 12:27:19 +0200 Subject: [PATCH] item click listener dsl --- .../clickListeners/forItemClickListener.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/recyclerview/clickListeners/forItemClickListener.kt b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/recyclerview/clickListeners/forItemClickListener.kt index 73f74de15..e227f8b76 100644 --- a/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/recyclerview/clickListeners/forItemClickListener.kt +++ b/kotlinextensions/src/main/java/com/crazylegend/kotlinextensions/recyclerview/clickListeners/forItemClickListener.kt @@ -8,4 +8,12 @@ import android.view.View */ interface forItemClickListener { fun forItem(position:Int, item:T, purpose:ClickPurpose, view: View) -} \ No newline at end of file +} + +fun forItemClickListenerDSL(callback: (position: Int, item: T, purpose: ClickPurpose, view: View) -> Unit = { _, _, _, _ -> }): forItemClickListener { + return object : forItemClickListener { + override fun forItem(position: Int, item: T, purpose: ClickPurpose, view: View) { + callback(position, item, purpose, view) + } + } +}