title: Right way to get insets
body: <p>I have an <code>Activity</code> with a <code>RecyclerView</code> in a data binding layout. RecyclerView takes up the whole screen, and looking at making the UX go full screen, drawn under the status and nav bars.</p>
  
  <p>I'm calling <code>setSystemUiVisibility</code> in activity's <code>onCreate</code> as below.</p>
  
  <pre><code>window.decorView.setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_LAYOUT_STABLE
              or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
          )
  </code></pre>
  
  <p>Now the <code>RecyclerView</code> is drawn under the system bars, so I want to make sure it has enough padding so the items don't overlap with the system UI.</p>
  
  <p>I found 2 ways of doing this, via a <code>BindingAdapter</code>.</p>
  
  <p><strong>Option 1</strong></p>
  
  <pre><code>    var  statusBar = 0
      var resourceId = view.resources.getIdentifier("status_bar_height", "dimen", "android")
      if (resourceId &gt; 0) {
          statusBar = view.resources.getDimensionPixelSize(resourceId)
      }
      var  navBar = 0
      resourceId = view.resources.getIdentifier("navigation_bar_height", "dimen", "android")
      if (resourceId &gt; 0) {
          navBar = view.resources.getDimensionPixelSize(resourceId)
      }
      view.setPadding(0, statusBar, 0, navBar)
  </code></pre>
  
  <p><strong>Option 2</strong></p>
  
  <pre><code>var insets = view.rootWindowInsets.stableInsets
  view.setPadding(0, insets.top, 0, insets.bottom)
  </code></pre>
  
  <p>I prefer the first, because it (with limited testing on emulators seems to) work on API 21, 28 and 29.</p>
  
  <p>Option 2 only works on API 29, and also seems to get null on <code>view.rootWindowInsets</code> if/when the view is not attached. (So I guess I have to add a listener and wait for it to be attached before doing this)</p>
  
  <p>So my question is, is there a down side to Option 1? Can I use it over the new API in 29? Is there any scenarios that Option 1 would not work?</p>
  
  <p>(I think Option 1 might not work well on tablets where both nav and systems bars are on the bottom, so extra padding will be applied to the wrong side.)</p>