https://kotlinlang.org logo
#android
Title
# android
m

mg6maciej

03/16/2017, 9:17 AM
@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

deviant

03/16/2017, 9:20 AM
1. nobody put logic in xml. actually this is bad practice. and your second expression is totally valid.
1
👍 1
1
m

mg6maciej

03/16/2017, 9:21 AM
Nobody and never are strong words. If it's possible, someone will do it. 🙂
d

deviant

03/16/2017, 9:21 AM
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

stepango

03/16/2017, 9:23 AM
@mg6maciej thanks for feedback, hope to add examples and tests there soon enough👍
m

Marc

03/16/2017, 9:24 AM
another way @mg6maciej is
android:onClick="@{() -> viewModel.incCounter()}"
m

mg6maciej

03/16/2017, 9:28 AM
@Marc That's how it is in example app code. I was wondering if using
obj::method
was possible.
👍 1
e

enighma

03/16/2017, 7:52 PM
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.