package com.vungle.mediation;

import com.vungle.warren.VungleSettings;

/** To apply the Vungle network settings during initialization. */
public class VungleNetworkSettings {

  private static final long MEGABYTE = 1024 * 1024;
  private static long minimumSpaceForInit = 50 * MEGABYTE;
  private static long minimumSpaceForAd = 51 * MEGABYTE;
  private static boolean androidIdOptedOut;
  private static VungleSettings vungleSettings;
  private static VungleSettingsChangedListener vungleSettingsChangedListener;

  public static void setMinSpaceForInit(long spaceForInit) {
    minimumSpaceForInit = spaceForInit;
    applySettings();
  }

  public static void setMinSpaceForAdLoad(long spaceForAd) {
    minimumSpaceForAd = spaceForAd;
    applySettings();
  }

  public static void setAndroidIdOptOut(boolean isOptedOut) {
    androidIdOptedOut = isOptedOut;
    applySettings();
  }

  /**
   * To pass Vungle network setting to SDK. this method must be called before first loadAd. if
   * called after first loading an ad, settings will not be applied.
   */
  private static void applySettings() {
    vungleSettings =
        new VungleSettings.Builder()
            .setMinimumSpaceForInit(minimumSpaceForInit)
            .setMinimumSpaceForAd(minimumSpaceForAd)
            .setAndroidIdOptOut(androidIdOptedOut)
            .disableBannerRefresh()
            .build();
    if (vungleSettingsChangedListener != null) {
      vungleSettingsChangedListener.onVungleSettingsChanged(vungleSettings);
    }
  }

  public static VungleSettings getVungleSettings() {
    return vungleSettings;
  }

  public static void setVungleSettingsChangedListener(
      VungleSettingsChangedListener settingsChangedListener) {
    vungleSettingsChangedListener = settingsChangedListener;
  }

  public interface VungleSettingsChangedListener {

    void onVungleSettingsChanged(VungleSettings vungleSettings);
  }
}

@@ -1563,24 +1563,148 @@
 ettings() %7B%0A
+    if (vungleSettings == null) %7B%0A      vungleSettings = new VungleSettings.Builder().disableBannerRefresh().build();%0A    %7D%0A
     return v

Fix auto refresh when none Vungle settings (#93)