louiscad
01/11/2018, 9:31 PMinline fun View.onClick(crossinline l: (v: View) -> Unit) = setOnClickListener { l(it) }
inline fun View.onClick(noinline l: (v: View) -> Unit) = setOnClickListener(l)
The first one is optimized but doesn't gives you a proper stacktrace for the l
lambda in case you want it, if you get an exception for example.
The second one generates 2 classes instead of one, and has 3 methods calls instead of one when a click strikes, but you see it all in the stacktrace, with the exception source.
Note that the second one still produces meaningful method and class names. Just the line number is plain wrong and misleading (not hard to figure out you can't trust it).
MainActivity$onCreate$$inlined$onClick$1.onClick
w_bianrytree
01/12/2018, 10:17 AMnoinline
and change that into crossline
when you want to release?louiscad
01/12/2018, 12:01 PMdave08
01/14/2018, 3:46 AM