Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): findStateDrawableIndex reflection method #13920

Merged
merged 2 commits into from
Nov 23, 2024

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Sep 25, 2023

Issue
When trying to read the backgroundColor when you only have a backgroundImage it will show this error:

TiUIHelper: (main) [0,184643] java.lang.NoSuchMethodException: android.graphics.drawable.StateListDrawable.getStateDrawableIndex [class [I]

findStateDrawableIndex is available since Android 29:
https://developer.android.com/reference/android/graphics/drawable/StateListDrawable#findStateDrawableIndex(int[])
getStateDrawableIndex is not in the list anymore.

Test:
I don't have the real app test case but this will trigger it too:

var win = Ti.UI.createWindow({});
var view = Ti.UI.createView({
	backgroundImage: "/images/appicon.png"
});
win.add(view);
console.log(view.backgroundColor)
win.open();

Note:
It will still show [WARN] TiUIHelper: (main) [649,649] Background drawable of unexpected type. Expected - ColorDrawable. Found - class android.graphics.drawable.BitmapDrawable but that is a warning from the SDK itself and expected since we don't have a color, just an image.

@m1ga m1ga marked this pull request as ready for review October 19, 2024 14:25
@m1ga m1ga added the android label Oct 19, 2024
@hansemannn hansemannn merged commit 4364a7c into master Nov 23, 2024
6 checks passed
@hansemannn hansemannn deleted the 230925_tiuihelper branch November 23, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants