cortinico / slidetoact

A simple 'Slide to Unlock' Material widget for Android, written in Kotlin 📱🎨🦄
MIT License
1.2k stars 165 forks source link

SlideToActView app:slider_icon doesn't accept databinding #156

Open MohamedHashim opened 3 years ago

MohamedHashim commented 3 years ago

What kind of issue is this?

Cannot find a setter for that accepts parameter type 'android.graphics.drawable.Drawable' If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.

Details

<com.ncorti.slidetoact.SlideToActView android:layout_width="wrap_content" android:layout_height="wrap_content" app:outer_color="@color/azul_two" app:rotate_icon="false" app:slider_height="44dp" app:slider_icon="@{modelView.checkinType == true? @drawable/ic_check_in: @drawable/ic_check_out}" app:slider_icon_color="@color/black" />

cortinico commented 3 years ago

Thanks for the report

Cannot find a setter for that accepts parameter type 'android.graphics.drawable.Drawable' If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.

That's indeed true. The setter for slider_icon is of type Int and not Drawable:

https://github.com/cortinico/slidetoact/blob/0e2ca7da2e115140747afe457bf78f65a6bb689d/slidetoact/src/main/java/com/ncorti/slidetoact/SlideToActView.kt#L151-L163

I'm unsure what would be the best approach to offer better support for Databinding here. Perhaps we need another setter of type Drawable.

Happy to review a PR if someone has the time to look into this 👍

MohamedHashim commented 3 years ago

Thank you for your response, I'll try to look into this if I have some free time.