code: private void obtainMaxHeight(@StyleRes final int themeResourceId) {
          TypedArray typedArray = getContext().getTheme()
                  .obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogMaxHeight});
          int defaultValue;
  
          try {
              defaultValue =
                      getContext().getResources().getDimensionPixelSize(R.dimen.dialog_max_height);
          } catch (Resources.NotFoundException | UnsupportedOperationException e) {
              defaultValue = -1;
          }
  
          try {
              setMaxHeight(typedArray.getDimensionPixelSize(0, defaultValue));
          } catch (Resources.NotFoundException | UnsupportedOperationException e) {
              setMaxHeight(-1);
          }
      }
docs: Obtains the maximum height from a specific theme.
  
  @param themeResourceId
  The resource id of the theme, the maximum height should be obtained from, as an
  {@link Integer} value