However the call-site still gives a lint warning "This typed array should be recycled after use with #recycle()". Is there anything I could do besides adding
@SuppressLint("Recycle")
everywhere?
Cody Engel
04/16/2020, 5:30 PM
May go with something like this for now 🤷🏻♂️
Copy code
@SuppressLint("Recycle")
fun Context.parseStyledAttributes(
attributeSet: AttributeSet?,
attributes: IntArray,
parser: (typedArray: TypedArray) -> Unit
) {
obtainStyledAttributes(attributeSet, attributes).parseStyledAttributes(parser)
}
a
Alex Vanyo
04/16/2020, 5:33 PM
Another option could be making use of `core-ktx`’s
TypedArray.use
extension
🙇🏻♂️ 1
c
Cody Engel
04/16/2020, 5:59 PM
🤔 actually
use
doesn't appear to remove the lint warning.
j
jw
04/16/2020, 6:09 PM
File a bug on lint
c
Cody Engel
04/16/2020, 6:13 PM
😬 if I must. Actually,
Context
has
withStyledAttributes
which calls recycle as a part of core ktx. I'm just going to stop trying to reinvent extension functions that already exist 🤦🏻
a
Alex Vanyo
04/16/2020, 7:09 PM
I had some issues with the
"Recycle"
warning in the past, but those seem to have been resolved recently with Android Studio 4.0 and the 4.0.0 Gradle plugin.
Maybe it was fixed from this?
https://issuetracker.google.com/issues/140344435