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

Crash on setting text via DSL.text(CharSequence) #117

Open
dant3 opened this issue Jun 16, 2017 · 0 comments
Open

Crash on setting text via DSL.text(CharSequence) #117

dant3 opened this issue Jun 16, 2017 · 0 comments

Comments

@dant3
Copy link

dant3 commented Jun 16, 2017

Hi. I'm trying to change the text in my view via DSL.text(CharSequence). Sometimes text can be null, which seems to be incorrectly handled by library:

 java.lang.IllegalArgumentException: method android.widget.TextView.setText argument 1 has type int, got null
  at java.lang.reflect.Method.invoke(Native Method)
  at trikita.anvil.PropertySetter.set(PropertySetter.java:106)
  at trikita.anvil.Anvil$Mount$Iterator.attr(Anvil.java:331)
  at trikita.anvil.BaseDSL.attr(BaseDSL.java:105)
  at trikita.anvil.DSL.text(DSL.java:2141)

Crash happens around:

                        if (value == null || assignable(arg, value.getClass())) {
                            m.invoke(v, value);
                            return true;
                        }

Clearly it happens because value is null and chosen method has signature for int, which is not checked.
I assume value type should be passed to PropertySetter.set explicitly to handle this issue gracefully.

Existing workaround is to set text to empty string instead of null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant