title: Android: How to bind ProgressBar visibility via DataBinding?
body: <p>I've tried a lot, honestly, but without success.</p>
  <p>I have a <code>HomeViewModel</code> and some data in constructor:</p>
  <pre class="lang-kotlin prettyprint-override"><code>class HomeViewModel(
      val userName: MutableLiveData&lt;String&gt; = MutableLiveData(),
      val userAvatar: MutableLiveData&lt;String&gt; = MutableLiveData(),
      // ...
      val showProgressBarUserInfo: MutableLiveData&lt;Boolean&gt; = MutableLiveData()
  ) : BaseViewModel() {
  </code></pre>
  <p>and function <code>saveUserInfo()</code> in HomeViewModel</p>
  <pre class="lang-kotlin prettyprint-override"><code>private fun saveUserInfo(user: User) {
      showProgressBarUserInfo.value = true
      getSomeOtherData()
      showProgressBarUserInfo.value = false
  }
  </code></pre>
  <p>where function <code>getSomeOtherData()</code> also loads username and avatar, which are also binded</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
  
      &lt;data&gt;
          &lt;import type=&quot;android.view.View&quot; /&gt;
          &lt;variable
              name=&quot;vm&quot;
              type=&quot;/path/to/HomeViewModel&quot; /&gt;
      &lt;/data&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;ProgressBar
              // ...
              android:visibility=&quot;@{vm.showProgressBarUserInfo ? View.VISIBLE : View.GONE}&quot; /&gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  &lt;/layout&gt;
  </code></pre>
  <p>Also I've tried to create a function <code>setVisibleOrGone()</code> (extension or not)</p>
  <pre class="lang-kotlin prettyprint-override"><code>fun View.setVisibleOrGone(bool: Boolean) {
      if (bool) {
          this.visibility = View.VISIBLE
      } else {
          this.visibility = View.GONE
      }
  }
  </code></pre>
  <p>with @BindingAdapter(&quot;showOrHide&quot;) annotation and use it like</p>
  <pre class="lang-xml prettyprint-override"><code>showOrHide=&quot;@{vm.showProgressBarUserInfo}&quot;
  </code></pre>
  <p>but all of the above does not work.</p>
  <p><strong>P.S.</strong> data for username and avatar bind successfully, but progress bar is not showing.</p>
  <p><strong>P.S.S.</strong> Toolbar title and ImageView:</p>
  <pre class="lang-xml prettyprint-override"><code>app:title=&quot;@{vm.userName}&quot;
  loadAvatar=&quot;@{vm.userAvatar}&quot;
  </code></pre>
  <p>where <code>loadAvatar</code> is extension function</p>
  <p>Please, help me</p>