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

arekolek

02/14/2019, 11:43 AM
Is there anything you can do to disable this false positive lint check when using
use
from KTX, but still have it if you actually don’t recycle the
TypedArray
? (Not this instance of course, but any future instances)
g

gildor

02/14/2019, 1:23 PM
Just suppress and report an issue in Android issue tracker
a

arekolek

02/14/2019, 1:43 PM
(Not this instance of course, but any future instances)
It will take some time before they fix it
So I’m wondering if I can have my cake and eat it too
l

leosan

02/14/2019, 1:45 PM
using `use`is different from the extension
withStyledAttributes
?
a

arekolek

02/14/2019, 1:47 PM
I didn’t know about that one, thanks 👍
1
@leosan Although there is a small difference, with
use
you can return a value, which can be useful sometimes
Copy code
private val foo: Boolean

init {
    foo = context.obtainStyledAttributes()
        .use {
            // do some stuff with it
            it.getBoolean()
        }
}
By the way, there’s already an issue reported https://issuetracker.google.com/issues/79905342
1