From 67b0f84994db1012f6ff7934ef058cc68cbea1e9 Mon Sep 17 00:00:00 2001 From: m1ga Date: Mon, 25 Sep 2023 23:15:56 +0200 Subject: [PATCH] fix(android): findStateDrawableIndex reflection method --- .../src/java/org/appcelerator/titanium/util/TiUIHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java b/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java index efd98b92ce1..62ab37eb3dc 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java +++ b/android/titanium/src/java/org/appcelerator/titanium/util/TiUIHelper.java @@ -1256,8 +1256,12 @@ public static String getBackgroundColorForState(TiBackgroundDrawable backgroundD // Get the backgroundDrawable background as a StateListDrawable. StateListDrawable stateListDrawable = (StateListDrawable) simpleDrawable; // Get the reflection methods. + String methodName = "getStateDrawableIndex"; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + methodName = "findStateDrawableIndex"; + } Method getStateDrawableIndexMethod = - StateListDrawable.class.getMethod("getStateDrawableIndex", int[].class); + StateListDrawable.class.getMethod(methodName, int[].class); Method getStateDrawableMethod = StateListDrawable.class.getMethod("getStateDrawable", int.class); // Get the disabled state's (as defined in TiUIHelper) index. int index = (int) getStateDrawableIndexMethod.invoke(stateListDrawable, state);