From 5aea9b290b0e615aa0e696553204b5bb957f9991 Mon Sep 17 00:00:00 2001 From: alihassan143 Date: Wed, 18 Sep 2024 17:26:17 +0500 Subject: [PATCH] code formatted --- .../FlutterMobileAdsWrapper.java | 143 ++++++++---------- 1 file changed, 61 insertions(+), 82 deletions(-) diff --git a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java index 6d90d764a..2586dc3b3 100644 --- a/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java +++ b/packages/google_mobile_ads/android/src/main/java/io/flutter/plugins/googlemobileads/FlutterMobileAdsWrapper.java @@ -18,97 +18,76 @@ import android.os.Build; import android.util.Log; import android.webkit.WebView; - import androidx.annotation.NonNull; - import com.google.android.gms.ads.MobileAds; import com.google.android.gms.ads.OnAdInspectorClosedListener; import com.google.android.gms.ads.RequestConfiguration; import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; - import io.flutter.embedding.engine.FlutterEngine; import io.flutter.plugins.webviewflutter.WebViewFlutterAndroidExternalApi; -/** - * A wrapper around static methods in {@link com.google.android.gms.ads.MobileAds}. - */ +/** A wrapper around static methods in {@link com.google.android.gms.ads.MobileAds}. */ public class FlutterMobileAdsWrapper { - private static final String TAG = "FlutterMobileAdsWrapper"; - - public FlutterMobileAdsWrapper() { - } - - /** - * Initializes the sdk. - */ - public void initialize(@NonNull Context context, @NonNull OnInitializationCompleteListener listener) { - new Thread(() -> { - // Initialize the Google Mobile Ads SDK on a background thread. - MobileAds.initialize(context, listener); - }).start(); - } - - /** - * Wrapper for setAppMuted. - */ - public void setAppMuted(boolean muted) { - MobileAds.setAppMuted(muted); - } - - /** - * Wrapper for setAppVolume. - */ - public void setAppVolume(double volume) { - MobileAds.setAppVolume((float) volume); - } - - /** - * Wrapper for disableMediationInitialization. - */ - public void disableMediationInitialization(@NonNull Context context) { - MobileAds.disableMediationAdapterInitialization(context); - } - - /** - * Wrapper for getVersionString. - */ - public String getVersionString() { - return MobileAds.getVersion().toString(); - } - - /** - * Wrapper for getRequestConfiguration. - */ - public RequestConfiguration getRequestConfiguration() { - return MobileAds.getRequestConfiguration(); - } - - /** - * Wrapper for openDebugMenu. - */ - public void openDebugMenu(Context context, String adUnitId) { - MobileAds.openDebugMenu(context, adUnitId); - } - - /** - * Open the ad inspector. - */ - public void openAdInspector(Context context, OnAdInspectorClosedListener listener) { - MobileAds.openAdInspector(context, listener); - } - - /** - * Register the webView for monetization. - */ - public void registerWebView(int webViewId, FlutterEngine flutterEngine) { - WebView webView = WebViewFlutterAndroidExternalApi.getWebView(flutterEngine, webViewId); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - Log.w(TAG, "MobileAds.registerWebView does not support API levels less than 21"); - } else if (webView == null) { - Log.w(TAG, "MobileAds.registerWebView unable to find webView with id: " + webViewId); - } else { - MobileAds.registerWebView(webView); - } + private static final String TAG = "FlutterMobileAdsWrapper"; + + public FlutterMobileAdsWrapper() {} + + /** Initializes the sdk. */ + public void initialize( + @NonNull Context context, @NonNull OnInitializationCompleteListener listener) { + new Thread( + () -> { + // Initialize the Google Mobile Ads SDK on a background thread. + MobileAds.initialize(context, listener); + }) + .start(); + } + + /** Wrapper for setAppMuted. */ + public void setAppMuted(boolean muted) { + MobileAds.setAppMuted(muted); + } + + /** Wrapper for setAppVolume. */ + public void setAppVolume(double volume) { + MobileAds.setAppVolume((float) volume); + } + + /** Wrapper for disableMediationInitialization. */ + public void disableMediationInitialization(@NonNull Context context) { + MobileAds.disableMediationAdapterInitialization(context); + } + + /** Wrapper for getVersionString. */ + public String getVersionString() { + return MobileAds.getVersion().toString(); + } + + /** Wrapper for getRequestConfiguration. */ + public RequestConfiguration getRequestConfiguration() { + return MobileAds.getRequestConfiguration(); + } + + /** Wrapper for openDebugMenu. */ + public void openDebugMenu(Context context, String adUnitId) { + MobileAds.openDebugMenu(context, adUnitId); + } + + /** Open the ad inspector. */ + public void openAdInspector(Context context, OnAdInspectorClosedListener listener) { + MobileAds.openAdInspector(context, listener); + } + + /** Register the webView for monetization. */ + public void registerWebView(int webViewId, FlutterEngine flutterEngine) { + WebView webView = WebViewFlutterAndroidExternalApi.getWebView(flutterEngine, webViewId); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + Log.w(TAG, "MobileAds.registerWebView does not support API levels less than 21"); + } else if (webView == null) { + Log.w(TAG, "MobileAds.registerWebView unable to find webView with id: " + webViewId); + } else { + MobileAds.registerWebView(webView); } + } }