Explorar el Código

[New]更新广告sdk v3.0.8.0

zhipeng hace 1 año
padre
commit
7c620768bf

+ 5 - 1
CHANGELOG.md

@@ -5,4 +5,8 @@
 
 ## 0.0.2
 
-* 新增Android端广告事件回调
+* 新增Android端广告事件回调
+
+## 0.0.3
+
+* 更新广告sdk v3.0.8.0

+ 9 - 2
android/build.gradle

@@ -68,9 +68,16 @@ android {
         implementation "androidx.appcompat:appcompat:1.6.1"
 
         implementation "androidx.recyclerview:recyclerview:1.3.0"
-        //广告模块
-        implementation "plus.ad:ad:2.9.7-SNAPSHOT"
 
+        // Atmob Ad
+        implementation "plus.ad:mediation:3.0.8.0-SNAPSHOT" //广告聚合模块
+        implementation("plus.ad:mediation-gromore:6.6.0.7.1-SNAPSHOT") {
+            exclude group: 'plus.bytedance', module: 'mediation-adscope'
+        } //Gromore adapter
+        implementation("plus.ad:mediation-taku:6.3.50.1-SNAPSHOT") {
+            exclude group: 'plus.taku', module: 'network-adscope'
+        } //Taku adapter
+        implementation "plus.ad:mediation-tobid:4.2.15.1-SNAPSHOT" //Tobid adapter
     }
 
     testOptions {

+ 3 - 6
android/src/main/java/com/atmob/flutter_ad/FlutterAdPlugin.java

@@ -55,16 +55,13 @@ public class FlutterAdPlugin implements FlutterPlugin, MethodCallHandler, Activi
         try {
             switch (call.method) {
                 case FlutterAdMethod.initAd:
-                    FlutterAtmobAdConfig.initAd(applicationContext, call, result);
+                    FlutterAtmobAdConfig.initAd(applicationContext, mActivity, call, result);
                     break;
                 case FlutterAdMethod.loadInterstitial:
-                    InterstitialAdCall.loadInterstitial(applicationContext, channel, call, result);
-                    break;
-                case FlutterAdMethod.loadInterstitialFull:
-                    InterstitialAdCall.loadInterstitialFull(applicationContext, channel, call, result);
+                    InterstitialAdCall.loadInterstitial(mActivity, channel, call, result);
                     break;
                 case FlutterAdMethod.loadRewardVideo:
-                    RewardVideoAdCall.loadRewardVideo(applicationContext, channel, call, result);
+                    RewardVideoAdCall.loadRewardVideo(mActivity, channel, call, result);
                     break;
                 case FlutterAdMethod.setAdEventCallback:
                     AtmobAdEventHelper.setAdEventCallback(flutterPluginBinding, result);

+ 134 - 38
android/src/main/java/com/atmob/flutter_ad/adevent/AtmobAdEventHelper.java

@@ -1,11 +1,13 @@
 package com.atmob.flutter_ad.adevent;
 
-import com.atmob.ad.callback.OnAdEventCallback;
 import com.atmob.flutter_ad.constants.FlutterAdMethod;
 import com.atmob.flutter_ad.constants.FlutterNameConfig;
 import com.atmob.flutter_ad.utils.FlutterParamsUtils;
-import com.atmob.logging.AtmobLog;
-import com.atmob.sdk.AtmobAdSdk;
+import com.atmob.mediation.api.AdConstants;
+import com.atmob.mediation.api.EcpmInfo;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 
 import io.flutter.embedding.engine.plugins.FlutterPlugin;
 import io.flutter.plugin.common.MethodChannel;
@@ -28,46 +30,140 @@ public class AtmobAdEventHelper {
                     }
                 }
             }
-            AtmobAdSdk.getInstance().setAdEventCallback(new OnAdEventCallback() {
-                @Override
-                public void onAdLoad(String adUnionType, String adPlacementId, String adSourceId, String adType, String adnType) {
-                    AtmobLog.d(TAG, "onAdLoad: adUnionType = " + adUnionType + ", adPlacementId = " + adPlacementId + ", adSourceId = " + adSourceId + ", adType = " + adType + ", adnType = " + adnType);
-                    if (eventChannel != null)
-                        eventChannel.invokeMethod(FlutterAdMethod.onAdLoadEvent, FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, adType, adnType));
-                }
+            result.success(null);
+        } catch (Exception e) {
+            result.error("setAdEventCallback error", e.getMessage(), null);
+        }
+    }
 
-                @Override
-                public void onAdShow(String adUnionType, String adPlacementId, String adSourceId, String adType, String adnType, float ecpm) {
-                    AtmobLog.d(TAG, "onAdShow: adUnionType = " + adUnionType + ", adPlacementId = " + adPlacementId + ", adSourceId = " + adSourceId + ", adType = " + adType + ", adnType = " + adnType + ", ecpm = " + ecpm);
-                    if (eventChannel != null)
-                        eventChannel.invokeMethod(FlutterAdMethod.onAdShowEvent, FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, adType, adnType, ecpm));
-                }
+    public static void onAdLoaded(int adType, EcpmInfo ecpmInfo) {
+        String adUnionType = getAdUnionType(ecpmInfo);
+        String adPlacementId = ecpmInfo.getPositionId();
+        String adSourceId = ecpmInfo.getShowPositionId();
+        String adnType = getAdnType(ecpmInfo);
+        if (eventChannel != null) {
+            eventChannel.invokeMethod(FlutterAdMethod.onAdLoadEvent,
+                    FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, getAdType(adType), adnType));
+        }
+    }
 
-                @Override
-                public void onAdClick(String adUnionType, String adPlacementId, String adSourceId, String adType, String adnType, float ecpm) {
-                    AtmobLog.d(TAG, "onAdClick: adUnionType = " + adUnionType + ", adPlacementId = " + adPlacementId + ", adSourceId = " + adSourceId + ", adType = " + adType + ", adnType = " + adnType + ", ecpm = " + ecpm);
-                    if (eventChannel != null)
-                        eventChannel.invokeMethod(FlutterAdMethod.onAdClickEvent, FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, adType, adnType, ecpm));
-                }
+    public static void onAdShow(int adType, EcpmInfo ecpmInfo) {
+        String adUnionType = getAdUnionType(ecpmInfo);
+        String adPlacementId = ecpmInfo.getPositionId();
+        String adSourceId = ecpmInfo.getShowPositionId();
+        String adnType = getAdnType(ecpmInfo);
+        float ecpm = getEcpm(ecpmInfo);
+        if (eventChannel != null) {
+            eventChannel.invokeMethod(FlutterAdMethod.onAdShowEvent,
+                    FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, getAdType(adType), adnType, ecpm));
+        }
+    }
 
-                @Override
-                public void onAdPlayStart(String adUnionType, String adPlacementId, String adSourceId, String adType, String adnType, float ecpm) {
-                    AtmobLog.d(TAG, "onAdPlayStart: adUnionType = " + adUnionType + ", adPlacementId = " + adPlacementId + ", adSourceId = " + adSourceId + ", adType = " + adType + ", adnType = " + adnType + ", ecpm = " + ecpm);
-                    if (eventChannel != null)
-                        eventChannel.invokeMethod(FlutterAdMethod.onAdPlayStartEvent, FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, adType, adnType, ecpm));
-                }
+    public static void onAdClick(int adType, EcpmInfo ecpmInfo) {
+        String adUnionType = getAdUnionType(ecpmInfo);
+        String adPlacementId = ecpmInfo.getPositionId();
+        String adSourceId = ecpmInfo.getShowPositionId();
+        String adnType = getAdnType(ecpmInfo);
+        float ecpm = getEcpm(ecpmInfo);
+        if (eventChannel != null) {
+            eventChannel.invokeMethod(FlutterAdMethod.onAdClickEvent,
+                    FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, getAdType(adType), adnType, ecpm));
+        }
+    }
 
-                @Override
-                public void onAdPlayEnd(String adUnionType, String adPlacementId, String adSourceId, String adType, String adnType, float ecpm, int duration, boolean isPlayOver) {
-                    AtmobLog.d(TAG, "onAdPlayEnd: adUnionType = " + adUnionType + ", adPlacementId = " + adPlacementId + ", adSourceId = " + adSourceId + ", adType = " + adType + ", adnType = " + adnType + ", ecpm = " + ecpm + ", duration = " + duration + ", isPlayOver = " + isPlayOver);
-                    if (eventChannel != null)
-                        eventChannel.invokeMethod(FlutterAdMethod.onAdPlayEndEvent, FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, adType, adnType, ecpm, duration, isPlayOver));
-                }
-            });
-            result.success(null);
-        } catch (Exception e) {
-            result.error("setAdEventCallback error", e.getMessage(), null);
+    public static void onAdPlayStart(EcpmInfo ecpmInfo) {
+        String adUnionType = getAdUnionType(ecpmInfo);
+        String adPlacementId = ecpmInfo.getPositionId();
+        String adSourceId = ecpmInfo.getShowPositionId();
+        String adnType = getAdnType(ecpmInfo);
+        float ecpm = getEcpm(ecpmInfo);
+        String adType = getAdType(AdConstants.RewardVideo);
+        if (eventChannel != null) {
+            eventChannel.invokeMethod(FlutterAdMethod.onAdPlayStartEvent,
+                    FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, adType, adnType, ecpm));
+        }
+    }
+
+    public static void onAdPlayEnd(EcpmInfo ecpmInfo, int duration, boolean isPlayOver) {
+        String adUnionType = getAdUnionType(ecpmInfo);
+        String adPlacementId = ecpmInfo.getPositionId();
+        String adSourceId = ecpmInfo.getShowPositionId();
+        String adnType = getAdnType(ecpmInfo);
+        float ecpm = getEcpm(ecpmInfo);
+        String adType = getAdType(AdConstants.RewardVideo);
+        if (eventChannel != null) {
+            eventChannel.invokeMethod(FlutterAdMethod.onAdPlayEndEvent,
+                    FlutterParamsUtils.createAdEventParams(adUnionType, adPlacementId, adSourceId, adType, adnType, ecpm, duration, isPlayOver));
+        }
+    }
+
+    //reward、banner、 native 、interstitial、 splash
+    public static String getAdType(int adType) {
+        switch (adType) {
+            case AdConstants.Splash:
+                return "splash";
+            case AdConstants.NativeExpress:
+            case AdConstants.NativeUnified:
+                return "native";
+            case AdConstants.Interstitial:
+            case AdConstants.InterstitialFull:
+                return "interstitial";
+            case AdConstants.RewardVideo:
+                return "reward";
+            case AdConstants.BannerExpress:
+                return "banner";
+        }
+        return "";
+    }
+
+    public static String getAdUnionType(EcpmInfo ecpmInfo) {
+        if (ecpmInfo == null) {
+            return "self";
+        }
+        int platformId = ecpmInfo.getPlatformId();
+        switch (platformId) {
+            case AdConstants.Gromore:
+                return "gromore";
+            case AdConstants.Taku:
+            case AdConstants.TopOn:
+                return "topon";
+            case AdConstants.Max:
+                return "max";
+            case AdConstants.ToBid:
+                return "tobid";
         }
+        return "self";
     }
 
+    public static String getAdnType(EcpmInfo ecpmInfo) {
+        if (ecpmInfo == null) {
+            return "other";
+        }
+        int showPlatformId = ecpmInfo.getShowPlatformId();
+        switch (showPlatformId) {
+            case AdConstants.CSJ:
+                return "csj";
+            case AdConstants.Tencent:
+                return "gdt";
+            case AdConstants.Kuaishou:
+                return "ks";
+            case AdConstants.Mintegral:
+                return "mint";
+            case AdConstants.Baidu:
+                return "baidu";
+        }
+        return "other";
+    }
+
+    /**
+     * @return 单位元
+     */
+    public static float getEcpm(EcpmInfo ecpmInfo) {
+        if (ecpmInfo == null) {
+            return 0;
+        }
+        double ecpmCent = ecpmInfo.getEcpmCent();
+        BigDecimal bigDecimal = new BigDecimal(ecpmCent);
+        return bigDecimal.divide(new BigDecimal(100), 2, RoundingMode.HALF_DOWN).floatValue();
+    }
 }

+ 44 - 17
android/src/main/java/com/atmob/flutter_ad/bannerad/BannerAdView.java

@@ -3,19 +3,23 @@ package com.atmob.flutter_ad.bannerad;
 import android.app.Activity;
 import android.content.Context;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.ViewTreeObserver;
 
 import androidx.annotation.Nullable;
 
-import com.atmob.ad.listener.BannerListener;
+import com.atmob.flutter_ad.adevent.AtmobAdEventHelper;
 import com.atmob.flutter_ad.constants.FlutterListenerMethod;
 import com.atmob.flutter_ad.constants.FlutterNameConfig;
 import com.atmob.flutter_ad.utils.FlutterParamsUtils;
 import com.atmob.flutter_ad.utils.SizeUtils;
 import com.atmob.flutter_ad.widget.AdLoadContainer;
 import com.atmob.logging.AtmobLog;
-import com.atmob.sdk.AtmobAdNative;
-import com.atmob.sdk.AtmobAdSdk;
+import com.atmob.mediation.api.AdConstants;
+import com.atmob.mediation.api.AdError;
+import com.atmob.mediation.api.ad.AtmobAdLoadCallback;
+import com.atmob.mediation.api.ad.banner.AtmobBannerAd;
+import com.atmob.mediation.api.ad.banner.AtmobBannerAdListener;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -44,7 +48,7 @@ public class BannerAdView implements PlatformView {
 
     int adFuncId;
 
-    AtmobAdNative adNative;
+    private AtmobBannerAd atmobBannerAd;
 
     public BannerAdView(Context context, Activity activity, BinaryMessenger messenger, int viewId, Map<String, Object> args) {
         this.context = context;
@@ -88,37 +92,57 @@ public class BannerAdView implements PlatformView {
 
 
     void loadBannerAd() {
-        adNative = AtmobAdSdk.getInstance().createAdNative(context);
-        adNative.loadBannerExpress(adFuncId, mContainer, new BannerListener() {
+        atmobBannerAd = new AtmobBannerAd(activity, String.valueOf(adFuncId));
+        atmobBannerAd.setBannerAdListener(new AtmobBannerAdListener() {
             @Override
-            public void onShow() {
-                AtmobLog.d(TAG, "onShow");
+            public void onAdClicked() {
+                AtmobLog.d(TAG, "onAdClicked");
+                AtmobAdEventHelper.onAdClick(AdConstants.BannerExpress, atmobBannerAd.getEcpmInfo());
+                if (channel != null) {
+                    channel.invokeMethod(FlutterListenerMethod.onClick, null);
+                }
+            }
+
+            @Override
+            public void onAdShow() {
+                AtmobLog.d(TAG, "onAdShow");
+                AtmobAdEventHelper.onAdShow(AdConstants.BannerExpress, atmobBannerAd.getEcpmInfo());
                 if (channel != null) {
                     channel.invokeMethod(FlutterListenerMethod.onShow, null);
                 }
             }
 
             @Override
-            public void onClose() {
-                AtmobLog.d(TAG, "onClose");
+            public void onAdShowFail(AdError adError) {
+                AtmobLog.d(TAG, "onAdShowFail:" + adError.toString());
                 if (channel != null) {
-                    channel.invokeMethod(FlutterListenerMethod.onClose, null);
+                    channel.invokeMethod(FlutterListenerMethod.onFail, adError.toString());
                 }
             }
 
             @Override
-            public void onFail(String msg) {
-                AtmobLog.d(TAG, "onFail:" + msg);
+            public void onAdClosed() {
+                AtmobLog.d(TAG, "onAdClosed");
                 if (channel != null) {
-                    channel.invokeMethod(FlutterListenerMethod.onFail, msg);
+                    channel.invokeMethod(FlutterListenerMethod.onClose, null);
+                }
+            }
+        });
+        atmobBannerAd.loadAd(new AtmobAdLoadCallback() {
+            @Override
+            public void onAdLoaded() {
+                AtmobAdEventHelper.onAdLoaded(AdConstants.BannerExpress, atmobBannerAd.getEcpmInfo());
+                View bannerView = atmobBannerAd.getBannerView();
+                if (bannerView != null) {
+                    mContainer.addView(bannerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                 }
             }
 
             @Override
-            public void onClick() {
-                AtmobLog.d(TAG, "onClick");
+            public void onLoadFailed(AdError adError) {
+                AtmobLog.d(TAG, "onLoadFailed:" + adError.toString());
                 if (channel != null) {
-                    channel.invokeMethod(FlutterListenerMethod.onClick, null);
+                    channel.invokeMethod(FlutterListenerMethod.onFail, adError.toString());
                 }
             }
         });
@@ -143,6 +167,9 @@ public class BannerAdView implements PlatformView {
         if (mContainer != null) {
             mContainer.removeAllViews();
         }
+        if (atmobBannerAd != null) {
+            atmobBannerAd.recycle();
+        }
         channel.setMethodCallHandler(null);
     }
 

+ 45 - 23
android/src/main/java/com/atmob/flutter_ad/config/FlutterAtmobAdConfig.java

@@ -1,13 +1,18 @@
 package com.atmob.flutter_ad.config;
 
+import android.app.Activity;
 import android.content.Context;
 import android.text.TextUtils;
 
+import com.atmob.central.AtmobCentral;
+import com.atmob.central.AtmobCentralConfig;
+import com.atmob.compliance.AtmobCompliance;
 import com.atmob.flutter_ad.utils.FlutterParamsUtils;
 import com.atmob.logging.AtmobLog;
-import com.atmob.sdk.AtmobAdConfig;
-import com.atmob.sdk.AtmobAdSdk;
-import com.atmob.sdk.GromoreSplashInfo;
+import com.atmob.mediation.api.AdError;
+import com.atmob.mediation.api.AtmobAdSdk;
+import com.atmob.mediation.api.config.AtmobAdConfig;
+import com.atmob.mediation.util.ThreadPool;
 
 import java.util.Map;
 
@@ -40,12 +45,17 @@ public class FlutterAtmobAdConfig {
      * 'debug': debug,
      *
      * @param applicationContext
+     * @param mActivity
      * @param call
      * @param result
      */
-    public static void initAd(Context applicationContext, MethodCall call, MethodChannel.Result result) {
+    public static void initAd(Context applicationContext, Activity mActivity, MethodCall call, MethodChannel.Result result) {
         try {
             Map<String, Object> params = call.arguments();
+            if (params == null) {
+                result.error("params is null", "params is null", null);
+                return;
+            }
             String atmobAppKey = (String) params.get("atmobAppKey");
             if (TextUtils.isEmpty(atmobAppKey)) {
                 result.error("atmobAppKey is empty", "atmobAppKey is empty", null);
@@ -54,31 +64,43 @@ public class FlutterAtmobAdConfig {
             String atmobChanel = FlutterParamsUtils.getString(params, "atmobChanel");
             int atmobAppId = FlutterParamsUtils.getInt(params, "atmobAppId", 0);
             int atmobTgPlatform = FlutterParamsUtils.getInt(params, "atmobAppId", 0);
-            String csjAppId = FlutterParamsUtils.getString(params, "csjAppId");
-            String toponAppKey = FlutterParamsUtils.getString(params, "toponAppKey");
-            String toponAppId = FlutterParamsUtils.getString(params, "toponAppId");
-
             boolean debug = FlutterParamsUtils.getBoolean(params, "debug", false);
 
-            int gromorePlatformId = FlutterParamsUtils.getInt(params, "gromorePlatformId", -1);
-            String gromorePositionId = FlutterParamsUtils.getString(params, "gromorePositionId");
-            String gromoreAppId = FlutterParamsUtils.getString(params, "gromoreAppId");
-            String gromoreAppKey = FlutterParamsUtils.getString(params, "gromoreAppKey");
+            AtmobCentral.init(applicationContext, new AtmobCentralConfig.Builder()
+                    .debug(debug)
+                    .appKey(atmobAppKey)
+                    .channel(atmobChanel)
+                    .appId(atmobAppId)
+                    .tgPlatform(atmobTgPlatform)
+                    .complianceStrategy(AtmobCompliance.Strategy.CHINA)
+                    .centralServer("https://project-api.atmob.com")
+                    .executorService(ThreadPool.getInstance())
+                    .build());
 
+            AtmobCentral.onPolicyGrant(true);
 
-            AtmobAdConfig.Build build = new AtmobAdConfig.Build(atmobAppKey);
-            build.atmobInfo(atmobChanel, atmobAppId, atmobTgPlatform);
-            build.csjAppId(csjAppId);
-            build.toponAppId(toponAppKey, toponAppId);
 
-            if (gromorePositionId != null && gromoreAppId != null) {
-                GromoreSplashInfo gromoreSplashInfo = new GromoreSplashInfo(gromorePlatformId, gromorePositionId, gromoreAppId, gromoreAppKey);
-                build.gromoreSplashInfo(gromoreSplashInfo);
-            }
+            AtmobAdSdk.init(applicationContext, new AtmobAdConfig.Builder()
+                    .setDebug(debug)
+                    .setUseServerConfig(true)
+                    .setServerUrl("https://i90okxj.v8dashen.com:4695", false) // isOversea, false: 国内, true: 海外
+                    .build(), new AtmobAdSdk.AtmobAdSdkInitCallback() {
+                @Override
+                public void onSuccess() {
+                    AtmobLog.d(TAG, "AtmobAdSdk init success.");
+
+                    AtmobAdSdk.preloadSplashAd(mActivity, null);
+                    AtmobAdSdk.preloadNativeAd(mActivity, null);
+                    AtmobAdSdk.preloadInterstitialAd(mActivity, null);
+                    AtmobAdSdk.preloadBannerAd(mActivity, null);
+                    AtmobAdSdk.preloadRewardAd(mActivity, null);
+                }
 
-            build.debug(debug);
-            AtmobAdSdk.getInstance().initAd(applicationContext, build.build());
-            AtmobLog.d(TAG, "initAd:success");
+                @Override
+                public void onFailed(AdError adError) {
+                    AtmobLog.e(TAG, "AtmobAdSdk init failed: %s.", adError);
+                }
+            });
             result.success(null);
         } catch (Exception e) {
             AtmobLog.d(TAG, "initAd:" + e.getMessage());

+ 1 - 0
android/src/main/java/com/atmob/flutter_ad/constants/CommonParams.java

@@ -4,6 +4,7 @@ public class CommonParams {
 
 
     public static final String AdFuncId = "adFuncId";
+    public static final String CallbackId = "callbackId";
 
 
     //广告事件参数

+ 0 - 2
android/src/main/java/com/atmob/flutter_ad/constants/FlutterAdMethod.java

@@ -11,8 +11,6 @@ public class FlutterAdMethod {
 
     public static final String loadInterstitial = "loadInterstitial";
 
-    public static final String loadInterstitialFull = "loadInterstitialFull";
-
     public static final String loadRewardVideo = "loadRewardVideo";
 
     public static final String setAdEventCallback = "setAdEventCallback";

+ 48 - 58
android/src/main/java/com/atmob/flutter_ad/interstitial/InterstitialAdCall.java

@@ -1,16 +1,18 @@
 package com.atmob.flutter_ad.interstitial;
 
-import android.content.Context;
+import android.app.Activity;
 
-import com.atmob.ad.listener.InterstitialFullListener;
-import com.atmob.ad.listener.InterstitialListener;
+import com.atmob.flutter_ad.adevent.AtmobAdEventHelper;
 import com.atmob.flutter_ad.constants.CommonParams;
 import com.atmob.flutter_ad.constants.FlutterAdMethod;
 import com.atmob.flutter_ad.constants.FlutterListenerMethod;
 import com.atmob.flutter_ad.utils.FlutterParamsUtils;
 import com.atmob.logging.AtmobLog;
-import com.atmob.sdk.AtmobAdNative;
-import com.atmob.sdk.AtmobAdSdk;
+import com.atmob.mediation.api.AdConstants;
+import com.atmob.mediation.api.AdError;
+import com.atmob.mediation.api.ad.AtmobAdLoadCallback;
+import com.atmob.mediation.api.ad.interstitial.AtmobInterstitialAd;
+import com.atmob.mediation.api.ad.interstitial.AtmobInterstitialAdListener;
 
 import java.util.Map;
 
@@ -20,8 +22,9 @@ import io.flutter.plugin.common.MethodChannel;
 public class InterstitialAdCall {
 
     private static final String TAG = "InterstitialAdCall";
+    private static AtmobInterstitialAd atmobInterstitialAd;
 
-    public static void loadInterstitial(Context context, MethodChannel channel, MethodCall call, MethodChannel.Result result) {
+    public static void loadInterstitial(Activity activity, MethodChannel channel, MethodCall call, MethodChannel.Result result) {
         Map<String, Object> params = call.arguments();
         if (params == null) {
             result.error("params is empty", "params is empty", null);
@@ -31,77 +34,64 @@ public class InterstitialAdCall {
             result.error("AdFuncId is empty", "AdFuncId is empty", null);
             return;
         }
+        String callbackId = FlutterParamsUtils.getString(params, CommonParams.CallbackId);
         int adFuncId = FlutterParamsUtils.getInt(params, CommonParams.AdFuncId, -1);
         AtmobLog.d(TAG, "loadInterstitial: adFuncId = " + adFuncId);
-        AtmobAdNative adNative = AtmobAdSdk.getInstance().createAdNative(context);
-        adNative.loadInterstitial(adFuncId, new InterstitialListener() {
+        atmobInterstitialAd = new AtmobInterstitialAd(activity, String.valueOf(adFuncId));
+        atmobInterstitialAd.setInterstitialListener(new AtmobInterstitialAdListener() {
             @Override
-            public void onShow() {
+            public void onInterstitialShow() {
                 AtmobLog.d(TAG, "loadInterstitial..onShow");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onShow));
+                AtmobAdEventHelper.onAdShow(AdConstants.Interstitial, atmobInterstitialAd.getEcpmInfo());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onShow));
+                }
             }
 
             @Override
-            public void onClose() {
-                AtmobLog.d(TAG, "loadInterstitial..onClose");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onClose));
-
+            public void onInterstitialShowFail(AdError adError) {
+                AtmobLog.d(TAG, "loadInterstitial..onShowFail: " + adError.toString());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onFail, adError.toString()));
+                }
             }
 
             @Override
-            public void onFail(String s) {
-                AtmobLog.d(TAG, "loadInterstitial..onFail: " + s);
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onFail, s));
-
-            }
-
-            @Override
-            public void onClick() {
+            public void onInterstitialAdClick() {
                 AtmobLog.d(TAG, "loadInterstitial..onClick");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onClick));
-
+                AtmobAdEventHelper.onAdClick(AdConstants.Interstitial, atmobInterstitialAd.getEcpmInfo());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onClick));
+                }
             }
-        });
-    }
 
-    public static void loadInterstitialFull(Context context, MethodChannel channel, MethodCall call, MethodChannel.Result result) {
-        Map<String, Object> params = call.arguments();
-        if (params == null) {
-            result.error("params is empty", "params is empty", null);
-            return;
-        }
-        if (!params.containsKey(CommonParams.AdFuncId)) {
-            result.error("AdFuncId is empty", "AdFuncId is empty", null);
-            return;
-        }
-        int adFuncId = FlutterParamsUtils.getInt(params, CommonParams.AdFuncId, -1);
-        AtmobLog.d(TAG, "loadInterstitialFull: adFuncId = " + adFuncId);
-        AtmobAdNative adNative = AtmobAdSdk.getInstance().createAdNative(context);
-        adNative.loadInterstitialFull(adFuncId, new InterstitialFullListener() {
             @Override
-            public void onShow() {
-                AtmobLog.d(TAG, "loadInterstitialFull..onShow");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onShow));
-            }
-
-            @Override
-            public void onClose() {
-                AtmobLog.d(TAG, "loadInterstitialFull..onClose");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onClose));
-
+            public void onInterstitialClosed() {
+                AtmobLog.d(TAG, "loadInterstitial..onClose");
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onClose));
+                }
             }
-
+        });
+        atmobInterstitialAd.loadAd(new AtmobAdLoadCallback() {
             @Override
-            public void onFail(String s) {
-                AtmobLog.d(TAG, "loadInterstitialFull..onFail: " + s);
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onFail, s));
-
+            public void onAdLoaded() {
+                AtmobLog.d(TAG, "loadInterstitial..onAdLoaded");
+                AtmobAdEventHelper.onAdLoaded(AdConstants.Interstitial, atmobInterstitialAd.getEcpmInfo());
+                atmobInterstitialAd.showInterstitial();
             }
 
             @Override
-            public void onClick() {
-                AtmobLog.d(TAG, "loadInterstitialFull..onClick");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onClick));
+            public void onLoadFailed(AdError adError) {
+                AtmobLog.d(TAG, "loadInterstitial..onLoadFailed: " + adError.toString());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onFail, adError.toString()));
+                }
             }
         });
     }

+ 30 - 30
android/src/main/java/com/atmob/flutter_ad/nativead/NativeAdView.java

@@ -7,15 +7,18 @@ import android.view.ViewTreeObserver;
 
 import androidx.annotation.Nullable;
 
-import com.atmob.ad.listener.NativeExpressListener;
+import com.atmob.flutter_ad.adevent.AtmobAdEventHelper;
 import com.atmob.flutter_ad.constants.FlutterListenerMethod;
 import com.atmob.flutter_ad.constants.FlutterNameConfig;
 import com.atmob.flutter_ad.utils.FlutterParamsUtils;
 import com.atmob.flutter_ad.utils.SizeUtils;
 import com.atmob.flutter_ad.widget.AdLoadContainer;
 import com.atmob.logging.AtmobLog;
-import com.atmob.sdk.AtmobAdNative;
-import com.atmob.sdk.AtmobAdSdk;
+import com.atmob.mediation.api.AdConstants;
+import com.atmob.mediation.api.AdError;
+import com.atmob.mediation.api.ad.AtmobAdLoadCallback;
+import com.atmob.mediation.api.ad.nativead.AtmobNativeAd;
+import com.atmob.mediation.api.ad.nativead.AtmobNativeAdListener;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -43,8 +46,7 @@ public class NativeAdView implements PlatformView {
     private MethodChannel channel;
 
     int adFuncId;
-
-    AtmobAdNative adNative;
+    private AtmobNativeAd atmobNativeAd;
 
     public NativeAdView(Context context, Activity activity, BinaryMessenger messenger, int viewId, Map<String, Object> args) {
         this.context = context;
@@ -86,40 +88,38 @@ public class NativeAdView implements PlatformView {
         channel = new MethodChannel(messenger, FlutterNameConfig.nativeAdView + "_" + viewId);
     }
 
-
     void loadNativeAd() {
-        adNative = AtmobAdSdk.getInstance().createAdNative(context);
-        adNative.loadNativeExpress(adFuncId, mContainer, new NativeExpressListener() {
+        atmobNativeAd = new AtmobNativeAd(activity, String.valueOf(adFuncId));
+        atmobNativeAd.setNativeAdListener(new AtmobNativeAdListener() {
             @Override
-            public void onShow() {
-                AtmobLog.d(TAG, "onShow");
-                if (channel != null) {
-                    channel.invokeMethod(FlutterListenerMethod.onShow, null);
-                }
+            public void onAdClick() {
+                AtmobLog.d(TAG, "onAdClick");
+                AtmobAdEventHelper.onAdClick(AdConstants.NativeExpress, atmobNativeAd.getEcpmInfo());
+                channel.invokeMethod(FlutterListenerMethod.onClick, null);
             }
 
             @Override
-            public void onClose() {
-                AtmobLog.d(TAG, "onClose");
-                if (channel != null) {
-                    channel.invokeMethod(FlutterListenerMethod.onClose, null);
-                }
+            public void onAdShow() {
+                AtmobLog.d(TAG, "onAdShow");
+                AtmobAdEventHelper.onAdShow(AdConstants.NativeExpress, atmobNativeAd.getEcpmInfo());
+                channel.invokeMethod(FlutterListenerMethod.onShow, null);
             }
-
+        });
+        atmobNativeAd.loadAd(new AtmobAdLoadCallback() {
             @Override
-            public void onFail(String msg) {
-                AtmobLog.d(TAG, "onFail:" + msg);
-                if (channel != null) {
-                    channel.invokeMethod(FlutterListenerMethod.onFail, msg);
+            public void onAdLoaded() {
+                AtmobLog.d(TAG, "onAdLoaded");
+                AtmobAdEventHelper.onAdLoaded(AdConstants.NativeExpress, atmobNativeAd.getEcpmInfo());
+                View nativeView = atmobNativeAd.getNativeView();
+                if (nativeView != null) {
+                    mContainer.addView(nativeView);
                 }
             }
 
             @Override
-            public void onClick() {
-                AtmobLog.d(TAG, "onClick");
-                if (channel != null) {
-                    channel.invokeMethod(FlutterListenerMethod.onClick, null);
-                }
+            public void onLoadFailed(AdError adError) {
+                AtmobLog.d(TAG, "onLoadFailed:" + adError.toString());
+                channel.invokeMethod(FlutterListenerMethod.onFail, adError.toString());
             }
         });
     }
@@ -143,8 +143,8 @@ public class NativeAdView implements PlatformView {
         if (mContainer != null) {
             mContainer.removeAllViews();
         }
-        if (adNative != null) {
-            adNative.removeNativeExpress();
+        if (atmobNativeAd != null) {
+            atmobNativeAd.recycle();
         }
         channel.setMethodCallHandler(null);
     }

+ 62 - 43
android/src/main/java/com/atmob/flutter_ad/splash/SplashAdView.java

@@ -6,13 +6,16 @@ import android.view.Gravity;
 import android.view.View;
 import android.widget.LinearLayout;
 import androidx.annotation.Nullable;
-import com.atmob.ad.listener.SplashListener;
+import com.atmob.flutter_ad.adevent.AtmobAdEventHelper;
 import com.atmob.flutter_ad.constants.FlutterListenerMethod;
 import com.atmob.flutter_ad.constants.FlutterNameConfig;
 import com.atmob.flutter_ad.utils.FlutterParamsUtils;
 import com.atmob.logging.AtmobLog;
-import com.atmob.sdk.AtmobAdNative;
-import com.atmob.sdk.AtmobAdSdk;
+import com.atmob.mediation.api.AdConstants;
+import com.atmob.mediation.api.AdError;
+import com.atmob.mediation.api.ad.AtmobAdLoadCallback;
+import com.atmob.mediation.api.ad.splash.AtmobSplashAd;
+import com.atmob.mediation.api.ad.splash.AtmobSplashAdListener;
 import java.util.Map;
 import io.flutter.plugin.common.BinaryMessenger;
 import io.flutter.plugin.common.MethodChannel;
@@ -38,6 +41,7 @@ public class SplashAdView implements PlatformView {
     private MethodChannel channel;
 
     int adFuncId;
+    private AtmobSplashAd atmobSplashAd;
 
     public SplashAdView(Context context, Activity activity, BinaryMessenger messenger, int viewId, Map<String, Object> args) {
         this.context = context;
@@ -70,46 +74,61 @@ public class SplashAdView implements PlatformView {
 
 
     private void loadSplashAd() {
-        AtmobAdNative adNative = AtmobAdSdk.getInstance().createAdNative(context);
-        adNative.loadSplash(adFuncId, mContainer, () -> {
-                    AtmobLog.d(TAG, "action");
-                    if (channel != null) {
-                        channel.invokeMethod(FlutterListenerMethod.action, null);
-                    }
-                },
-                new SplashListener() {
-                    @Override
-                    public void onShow() {
-                        AtmobLog.d(TAG, "onShow");
-                        if (channel != null) {
-                            channel.invokeMethod(FlutterListenerMethod.onShow, null);
-                        }
-                    }
-
-                    @Override
-                    public void onClose() {
-                        AtmobLog.d(TAG, "onClose");
-                        if (channel != null) {
-                            channel.invokeMethod(FlutterListenerMethod.onClose, null);
-                        }
-                    }
-
-                    @Override
-                    public void onFail(String msg) {
-                        AtmobLog.d(TAG, "onFail:" + msg);
-                        if (channel != null) {
-                            channel.invokeMethod(FlutterListenerMethod.onFail, msg);
-                        }
-                    }
-
-                    @Override
-                    public void onClick() {
-                        AtmobLog.d(TAG, "onClick");
-                        if (channel != null) {
-                            channel.invokeMethod(FlutterListenerMethod.onClick, null);
-                        }
-                    }
-                });
+        atmobSplashAd = new AtmobSplashAd(activity, String.valueOf(adFuncId));
+        atmobSplashAd.setSplashAdListener(new AtmobSplashAdListener() {
+            @Override
+            public void onAdClicked() {
+                AtmobLog.d(TAG, "onAdClicked");
+                AtmobAdEventHelper.onAdClick(AdConstants.Splash, atmobSplashAd.getEcpmInfo());
+                if (channel != null) {
+                    channel.invokeMethod(FlutterListenerMethod.onClick, null);
+                }
+            }
+
+            @Override
+            public void onAdShow() {
+                AtmobLog.d(TAG, "onAdShow");
+                AtmobAdEventHelper.onAdShow(AdConstants.Splash, atmobSplashAd.getEcpmInfo());
+                if (channel != null) {
+                    channel.invokeMethod(FlutterListenerMethod.onShow, null);
+                }
+            }
+
+            @Override
+            public void onAdShowFail(AdError adError) {
+                AtmobLog.d(TAG, "onAdShowFail:" + adError.toString());
+                if (channel != null) {
+                    channel.invokeMethod(FlutterListenerMethod.onFail, adError.toString());
+                    channel.invokeMethod(FlutterListenerMethod.action, null);
+                }
+            }
+
+            @Override
+            public void onAdDismiss() {
+                AtmobLog.d(TAG, "onAdDismiss");
+                if (channel != null) {
+                    channel.invokeMethod(FlutterListenerMethod.onClose, null);
+                    channel.invokeMethod(FlutterListenerMethod.action, null);
+                }
+            }
+        });
+        atmobSplashAd.loadAd(new AtmobAdLoadCallback() {
+            @Override
+            public void onAdLoaded() {
+                AtmobLog.d(TAG, "onAdLoaded");
+                AtmobAdEventHelper.onAdLoaded(AdConstants.Splash, atmobSplashAd.getEcpmInfo());
+                atmobSplashAd.showSplashAd(mContainer);
+            }
+
+            @Override
+            public void onLoadFailed(AdError adError) {
+                AtmobLog.d(TAG, "onLoadFailed:" + adError.toString());
+                if (channel != null) {
+                    channel.invokeMethod(FlutterListenerMethod.onFail, adError.toString());
+                    channel.invokeMethod(FlutterListenerMethod.action, null);
+                }
+            }
+        });
     }
 
     @Nullable

+ 4 - 4
android/src/main/java/com/atmob/flutter_ad/utils/FlutterParamsUtils.java

@@ -11,17 +11,17 @@ import java.util.Map;
 public class FlutterParamsUtils {
 
 
-    public static Map<String, Object> createAdMethodParams(String adFuncId, String method, String failMsg) {
+    public static Map<String, Object> createAdMethodParams(String callbackId, String method, String failMsg) {
         Map<String, Object> params = new HashMap<>();
-        params.put("adFuncId", adFuncId);
+        params.put("callbackId", callbackId);
         params.put("method", method);
         params.put("failMsg", failMsg);
         return params;
     }
 
-    public static Map<String, Object> createAdMethodParams(String adFuncId, String method) {
+    public static Map<String, Object> createAdMethodParams(String callbackId, String method) {
         Map<String, Object> params = new HashMap<>();
-        params.put("adFuncId", adFuncId);
+        params.put("callbackId", callbackId);
         params.put("method", method);
         return params;
     }

+ 72 - 23
android/src/main/java/com/atmob/flutter_ad/video/RewardVideoAdCall.java

@@ -1,15 +1,18 @@
 package com.atmob.flutter_ad.video;
 
-import android.content.Context;
+import android.app.Activity;
 
-import com.atmob.ad.listener.RewardVideoListener;
+import com.atmob.flutter_ad.adevent.AtmobAdEventHelper;
 import com.atmob.flutter_ad.constants.CommonParams;
 import com.atmob.flutter_ad.constants.FlutterAdMethod;
 import com.atmob.flutter_ad.constants.FlutterListenerMethod;
 import com.atmob.flutter_ad.utils.FlutterParamsUtils;
 import com.atmob.logging.AtmobLog;
-import com.atmob.sdk.AtmobAdNative;
-import com.atmob.sdk.AtmobAdSdk;
+import com.atmob.mediation.api.AdConstants;
+import com.atmob.mediation.api.AdError;
+import com.atmob.mediation.api.ad.AtmobAdLoadCallback;
+import com.atmob.mediation.api.ad.reward.AtmobRewardAd;
+import com.atmob.mediation.api.ad.reward.AtmobRewardAdListener;
 
 import java.util.Map;
 
@@ -20,7 +23,7 @@ public class RewardVideoAdCall {
 
     private static final String TAG = "RewardVideoAdCall";
 
-    public static void loadRewardVideo(Context context, MethodChannel channel, MethodCall call, MethodChannel.Result result) {
+    public static void loadRewardVideo(Activity activity, MethodChannel channel, MethodCall call, MethodChannel.Result result) {
         Map<String, Object> params = call.arguments();
         if (params == null) {
             result.error("params is empty", "params is empty", null);
@@ -30,41 +33,87 @@ public class RewardVideoAdCall {
             result.error("AdFuncId is empty", "AdFuncId is empty", null);
             return;
         }
+        String callbackId = FlutterParamsUtils.getString(params, CommonParams.CallbackId);
         int adFuncId = FlutterParamsUtils.getInt(params, CommonParams.AdFuncId, -1);
         AtmobLog.d(TAG, "loadRewardVideo: adFuncId = " + adFuncId);
-        AtmobAdNative adNative = AtmobAdSdk.getInstance().createAdNative(context);
-        adNative.loadRewardVideo(adFuncId, new RewardVideoListener() {
+        AtmobRewardAd atmobRewardAd = new AtmobRewardAd(activity, String.valueOf(adFuncId));
+        atmobRewardAd.setRewardAdListener(new AtmobRewardAdListener() {
+
+            private long startTime;
+            private boolean isComplete;
+
             @Override
-            public void onRewarded() {
-                AtmobLog.d(TAG, "loadRewardVideo..onRewarded");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onRewarded));
+            public void onRewardAdShow() {
+                AtmobLog.d(TAG, "loadRewardVideo..onRewardAdShow");
+                startTime = System.currentTimeMillis();
+                AtmobAdEventHelper.onAdShow(AdConstants.RewardVideo, atmobRewardAd.getEcpmInfo());
+                AtmobAdEventHelper.onAdPlayStart(atmobRewardAd.getEcpmInfo());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onShow));
+                }
             }
 
             @Override
-            public void onShow() {
-                AtmobLog.d(TAG, "loadRewardVideo..onShow");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onShow));
+            public void onRewardAdShowFail(AdError adError) {
+                AtmobLog.d(TAG, "loadRewardVideo..onRewardAdShowFail: " + adError.toString());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onFail, adError.toString()));
+                }
             }
 
             @Override
-            public void onClose() {
-                AtmobLog.d(TAG, "loadRewardVideo..onClose");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onClose));
-
+            public void onRewardClick() {
+                AtmobLog.d(TAG, "loadRewardVideo..onRewardClick");
+                AtmobAdEventHelper.onAdClick(AdConstants.RewardVideo, atmobRewardAd.getEcpmInfo());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onClick));
+                }
             }
 
             @Override
-            public void onFail(String s) {
-                AtmobLog.d(TAG, "loadRewardVideo..onFail: " + s);
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onFail, s));
+            public void onRewardAdClosed() {
+                AtmobLog.d(TAG, "loadRewardVideo..onRewardAdClosed");
+                long duration = System.currentTimeMillis() - startTime;
+                AtmobAdEventHelper.onAdPlayEnd(atmobRewardAd.getEcpmInfo(), (int) duration, isComplete);
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onClose));
+                }
+            }
 
+            @Override
+            public void onVideoComplete() {
+                AtmobLog.d(TAG, "loadRewardVideo..onVideoComplete");
+                isComplete = true;
             }
 
             @Override
-            public void onClick() {
-                AtmobLog.d(TAG, "loadRewardVideo..onClick");
-                channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createAdMethodParams(String.valueOf(adFuncId), FlutterListenerMethod.onClick));
+            public void onRewardVerify() {
+                AtmobLog.d(TAG, "loadRewardVideo..onRewardVerify");
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onRewarded));
+                }
+            }
+        });
+        atmobRewardAd.loadAd(new AtmobAdLoadCallback() {
+            @Override
+            public void onAdLoaded() {
+                AtmobLog.d(TAG, "loadRewardVideo..onAdLoaded");
+                AtmobAdEventHelper.onAdLoaded(AdConstants.RewardVideo, atmobRewardAd.getEcpmInfo());
+                atmobRewardAd.showRewardAd();
+            }
 
+            @Override
+            public void onLoadFailed(AdError adError) {
+                AtmobLog.d(TAG, "loadRewardVideo..onLoadFailed: " + adError.toString());
+                if (callbackId != null) {
+                    channel.invokeMethod(FlutterAdMethod.flutterAdMethod,
+                            FlutterParamsUtils.createAdMethodParams(callbackId, FlutterListenerMethod.onFail, adError.toString()));
+                }
             }
         });
     }

+ 9 - 26
lib/src/core/flutter_ad_method_channel.dart

@@ -1,10 +1,11 @@
 import 'package:flutter/foundation.dart';
 import 'package:flutter/services.dart';
 import 'package:flutter_ad/src/constants/flutter_method.dart';
+import 'package:uuid/uuid.dart';
+
 import '../config/atmob_ad_config.dart';
-import '../listener/on_ad_event_listener.dart';
 import '../listener/interstitial_ad_listener.dart';
-import '../listener/interstitial_full_ad_listener.dart';
+import '../listener/on_ad_event_listener.dart';
 import '../listener/reward_video_ad_listener.dart';
 import '../utils/flutter_ad_event_listener_method_handler.dart';
 import '../utils/flutter_ad_listener_method_handler.dart';
@@ -47,31 +48,11 @@ class MethodChannelFlutterAd extends FlutterAdPlatform {
       default:
         throw UnsupportedError("Unsupported platform");
     }
-    FlutterAdListenerMethodHandler.setAdListener(adFuncId, listener);
+    String callbackId = const Uuid().v4();
+    FlutterAdListenerMethodHandler.setAdListener(callbackId, listener);
     methodChannel.invokeMethod(FlutterAdMethod.loadInterstitial, {
       "adFuncId": adFuncId,
-    });
-  }
-
-  @override
-  void loadInterstitialFull(
-      {required String androidAdFuncId,
-      required String iosAdFuncId,
-      InterstitialFullAdListener? listener}) {
-    String adFuncId;
-    switch (defaultTargetPlatform) {
-      case TargetPlatform.android:
-        adFuncId = androidAdFuncId;
-        break;
-      case TargetPlatform.iOS:
-        adFuncId = iosAdFuncId;
-        break;
-      default:
-        throw UnsupportedError("Unsupported platform");
-    }
-    FlutterAdListenerMethodHandler.setAdListener(adFuncId, listener);
-    methodChannel.invokeMethod(FlutterAdMethod.loadInterstitialFull, {
-      "adFuncId": adFuncId,
+      "callbackId": callbackId,
     });
   }
 
@@ -91,9 +72,11 @@ class MethodChannelFlutterAd extends FlutterAdPlatform {
       default:
         throw UnsupportedError("Unsupported platform");
     }
-    FlutterAdListenerMethodHandler.setAdListener(adFuncId, listener);
+    String callbackId = const Uuid().v4();
+    FlutterAdListenerMethodHandler.setAdListener(callbackId, listener);
     methodChannel.invokeMethod(FlutterAdMethod.loadRewardVideo, {
       "adFuncId": adFuncId,
+      "callbackId": callbackId,
     });
   }
 }

+ 0 - 8
lib/src/core/flutter_ad_platform.dart

@@ -43,14 +43,6 @@ abstract class FlutterAdPlatform extends PlatformInterface {
     throw UnimplementedError('loadInterstitial() has not been implemented.');
   }
 
-  void loadInterstitialFull(
-      {required String androidAdFuncId,
-      required String iosAdFuncId,
-      InterstitialFullAdListener? listener}) {
-    throw UnimplementedError(
-        'loadInterstitialFull() has not been implemented.');
-  }
-
   void loadRewardVideo(
       {required String androidAdFuncId,
       required String iosAdFuncId,

+ 0 - 10
lib/src/core/flutter_atmob_ad.dart

@@ -28,16 +28,6 @@ class FlutterAtmobAd {
         listener: listener);
   }
 
-  static void loadInterstitialFull(
-      {required String androidAdFuncId,
-      required String iosAdFuncId,
-      InterstitialFullAdListener? listener}) {
-    FlutterAdPlatform.instance.loadInterstitialFull(
-        androidAdFuncId: androidAdFuncId,
-        iosAdFuncId: iosAdFuncId,
-        listener: listener);
-  }
-
   static void loadRewardVideo(
       {required String androidAdFuncId,
       required String iosAdFuncId,

+ 7 - 7
lib/src/utils/flutter_ad_listener_method_handler.dart

@@ -11,11 +11,11 @@ class FlutterAdListenerMethodHandler {
 
   static final Map<String, AtmobAdListener> _adListenerMap = {};
 
-  static setAdListener(String adFuncId, AtmobAdListener? listener) {
+  static setAdListener(String callbackId, AtmobAdListener? listener) {
     if (listener == null) {
       return;
     }
-    _adListenerMap[adFuncId] = listener;
+    _adListenerMap[callbackId] = listener;
   }
 
   static void setMethodChannel(MethodChannel channel) {
@@ -26,10 +26,10 @@ class FlutterAdListenerMethodHandler {
 
   static Future<dynamic> _platformCallHandler(MethodCall call) async {
     debugPrint(
-        "FlutterAdListenerMethodChannelHelper:method= ${call.method}, adFuncId= ${call.arguments["adFuncId"]}");
+        "FlutterAdListenerMethodChannelHelper:method= ${call.method}, callbackId= ${call.arguments["callbackId"]}");
     if (call.method == FlutterAdMethod.flutterAdMethod) {
-      final String adFuncId = call.arguments["adFuncId"];
-      final AtmobAdListener? listener = _adListenerMap[adFuncId];
+      final String callbackId = call.arguments["callbackId"];
+      final AtmobAdListener? listener = _adListenerMap[callbackId];
       if (listener == null) {
         return;
       }
@@ -39,14 +39,14 @@ class FlutterAdListenerMethodHandler {
           break;
         case FlutterListenerMethod.onFail:
           listener.onFail(call.arguments["failMsg"]);
-          _adListenerMap.remove(adFuncId);
+          _adListenerMap.remove(callbackId);
           break;
         case FlutterListenerMethod.onClick:
           listener.onClick();
           break;
         case FlutterListenerMethod.onClose:
           listener.onClose();
-          _adListenerMap.remove(adFuncId);
+          _adListenerMap.remove(callbackId);
           break;
         case FlutterListenerMethod.onRewarded:
           if (listener is RewardVideoAdListener) listener.onRewarded();

+ 3 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: flutter_ad
 description: "国内广告插件"
-version: 0.0.2
+version: 0.0.3
 homepage: http://git.atmob.com/Atmob-Flutter/flutter_atmob_ad
 
 environment:
@@ -12,6 +12,8 @@ dependencies:
     sdk: flutter
   plugin_platform_interface: ^2.0.2
 
+  uuid: 4.5.1
+
 dev_dependencies:
   flutter_test:
     sdk: flutter