title: ViewCompat.setOnApplyWindowInsetsListener don't take affect when it take view as atribute
body: <p>I try to handle insets by setting <code>ViewCompat.setOnApplyWindowInsetsListener</code> on attached view, but listener is not called.</p>
  <p>I'm confused, because when i apply insets listener to <code>decorView</code>, it works:</p>
  <pre><code>   ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { v, insets  -&gt;
          Toast.makeText(this, &quot;INSETS HANDLED&quot;, Toast.LENGTH_LONG).show()
          insets
      }
  </code></pre>
  <p>But when i apply insets listener to activity root view (i do it in same place), it's not working:</p>
  <pre><code>ViewCompat.setOnApplyWindowInsetsListener(main_root) { v, insets  -&gt;
          Toast.makeText(this, &quot;INSETS HANDLED&quot;, Toast.LENGTH_LONG).show()
          insets
      }
  </code></pre>
  <p>I have a single activity app, and i set both this listeners when <code>onCreate()</code> method called.</p>
  <p>I know i can get insets from first example and cache them, but now i need second code works, because i need this library works:</p>
  <p><a href="https://github.com/chrisbanes/insetter" rel="nofollow noreferrer">https://github.com/chrisbanes/insetter</a></p>
  <p>It's have api like:</p>
  <pre><code>    Insetter.builder()
          .applySystemWindowInsetsToPadding(Side.LEFT)
          .applyToView(main_bottom_nav)
  </code></pre>
  <p>It provide easy way to apply insets to your views. But it did't work.</p>
  <p>I debug it and i saw that under the hood this library set listener to view like i try to do in a second code example, so when i get the reason why my listeners are not trigger, i think i can make this library work.</p>
  <p>My minds are:</p>
  <p>I don't rly understand what's happening. It's very strange for me that decorView has insets, but activity root is not. By logic, it's possible only when someone between decorView and activity view handle and consume insets, but is sounds strange: activity root view must to know about insets.</p>
  <p>What i tried to do(see code), and it's not help:</p>
  <ul>
  <li>Change root ViewGroup from ConstraintLayout ro Frame/Linear/RelativeLayout.</li>
  <li>Add/remove <code>fitsSystemWindows</code> attribute to activity root ViewGroup. In fact i planning to remove insets at all to make a fullscreen application, so i don't think i need this flag enabled.</li>
  <li>Change windowSoftInputMode of activity: it's adjustResize now.</li>
  <li>Call <code>requestApplyInsets()</code> on target view before and after listener applied.</li>
  <li>Downgrade androidx.core:core-ktx and androidx.activity:activity-ktx to stable versions.</li>
  </ul>
  <p>Code:</p>
  <p>activity.xml:
  <a href="https://github.com/KirstenLy/AdviceCollector/blob/master/app/src/main/res/layout/activity_main.xml" rel="nofollow noreferrer">https://github.com/KirstenLy/AdviceCollector/blob/master/app/src/main/res/layout/activity_main.xml</a></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout 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;
      android:id=&quot;@+id/main_root&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:background=&quot;@color/color_main_content&quot;&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/main_icon&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:src=&quot;@drawable/wise&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
          android:id=&quot;@+id/main_bottom_nav&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:background=&quot;@color/color_main_content&quot;
          android:elevation=&quot;@dimen/elevation_4&quot;
          android:translationZ=&quot;@dimen/elevation_4&quot;
          android:visibility=&quot;gone&quot;
          app:labelVisibilityMode=&quot;unlabeled&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:menu=&quot;@menu/bottom_navigation_menu&quot; /&gt;
  
      &lt;!-- Helper view to show snackBar: need because of transparent navigation bar --&gt;
      &lt;View
          android:id=&quot;@+id/main_snackbar_anchor&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
      &lt;!-- No internet error section --&gt;
      &lt;ImageView
          android:id=&quot;@+id/main_error_internet_icon&quot;
          android:layout_width=&quot;@dimen/image_size_96&quot;
          android:layout_height=&quot;@dimen/image_size_96&quot;
          app:layout_constraintBottom_toTopOf=&quot;@+id/main_error_internet_text&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_chainStyle=&quot;packed&quot;
          app:srcCompat=&quot;@drawable/ic_wifi&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/main_error_internet_text&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:ellipsize=&quot;end&quot;
          android:gravity=&quot;center&quot;
          android:lines=&quot;3&quot;
          android:padding=&quot;@dimen/padding_16&quot;
          android:textAlignment=&quot;center&quot;
          app:layout_constraintBottom_toTopOf=&quot;@+id/main_error_internet_retry_button&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/main_error_internet_icon&quot;
          tools:text=&quot;@string/main_activity_error_loading&quot; /&gt;
  
      &lt;com.google.android.material.button.MaterialButton
          android:id=&quot;@+id/main_error_internet_retry_button&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:backgroundTint=&quot;@color/dark_blue&quot;
          android:padding=&quot;@dimen/padding_16&quot;
          android:text=&quot;@string/default_retry&quot;
          app:icon=&quot;@drawable/ic_autorenew&quot;
          app:iconGravity=&quot;textEnd&quot;
          app:iconPadding=&quot;@dimen/padding_4&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/main_error_internet_text&quot; /&gt;
  
      &lt;androidx.constraintlayout.widget.Group
          android:id=&quot;@+id/main_error_group&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:constraint_referenced_ids=&quot;main_error_internet_icon,main_error_internet_retry_button,main_error_internet_text&quot; /&gt;
  
      &lt;FrameLayout
          android:id=&quot;@+id/main_container&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;0dp&quot;
          app:layout_constraintBottom_toTopOf=&quot;@+id/main_bottom_nav&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>MainActivity.kt:
  <a href="https://github.com/KirstenLy/AdviceCollector/blob/master/app/src/main/java/com/kirstenly/advice_collector/ui/activity_main/MainActivity.kt" rel="nofollow noreferrer">https://github.com/KirstenLy/AdviceCollector/blob/master/app/src/main/java/com/kirstenly/advice_collector/ui/activity_main/MainActivity.kt</a></p>
  <pre><code>package com.kirstenly.advice_collector.ui.activity_main
  
  import android.os.Bundle
  import android.widget.Toast
  import androidx.core.view.ViewCompat
  import androidx.core.view.isGone
  import androidx.core.view.isVisible
  import com.google.android.play.core.review.ReviewManagerFactory
  import com.kirstenly.advice_collector.R
  import com.kirstenly.advice_collector.Screens
  import com.kirstenly.advice_collector.contracts.NavigationEventConsumer
  import com.kirstenly.advice_collector.other.helpers.DayNightThemeHelper
  import com.kirstenly.advice_collector.other.helpers.InsetHelper
  import com.kirstenly.advice_collector.ui.activity_main.router.MainActivityRouter
  import com.kirstenly.sdk.extensions.*
  import com.kirstenly.sdk.other.navigation.BaseScreen
  import dagger.android.support.DaggerAppCompatActivity
  import kotlinx.android.synthetic.main.activity_main.*
  import javax.inject.Inject
  
  /** Host activity for application */
  class MainActivity : DaggerAppCompatActivity(R.layout.activity_main), NavigationEventConsumer {
  
      @Inject lateinit var router: MainActivityRouter
      @Inject lateinit var viewModel: MainActivityViewModel
      @Inject lateinit var insetHelper: InsetHelper
      @Inject lateinit var dayNightThemeHelper: DayNightThemeHelper
  
      override fun onNavigationEvent(screen: BaseScreen) {
          router.navigateTo(screen)
      }
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setTheme(R.style.AppTheme)
          initViews()
          initObservers()
      }
  
      private fun initViews() {
  
          ViewCompat.setOnApplyWindowInsetsListener(window.decorView){ v, insets  -&gt;
              Toast.makeText(this, &quot;INSETS HANDLED&quot;, Toast.LENGTH_LONG).show()
              insets
          }
          
  //        main_bottom_nav.applySystemWindowInsetsToMargin(bottom = true, top = true, left = true, consume = true)
  
  //        root_root.requestApplyInsetsWhenAttached()
  //        Insetter.builder()
  //            .applySystemWindowInsetsToPadding(Side.LEFT)
  //            .applyToView(main_bottom_nav)
  //
  //        setWindowTransparency { statusBarSize, navigationBarSize -&gt;
  //            insetHelper.topInset = statusBarSize
  //            insetHelper.bottomInset = navigationBarSize
  //            main_bottom_nav.updatePaddingFromPx(bottom = navigationBarSize)
  //            main_snackbar_anchor.layoutParams.height = navigationBarSize
  //        }
  
          with(main_bottom_nav) {
              setOnNavigationItemSelectedListener {
                  when (it.itemId) {
                      R.id.bottom_home -&gt; router.navigateTo(Screens.HomeScreen)
                      R.id.bottom_favorite -&gt; router.navigateTo(Screens.FavoriteAdvicesScreen)
                      R.id.bottom_login -&gt; router.navigateToLoginOrUserAdvices()
                      R.id.bottom_new_advice -&gt; router.navigateToNewAdvice()
                      R.id.bottom_day_night -&gt; dayNightThemeHelper.setDayOrNightMode()
                  }
                  true
              }
  
              removeItemIconTintList()
              setIconOnItem(R.id.bottom_day_night, dayNightThemeHelper.getDayOrNightModeIcon())
          }
  
          main_error_internet_retry_button.setOnClickListener {
              viewModel.retryInternetConnection()
          }
      }
  
      private fun initObservers() {
          viewModel.errorStateLiveData.observe(this, { errorState -&gt;
              main_error_group.isVisible = errorState != ErrorState.NONE
              main_icon.isVisible = errorState == ErrorState.NONE
              main_error_internet_retry_button.isEnabled = errorState != ErrorState.RETRYING
  
              val errorText = when (errorState) {
                  ErrorState.RETRYING -&gt; getString(R.string.main_activity_error_retrying)
                  ErrorState.NO_INTERNET_ERROR -&gt; getString(R.string.main_activity_error_loading)
                  ErrorState.UPDATE_DATA_ERROR -&gt; getString(R.string.main_activity_error_update)
                  ErrorState.NONE -&gt; null
              }
  
              main_error_internet_text.text = errorText
          })
  
          viewModel.navigationEventLiveData.observe(this, router::navigateTo)
  
          viewModel.isDataPreparedLiveData.observe(this, { isDataPrepared -&gt;
              main_icon.isGone = isDataPrepared
          })
      }
  
      // TODO: Поддержать inAppReview, будет возможно только после залива в GP
      private fun initAppReview() {
          val manager = ReviewManagerFactory.create(this)
          val request = manager.requestReviewFlow()
          request.addOnCompleteListener { request -&gt;
              if (request.isSuccessful) {
                  // We got the ReviewInfo object
                  val reviewInfo = request.result
                  val flow = manager.launchReviewFlow(this, reviewInfo)
                  flow.addOnCompleteListener { a -&gt;
                      a.isComplete
                      // The flow has finished. The API does not indicate whether the user
                      // reviewed or not, or even whether the review dialog was shown. Thus, no
                      // matter the result, we continue our app flow.
                  }
              } else {
                  // There was some problem, continue regardless of the result.
              }
          }
      }
  
      override fun onBackPressed() {
          if (!router.handleOnBackPressedByCurrentFragment()) {
              if (!supportFragmentManager.isBackStackEmpty()) {
                  super.onBackPressed()
              } else {
                  finish()
              }
          }
      }
  }
  </code></pre>