MediaRouter: update visibility of media control view before measuring

Bug: 23934584
Change-Id: I19c4d0e807694cfc91e2183b8e87f3157e05ce39
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
index 5476f48..f3ab408 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
@@ -478,6 +478,17 @@
         return height;
     }
 
+    private void updateMediaControlVisibility() {
+        // TODO: Update the top and bottom padding of the control layout according to the display
+        // height.
+        mDividerView.setVisibility((mVolumeControl.getVisibility() == View.VISIBLE
+                && mPlaybackControl.getVisibility() == View.VISIBLE)
+                ? View.VISIBLE : View.GONE);
+        mMediaControlLayout.setVisibility((mVolumeControl.getVisibility() == View.GONE
+                && mPlaybackControl.getVisibility() == View.GONE)
+                ? View.GONE : View.VISIBLE);
+    }
+
     /**
      * Updates the height of views and hide artwork or metadata if space is limited.
      */
@@ -485,6 +496,7 @@
         if (mCustomControlView != null) {
             return;
         }
+        updateMediaControlVisibility();
         View decorView = getWindow().getDecorView();
         decorView.measure(
                 MeasureSpec.makeMeasureSpec(getWindow().getAttributes().width, MeasureSpec.EXACTLY),
@@ -538,14 +550,7 @@
         } else {
             mPlaybackControl.setVisibility(View.GONE);
         }
-        // TODO: Update the top and bottom padding of the control layout according to the display
-        // height.
-        mDividerView.setVisibility((mVolumeControl.getVisibility() == View.VISIBLE
-                && mPlaybackControl.getVisibility() == View.VISIBLE)
-                ? View.VISIBLE : View.GONE);
-        mMediaControlLayout.setVisibility((mVolumeControl.getVisibility() == View.GONE
-                && mPlaybackControl.getVisibility() == View.GONE)
-                ? View.GONE : View.VISIBLE);
+        updateMediaControlVisibility();
         mainControllerHeight = getMainControllerHeight(
                 mPlaybackControl.getVisibility() == View.VISIBLE);
         desiredControlLayoutHeight =