Skip to content

Commit

Permalink
chore(fmt): update to use prettier-plugin-java
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlabo committed Dec 4, 2024
1 parent 07d68c0 commit 82c7cbe
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,18 @@ public void hideBanner(final PluginCall call) {
try {
activitySupplier
.get()
.runOnUiThread(
() -> {
if (mAdViewLayout != null) {
mAdViewLayout.setVisibility(View.GONE);
mAdView.pause();
.runOnUiThread(() -> {
if (mAdViewLayout != null) {
mAdViewLayout.setVisibility(View.GONE);
mAdView.pause();

final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);

notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);

call.resolve();
}
call.resolve();
}
);
});
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
Expand All @@ -163,19 +161,17 @@ public void resumeBanner(final PluginCall call) {
try {
activitySupplier
.get()
.runOnUiThread(
() -> {
if (mAdViewLayout != null && mAdView != null) {
mAdViewLayout.setVisibility(View.VISIBLE);
mAdView.resume();
.runOnUiThread(() -> {
if (mAdViewLayout != null && mAdView != null) {
mAdViewLayout.setVisibility(View.VISIBLE);
mAdView.resume();

final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);
notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);
notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);

Log.d(logTag, "Banner AD Resumed");
}
Log.d(logTag, "Banner AD Resumed");
}
);
});

call.resolve();
} catch (Exception ex) {
Expand All @@ -188,19 +184,17 @@ public void removeBanner(final PluginCall call) {
if (mAdView != null) {
activitySupplier
.get()
.runOnUiThread(
() -> {
if (mAdView != null) {
mViewGroup.removeView(mAdViewLayout);
mAdViewLayout.removeView(mAdView);
mAdView.destroy();
mAdView = null;
Log.d(logTag, "Banner AD Removed");
final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
}
.runOnUiThread(() -> {
if (mAdView != null) {
mViewGroup.removeView(mAdViewLayout);
mAdViewLayout.removeView(mAdView);
mAdView.destroy();
mAdView = null;
Log.d(logTag, "Banner AD Removed");
final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
}
);
});
}

call.resolve();
Expand All @@ -212,12 +206,10 @@ public void removeBanner(final PluginCall call) {
private void updateExistingAdView(AdOptions adOptions) {
activitySupplier
.get()
.runOnUiThread(
() -> {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
mAdView.loadAd(adRequest);
}
);
.runOnUiThread(() -> {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
mAdView.loadAd(adRequest);
});
}

/**
Expand All @@ -228,67 +220,65 @@ private void createNewAdView(AdOptions adOptions) {
// Run AdMob In Main UI Thread
activitySupplier
.get()
.runOnUiThread(
() -> {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
// Assign the correct id needed
AdViewIdHelper.assignIdToAdView(mAdView, adOptions, adRequest, logTag, contextSupplier.get());
// Add the AdView to the view hierarchy.
mAdViewLayout.addView(mAdView);
// Start loading the ad.
mAdView.loadAd(adRequest);
mAdView.setAdListener(
new AdListener() {
@Override
public void onAdLoaded() {
final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);

notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
notifyListeners(BannerAdPluginEvents.Loaded.getWebEventName(), emptyObject);
super.onAdLoaded();
}
.runOnUiThread(() -> {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
// Assign the correct id needed
AdViewIdHelper.assignIdToAdView(mAdView, adOptions, adRequest, logTag, contextSupplier.get());
// Add the AdView to the view hierarchy.
mAdViewLayout.addView(mAdView);
// Start loading the ad.
mAdView.loadAd(adRequest);
mAdView.setAdListener(
new AdListener() {
@Override
public void onAdLoaded() {
final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(mAdView);

notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
notifyListeners(BannerAdPluginEvents.Loaded.getWebEventName(), emptyObject);
super.onAdLoaded();
}

@Override
public void onAdFailedToLoad(@NonNull LoadAdError adError) {
if (mAdView != null) {
mViewGroup.removeView(mAdViewLayout);
mAdViewLayout.removeView(mAdView);
mAdView.destroy();
mAdView = null;
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError adError) {
if (mAdView != null) {
mViewGroup.removeView(mAdViewLayout);
mAdViewLayout.removeView(mAdView);
mAdView.destroy();
mAdView = null;
}

final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);
final BannerAdSizeInfo sizeInfo = new BannerAdSizeInfo(0, 0);
notifyListeners(BannerAdPluginEvents.SizeChanged.getWebEventName(), sizeInfo);

final AdMobPluginError adMobPluginError = new AdMobPluginError(adError);
notifyListeners(BannerAdPluginEvents.FailedToLoad.getWebEventName(), adMobPluginError);
final AdMobPluginError adMobPluginError = new AdMobPluginError(adError);
notifyListeners(BannerAdPluginEvents.FailedToLoad.getWebEventName(), adMobPluginError);

super.onAdFailedToLoad(adError);
}
super.onAdFailedToLoad(adError);
}

@Override
public void onAdOpened() {
notifyListeners(BannerAdPluginEvents.Opened.getWebEventName(), emptyObject);
super.onAdOpened();
}
@Override
public void onAdOpened() {
notifyListeners(BannerAdPluginEvents.Opened.getWebEventName(), emptyObject);
super.onAdOpened();
}

@Override
public void onAdClosed() {
notifyListeners(BannerAdPluginEvents.Closed.getWebEventName(), emptyObject);
super.onAdClosed();
}
@Override
public void onAdClosed() {
notifyListeners(BannerAdPluginEvents.Closed.getWebEventName(), emptyObject);
super.onAdClosed();
}

@Override
public void onAdImpression() {
notifyListeners(BannerAdPluginEvents.AdImpression.getWebEventName(), emptyObject);
super.onAdImpression();
}
@Override
public void onAdImpression() {
notifyListeners(BannerAdPluginEvents.AdImpression.getWebEventName(), emptyObject);
super.onAdImpression();
}
);
}
);

// Add AdViewLayout top of the WebView
mViewGroup.addView(mAdViewLayout);
}
);
// Add AdViewLayout top of the WebView
mViewGroup.addView(mAdViewLayout);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,22 @@ public void showConsentForm(final PluginCall call, BiConsumer<String, JSObject>
ensureConsentInfo();
activitySupplier
.get()
.runOnUiThread(
() ->
UserMessagingPlatform.loadConsentForm(
contextSupplier.get(),
consentForm ->
consentForm.show(
activitySupplier.get(),
formError -> {
if (formError != null) {
call.reject("Error when show consent form", formError.getMessage());
} else {
JSObject consentFormInfo = new JSObject();
consentFormInfo.put("status", getConsentStatusString(consentInformation.getConsentStatus()));

call.resolve(consentFormInfo);
}
}
),
formError -> call.reject("Error when show consent form", formError.getMessage())
)
.runOnUiThread(() ->
UserMessagingPlatform.loadConsentForm(
contextSupplier.get(),
consentForm ->
consentForm.show(activitySupplier.get(), formError -> {
if (formError != null) {
call.reject("Error when show consent form", formError.getMessage());
} else {
JSObject consentFormInfo = new JSObject();
consentFormInfo.put("status", getConsentStatusString(consentInformation.getConsentStatus()));

call.resolve(consentFormInfo);
}
}),
formError -> call.reject("Error when show consent form", formError.getMessage())
)
);
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@ public void prepareInterstitial(final PluginCall call, BiConsumer<String, JSObje
try {
activitySupplier
.get()
.runOnUiThread(
() -> {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
InterstitialAd.load(
activitySupplier.get(),
id,
adRequest,
adCallbackAndListeners.getInterstitialAdLoadCallback(call, notifyListenersFunction)
);
}
);
.runOnUiThread(() -> {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
InterstitialAd.load(
activitySupplier.get(),
id,
adRequest,
adCallbackAndListeners.getInterstitialAdLoadCallback(call, notifyListenersFunction)
);
});
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
Expand All @@ -66,15 +64,13 @@ public void showInterstitial(final PluginCall call, BiConsumer<String, JSObject>

activitySupplier
.get()
.runOnUiThread(
() -> {
try {
interstitialAd.show(activitySupplier.get());
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
.runOnUiThread(() -> {
try {
interstitialAd.show(activitySupplier.get());
call.resolve();
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@ public void prepareRewardVideoAd(final PluginCall call, BiConsumer<String, JSObj

activitySupplier
.get()
.runOnUiThread(
() -> {
try {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
RewardedAd.load(
contextSupplier.get(),
id,
adRequest,
RewardedAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(call, notifyListenersFunction, adOptions)
);
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
.runOnUiThread(() -> {
try {
final AdRequest adRequest = RequestHelper.createRequest(adOptions);
final String id = AdViewIdHelper.getFinalAdId(adOptions, adRequest, logTag, contextSupplier.get());
RewardedAd.load(
contextSupplier.get(),
id,
adRequest,
RewardedAdCallbackAndListeners.INSTANCE.getRewardedAdLoadCallback(call, notifyListenersFunction, adOptions)
);
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
);
});
}

@PluginMethod
Expand All @@ -65,14 +63,12 @@ public void showRewardVideoAd(final PluginCall call, BiConsumer<String, JSObject
try {
activitySupplier
.get()
.runOnUiThread(
() -> {
mRewardedAd.show(
activitySupplier.get(),
RewardedAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
);
}
);
.runOnUiThread(() -> {
mRewardedAd.show(
activitySupplier.get(),
RewardedAdCallbackAndListeners.INSTANCE.getOnUserEarnedRewardListener(call, notifyListenersFunction)
);
});
} catch (Exception ex) {
call.reject(ex.getLocalizedMessage(), ex);
}
Expand Down
Loading

0 comments on commit 82c7cbe

Please sign in to comment.