aaverin
03/28/2018, 10:02 AMtry {
val field = javaClass.getDeclaredField("mShiftingMode")
field.isAccessible = true
field.set(this, enable)
} catch (e: NoSuchFieldException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
}
I looked into kotlin-reflect, but can’t find a way to make private property publicrcgonzalezf
03/28/2018, 3:21 PMtry {
with( javaClass.getDeclaredField("mShiftingMode")){
isAccessible = true
set(this, enable)
}
} catch (e: NoSuchFieldException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
}
And if you want to hide those try catch blocks, maybe send those to another function; and pass a lambda with your field logic.rcgonzalezf
03/28/2018, 3:22 PMrcgonzalezf
03/28/2018, 3:23 PM