use of admob.plus.core.GenericAd in project admob-plus by admob-plus.
the class AdMob method execute.
@Override
public boolean execute(String actionKey, JSONArray args, CallbackContext callbackContext) {
Log.d(TAG, String.format("Execute %s", actionKey));
ExecuteContext ctx = new ExecuteContext(actionKey, args, callbackContext);
switch(actionKey) {
case Actions.READY:
return executeReady(callbackContext);
case Actions.START:
MobileAds.initialize(cordova.getActivity(), status -> {
helper.configForTestLab();
callbackContext.success(new JSONObject(new HashMap<String, Object>() {
{
put("version", MobileAds.getVersionString());
}
}));
});
break;
case Actions.CONFIGURE:
case Actions.CONFIG_REQUEST:
ctx.configure(helper);
break;
case Actions.AD_CREATE:
String adClass = ctx.optString("cls");
if (adClass == null) {
ctx.reject("ad cls is missing");
} else {
GenericAd ad = null;
switch(adClass) {
case "AppOpenAd":
ad = new AppOpen(ctx);
break;
case "BannerAd":
ad = new Banner(ctx);
break;
case "InterstitialAd":
ad = new Interstitial(ctx);
break;
case "NativeAd":
ad = new Native(ctx);
break;
case "RewardedAd":
ad = new Rewarded(ctx);
break;
case "RewardedInterstitialAd":
ad = new RewardedInterstitial(ctx);
break;
}
if (ad != null) {
ctx.resolve();
} else {
ctx.reject("ad cls is not supported");
}
}
break;
case Actions.AD_IS_LOADED:
return executeAdIsLoaded_(ctx);
case Actions.AD_LOAD:
return executeAdLoad(ctx);
case Actions.AD_SHOW:
return executeAdShow(ctx);
case Actions.AD_HIDE:
return executeAdHide(ctx);
case Actions.SET_APP_MUTED:
{
boolean value = args.optBoolean(0);
MobileAds.setAppMuted(value);
callbackContext.success();
break;
}
case Actions.SET_APP_VOLUME:
{
float value = BigDecimal.valueOf(args.optDouble(0)).floatValue();
MobileAds.setAppVolume(value);
callbackContext.success();
break;
}
default:
return false;
}
return true;
}
use of admob.plus.core.GenericAd in project admob-plus by admob-plus.
the class AdMobPlusPlugin method adHide.
@PluginMethod
public void adHide(PluginCall call) {
final ExecuteContext ctx = new ExecuteContext(call);
getBridge().executeOnMainThread(() -> {
GenericAd ad = (GenericAd) ctx.optAdOrError();
if (ad != null) {
ad.hide(ctx);
}
});
}
use of admob.plus.core.GenericAd in project admob-plus by admob-plus.
the class AdMobPlusPlugin method adLoad.
@PluginMethod
public void adLoad(PluginCall call) {
final ExecuteContext ctx = new ExecuteContext(call);
getBridge().executeOnMainThread(() -> {
GenericAd ad = (GenericAd) ctx.optAdOrError();
if (ad != null) {
ad.load(ctx);
}
});
}
use of admob.plus.core.GenericAd in project admob-plus by admob-plus.
the class AdMobPlusRNModule method adShow.
@ReactMethod
public void adShow(ReadableMap opts, Promise promise) {
final ExecuteContext ctx = new ExecuteContext(opts, promise);
new Handler(Looper.getMainLooper()).post(() -> {
GenericAd ad = (GenericAd) ctx.optAdOrError();
if (ad != null) {
if (ad.isLoaded()) {
ad.show(ctx);
} else {
ctx.reject("ad is not loaded");
}
}
});
}
use of admob.plus.core.GenericAd in project admob-plus by admob-plus.
the class AdMobPlusRNModule method adLoad.
@ReactMethod
public void adLoad(ReadableMap opts, Promise promise) {
final ExecuteContext ctx = new ExecuteContext(opts, promise);
new Handler(Looper.getMainLooper()).post(() -> {
GenericAd ad = (GenericAd) ctx.optAdOrError();
if (ad != null) {
ad.load(ctx);
}
});
}
Aggregations