Check for field type before attempting to read
This commit is contained in:
@@ -12,7 +12,7 @@ class ConstantLookup(private val prefix: String, private val lookup29: Array<out
|
||||
private val lookup by lazy {
|
||||
SparseArrayCompat<String>().apply {
|
||||
for (field in clazz().declaredFields) try {
|
||||
if (field.name.startsWith(prefix)) put(field.getInt(null), field.name)
|
||||
if (field.type == Int::class.java && field.name.startsWith(prefix)) put(field.getInt(null), field.name)
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e)
|
||||
}
|
||||
@@ -40,7 +40,7 @@ inline fun <reified T> ConstantLookup(prefix: String, vararg lookup29: String?)
|
||||
class LongConstantLookup(private val clazz: Class<*>, private val prefix: String) {
|
||||
private val lookup = LongSparseArray<String>().apply {
|
||||
for (field in clazz.declaredFields) try {
|
||||
if (field.name.startsWith(prefix)) put(field.getLong(null), field.name)
|
||||
if (field.type == Long::class.java && field.name.startsWith(prefix)) put(field.getLong(null), field.name)
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user