<@U0BRPBCKT> 1) I never used databinding, cause I ...
# android
m
@stepango 1) I never used databinding, cause I don't like to put presentation logic in XML (e.g.
viewModel.counter > 0 ? View.VISIBLE : View.GONE
), but is it not possible to do
android:onClick="@{viewModel::incCounter}"
? (not library related) 2) Would be nice to see an example app also implemented without using your lib to see what problems it solves. I don't like using libs just to use libs, when for example the amount of code stays the same or almost the same, just looks different. 3) Add real tests in lib module. Remove example tests from both modules. I like to first read executable documentation.
d
1. nobody put logic in xml. actually this is bad practice. and your second expression is totally valid.
1
👍 1
1
m
Nobody and never are strong words. If it's possible, someone will do it. 🙂
d
better to write custom binding adapter for such thing
Copy code
@BindingAdapter("visible")
    public static void setVisible(View view, Boolean visible) {
        view.setVisibility(visible == null || visible ? View.VISIBLE : View.GONE);
    }
👍 2
1
If it's possible, someone will do it
sure. we have a lot of ways to shoot own leg
s
@mg6maciej thanks for feedback, hope to add examples and tests there soon enough👍
m
another way @mg6maciej is
android:onClick="@{() -> viewModel.incCounter()}"
m
@Marc That's how it is in example app code. I was wondering if using
obj::method
was possible.
👍 1
e
I think view logic should be in the view and the view in android is the xml file
So yo show/hide something in xml is pretty standard for similar MVVM systems and makes sense once you’re used to it.