https://kotlinlang.org logo
#android
Title
# android
r

radzio

01/10/2018, 8:35 PM
Hi everyone! I want to use Kotlin extension function to remove
if(Build.VERSION.SDK_INT)
from my code. I've created this:
Copy code
inline fun <T> T.applyForOreoOrAbove(block: T.() -> Unit): T {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    block()
  }
  return this
}
Unfortunately, Android Lint still complains that call requires... Is it a bug in the Lint or am I doing something wrong?
Effect:

https://i.imgur.com/Ts3EGv7.png

l

louiscad

01/10/2018, 8:37 PM
Lint check for API level is not smart enough yet. Please, suggest an improvement on b.android.com
j

jw

01/10/2018, 8:42 PM
Use 3.1 alpha 5 or newer
r

radzio

01/10/2018, 9:12 PM
I've tested it with AS 3.1 alpha 7 with same result 😞
j

jw

01/10/2018, 9:16 PM
r

radzio

01/10/2018, 9:17 PM
Sure thing! Thanks for help!