Anvil 0.4.0 + support libraries

Previously on Anvil: version 0.1 was the
first one to use incremental rendering approach instead of virtual tree
diff’ing. Version 0.2 added support for XML layouts and binding data to
existing views. Version 0.3 was about two-way data bindings - most views got
simplified lambas for handling user input and many related bugs have been fixed.

Today’s version 0.4 takes care of support libraries.

I personally rarely use support libraries (at work we don’t target regular
consumer devices so material niceties or fragments or action bars are not used
a lot). But the urgency of bringing them to Anvil has been clear.

Thanks to Lalit Maganti who rewrote Anvil DSL
generator, it finally got the ability to produce DSL from the support classes
as well.

Here are the new build artifacts that should be added if you are going to use
support libraries with Anvil (you may only add the ones you actually need, they
are all independent):

Unlike RecyclerView, CardView is a pretty boring library, all you can do is
create a card view and control its corner radius, elevation etc:

cardView(() -> {
cardElevation(1);
radius(dip(4));
});

One potential caveat is using animated views (like switches) inside the
recycler view. You can’t modify such views during the layout phase, so if you
are calling notifyDataSetChanged on your recycler adapter from inside the
view() method - better delay the adapter change with post(). It would fix a
potential crash.

AppCompat

Due to the programming language semantics, Anvil is unable to replace regular
views with appCompat versions on-the-fly like XML inflater does. Probably it’s
for the best - explicit is often better than implicit:

appCompatButton(() -> ...);
appCompatCheckBox(() -> ...);

Design

Design library is often being used to get the floating action buttons, so
here’s an example: