|
|
@@ -24,49 +24,42 @@ public class InterstitialAdCall {
|
|
|
|
|
|
public static void loadInterstitial(Context context, MethodChannel channel, MethodCall call, MethodChannel.Result result) {
|
|
|
Map<String, Object> params = call.arguments();
|
|
|
- String adFuncId = null;
|
|
|
- if (params != null && params.containsKey(CommonParams.AdFuncId)) {
|
|
|
- adFuncId = (String) params.get(CommonParams.AdFuncId);
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(adFuncId)) {
|
|
|
- result.error("AdFuncId is empty", "AdFuncId is empty", null);
|
|
|
+ if (params == null) {
|
|
|
+ result.error("params is empty", "params is empty", null);
|
|
|
return;
|
|
|
}
|
|
|
- int intAdFuncId;
|
|
|
- try {
|
|
|
- intAdFuncId = Integer.parseInt(adFuncId);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- result.error("AdFuncId is not a number", "AdFuncId is not a number", null);
|
|
|
+ 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, "loadInterstitial: adFuncId = " + adFuncId);
|
|
|
AtmobAdNative adNative = AtmobAdSdk.getInstance().createAdNative(context);
|
|
|
- String finalAdFuncId = adFuncId;
|
|
|
- adNative.loadInterstitial(intAdFuncId, new InterstitialListener() {
|
|
|
+ adNative.loadInterstitial(adFuncId, new InterstitialListener() {
|
|
|
@Override
|
|
|
public void onShow() {
|
|
|
AtmobLog.d(TAG, "loadInterstitial..onShow");
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onShow));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onShow));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onClose() {
|
|
|
AtmobLog.d(TAG, "loadInterstitial..onClose");
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onClose));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onClose));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFail(String s) {
|
|
|
AtmobLog.d(TAG, "loadInterstitial..onFail: " + s);
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onFail, s));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onFail, s));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onClick() {
|
|
|
AtmobLog.d(TAG, "loadInterstitial..onClick");
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onClick));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onClick));
|
|
|
|
|
|
}
|
|
|
});
|
|
|
@@ -74,49 +67,42 @@ public class InterstitialAdCall {
|
|
|
|
|
|
public static void loadInterstitialFull(Context context, MethodChannel channel, MethodCall call, MethodChannel.Result result) {
|
|
|
Map<String, Object> params = call.arguments();
|
|
|
- String adFuncId = null;
|
|
|
- if (params != null && params.containsKey(CommonParams.AdFuncId)) {
|
|
|
- adFuncId = (String) params.get(CommonParams.AdFuncId);
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(adFuncId)) {
|
|
|
- result.error("AdFuncId is empty", "AdFuncId is empty", null);
|
|
|
+ if (params == null) {
|
|
|
+ result.error("params is empty", "params is empty", null);
|
|
|
return;
|
|
|
}
|
|
|
- int intAdFuncId;
|
|
|
- try {
|
|
|
- intAdFuncId = Integer.parseInt(adFuncId);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- result.error("AdFuncId is not a number", "AdFuncId is not a number", null);
|
|
|
+ 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);
|
|
|
- String finalAdFuncId = adFuncId;
|
|
|
- adNative.loadInterstitialFull(intAdFuncId, new InterstitialFullListener() {
|
|
|
+ adNative.loadInterstitialFull(adFuncId, new InterstitialFullListener() {
|
|
|
@Override
|
|
|
public void onShow() {
|
|
|
AtmobLog.d(TAG, "loadInterstitialFull..onShow");
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onShow));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onShow));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onClose() {
|
|
|
AtmobLog.d(TAG, "loadInterstitialFull..onClose");
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onClose));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onClose));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onFail(String s) {
|
|
|
AtmobLog.d(TAG, "loadInterstitialFull..onFail: " + s);
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onFail, s));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onFail, s));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onClick() {
|
|
|
AtmobLog.d(TAG, "loadInterstitialFull..onClick");
|
|
|
- channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(finalAdFuncId, FlutterListenerMethod.onClick));
|
|
|
+ channel.invokeMethod(FlutterAdMethod.flutterAdMethod, FlutterParamsUtils.createCommonParams(String.valueOf(adFuncId), FlutterListenerMethod.onClick));
|
|
|
}
|
|
|
});
|
|
|
}
|