animateVisibleIfNull

fun View.animateVisibleIfNull(instance: Any?, enterAnimation: Animation?, exitAnimation: Animation?)

Starts animations based on the View visibility. The visibility is based on whether the instance is null.

For this to work, both enterAnimation and exitAnimation must be specified.

If the instance is null, the visibility is set to View.VISIBLE and the enterAnimation is started. If the instance is not null, the exitAnimation is started and the visibility is set to View.GONE.

No animations are started if the values are set for the very first time.

Example usage:

<View
auto:visibleIfNull="@{viewModel.instance}"
auto:enterAnimation="@{@anim/tt_enter_slideup}"
auto:exitAnimation="@{@anim/tt_exit_slidedown}" />