Chivorns / SmartMaterialSpinner

The powerful android spinner library for your application
https://github.com/Chivorns/SmartMaterialSpinner
Other
333 stars 56 forks source link

IndexOutOfBoundsExceptions when calling SmartMaterialSpinner#setSelection method #24

Closed mochadwi closed 3 years ago

mochadwi commented 4 years ago

I'm curious about this line of code (highlighted)

Screen Shot 2020-05-08 at 9 44 05 AM

and see the implementation of hint will never be null, because you were always using "" a blanks/empty strings.

Screen Shot 2020-05-08 at 9 42 51 AM

both in setter line 1106 and 256

thus the code: SmartMaterialSpinner.super.setSelection(hint != null ? finalPosition + 1 : finalPosition, false);

will always having a finalPosition + 1 means the index/position == item.size, IndexOutOfBoundsExceptions occurred

IMHO the rest of the nullability check will having a false-positive instead

cmiiw

Chivorns commented 4 years ago

Hi @mochadwi , thank for your feedback. I will check on it soon if it the root cause of that issue. Currently I'm a bit busy with company projects so cannot support you for now. Please stay tune. Thank

mochadwi commented 4 years ago

If it's okay, I might open a PR for it @Chivorns

Chivorns commented 4 years ago

Okay @mochadwi . Much appreciate.