Weather Tracker v1.0.0版本的 MD5 值为:3edef27647e42a8ea0e7c0d2dbf56f97
以下内容为反编译后的 MRAIDAdPresenter.java 源代码,内容仅作参考
package com.vungle.warren.ui.presenter;
import android.content.ActivityNotFoundException;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import android.webkit.WebView;
import android.webkit.WebViewRenderProcess;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import com.fyber.inneractive.sdk.external.InneractiveMediationDefs;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.vungle.warren.ClickCoordinateTracker;
import com.vungle.warren.SessionTracker;
import com.vungle.warren.VungleLogger;
import com.vungle.warren.analytics.AdAnalytics;
import com.vungle.warren.error.VungleException;
import com.vungle.warren.model.Advertisement;
import com.vungle.warren.model.Cookie;
import com.vungle.warren.model.JsonUtil;
import com.vungle.warren.model.Placement;
import com.vungle.warren.model.Report;
import com.vungle.warren.model.ReportDBAdapter;
import com.vungle.warren.model.SessionData;
import com.vungle.warren.model.token.Gdpr;
import com.vungle.warren.omsdk.OMTracker;
import com.vungle.warren.persistence.Repository;
import com.vungle.warren.session.SessionAttribute;
import com.vungle.warren.session.SessionEvent;
import com.vungle.warren.ui.DurationRecorder;
import com.vungle.warren.ui.JavascriptBridge;
import com.vungle.warren.ui.PresenterAdOpenCallback;
import com.vungle.warren.ui.PresenterAppLeftCallback;
import com.vungle.warren.ui.contract.AdContract;
import com.vungle.warren.ui.contract.WebAdContract;
import com.vungle.warren.ui.state.OptionsState;
import com.vungle.warren.ui.view.WebViewAPI;
import com.vungle.warren.utility.AsyncFileUtils;
import com.vungle.warren.utility.Constants;
import com.vungle.warren.utility.Scheduler;
import com.vungle.warren.utility.ThreadUtil;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
public class MRAIDAdPresenter implements WebAdContract.WebAdPresenter, WebViewAPI.MRAIDDelegate, WebViewAPI.WebClientErrorHandler {
private static final String ACTION = "action";
private static final String ACTION_WITH_VALUE = "actionWithValue";
private static final String CLOSE = "close";
private static final String CONSENT_ACTION = "consentAction";
private static final String ERROR = "error";
private static final String EXTRA_INCENTIVIZED_SENT = "incentivized_sent";
private static final String EXTRA_REPORT = "saved_report";
private static final String OPEN = "open";
private static final String OPEN_DEEPLINK_SUCCESS = "deeplinkSuccess";
private static final String OPEN_NON_MRAID = "openNonMraid";
private static final String OPEN_PRIVACY = "openPrivacy";
private static final String SET_ORIENTATION_PROPERTIES = "setOrientationProperties";
private static final String SUCCESSFUL_VIEW = "successfulView";
private static final String TAG = "com.vungle.warren.ui.presenter.MRAIDAdPresenter";
private static final String TPAT = "tpat";
private static final String USE_CUSTOM_CLOSE = "useCustomClose";
private static final String USE_CUSTOM_PRIVACY = "useCustomPrivacy";
private static final String VIDEO_VIEWED = "videoViewed";
private WebAdContract.WebAdView adView;
private boolean adViewed;
private Advertisement advertisement;
private final AdAnalytics analytics;
private File assetDir;
private boolean backEnabled;
private AdContract.AdvertisementPresenter.EventListener bus;
private ClickCoordinateTracker clickCoordinateTracker;
private long duration;
private DurationRecorder durationRecorder;
private AsyncFileUtils.ExistenceOperation fileExistenceOperation;
@Nullable
private final String[] impressionUrls;
private final OMTracker omTracker;
@NonNull
private final Placement placement;
private Report report;
private Repository repository;
private final Scheduler scheduler;
private WebViewAPI webClient;
private Map<String, Cookie> cookieMap = new HashMap();
private AtomicBoolean sendReportIncentivized = new AtomicBoolean(false);
private AtomicBoolean isDestroying = new AtomicBoolean(false);
private Repository.SaveCallback repoCallback = new Repository.SaveCallback() {
boolean errorHappened = false;
@Override
public void onError(Exception exc) {
if (this.errorHappened) {
return;
}
this.errorHappened = true;
VungleException vungleException = new VungleException(26);
MRAIDAdPresenter.this.makeBusError(vungleException);
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName(), vungleException.getLocalizedMessage());
MRAIDAdPresenter.this.closeView();
}
@Override
public void onSaved() {
}
};
public MRAIDAdPresenter(@NonNull Advertisement advertisement, @NonNull Placement placement, @NonNull Repository repository, @NonNull Scheduler scheduler, @NonNull AdAnalytics adAnalytics, @NonNull WebViewAPI webViewAPI, @Nullable OptionsState optionsState, @NonNull File file, @NonNull OMTracker oMTracker, @Nullable String[] strArr) {
this.advertisement = advertisement;
this.repository = repository;
this.placement = placement;
this.scheduler = scheduler;
this.analytics = adAnalytics;
this.webClient = webViewAPI;
this.assetDir = file;
this.omTracker = oMTracker;
this.impressionUrls = strArr;
loadData(optionsState);
if (advertisement.isClickCoordinatesTrackingEnabled()) {
this.clickCoordinateTracker = new ClickCoordinateTracker(advertisement, adAnalytics);
}
}
public void closeView() {
this.adView.close();
this.scheduler.cancelAll();
}
private void download() {
reportAction("cta", "");
try {
this.analytics.ping(new String[]{this.advertisement.getCTAURL(true)});
this.adView.open(this.advertisement.getDeeplinkUrl(), this.advertisement.getCTAURL(false), new PresenterAppLeftCallback(this.bus, this.placement), new PresenterAdOpenCallback() {
@Override
public void onAdOpenType(PresenterAdOpenCallback.AdOpenType adOpenType) {
if (adOpenType == PresenterAdOpenCallback.AdOpenType.DEEP_LINK) {
MRAIDAdPresenter.this.reportAction(MRAIDAdPresenter.OPEN_DEEPLINK_SUCCESS, null);
}
}
});
} catch (ActivityNotFoundException unused) {
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName() + "#download", "Download - Activity Not Found");
}
}
public void handleWebViewException(@NonNull VungleException vungleException) {
WebAdContract.WebAdView webAdView = this.adView;
if (webAdView != null) {
webAdView.removeWebView();
}
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName() + "#handleWebViewException", "WebViewException: " + vungleException.getLocalizedMessage());
reportErrorAndCloseAd(vungleException);
}
private void loadData(OptionsState optionsState) {
this.cookieMap.put(Cookie.INCENTIVIZED_TEXT_COOKIE, this.repository.load(Cookie.INCENTIVIZED_TEXT_COOKIE, Cookie.class).get());
this.cookieMap.put(Cookie.CONSENT_COOKIE, this.repository.load(Cookie.CONSENT_COOKIE, Cookie.class).get());
this.cookieMap.put(Cookie.CONFIG_COOKIE, this.repository.load(Cookie.CONFIG_COOKIE, Cookie.class).get());
if (optionsState != null) {
String string = optionsState.getString(EXTRA_REPORT);
Report report = TextUtils.isEmpty(string) ? null : (Report) this.repository.load(string, Report.class).get();
if (report != null) {
this.report = report;
}
}
}
private void loadMraid(@NonNull File file) {
File file2 = new File(file.getParent());
final File file3 = new File(file2.getPath() + File.separator + "index.html");
this.fileExistenceOperation = AsyncFileUtils.isFileExistAsync(file3, new AsyncFileUtils.FileExistCallback() {
@Override
public void status(boolean z) {
if (!z) {
MRAIDAdPresenter.this.makeBusError(new VungleException(27));
MRAIDAdPresenter.this.makeBusError(new VungleException(10));
MRAIDAdPresenter.this.adView.close();
return;
}
WebAdContract.WebAdView webAdView = MRAIDAdPresenter.this.adView;
webAdView.showWebsite(Advertisement.FILE_SCHEME + file3.getPath());
MRAIDAdPresenter.this.recordPlayRemoteUrl();
}
});
}
public void makeBusError(@NonNull VungleException vungleException) {
AdContract.AdvertisementPresenter.EventListener eventListener = this.bus;
if (eventListener != null) {
eventListener.onError(vungleException, this.placement.getId());
}
}
private void prepare(@Nullable OptionsState optionsState) {
this.webClient.setMRAIDDelegate(this);
this.webClient.setErrorHandler(this);
loadMraid(new File(this.assetDir.getPath() + File.separator + "template"));
Cookie cookie = this.cookieMap.get(Cookie.INCENTIVIZED_TEXT_COOKIE);
if (cookie != null) {
this.advertisement.setIncentivizedText(cookie.getString(CampaignEx.JSON_KEY_TITLE), cookie.getString("body"), cookie.getString("continue"), cookie.getString("close"));
}
String string = cookie == null ? null : cookie.getString("userID");
boolean z = false;
if (this.report == null) {
Report report = new Report(this.advertisement, this.placement, System.currentTimeMillis(), string);
this.report = report;
report.setTtDownload(this.advertisement.getTtDownload());
this.repository.save(this.report, this.repoCallback, false);
}
if (this.durationRecorder == null) {
this.durationRecorder = new DurationRecorder(this.report, this.repository, this.repoCallback);
}
Cookie cookie2 = this.cookieMap.get(Cookie.CONSENT_COOKIE);
if (cookie2 != null) {
if (cookie2.getBoolean("is_country_data_protected").booleanValue() && "unknown".equals(cookie2.getString("consent_status"))) {
z = true;
}
this.webClient.setConsentStatus(z, cookie2.getString("consent_title"), cookie2.getString("consent_message"), cookie2.getString("button_accept"), cookie2.getString("button_deny"));
if (z) {
cookie2.putValue("consent_status", Gdpr.OPTED_OUT_BY_TIMEOUT);
cookie2.putValue("timestamp", Long.valueOf(System.currentTimeMillis() / 1000));
cookie2.putValue("consent_source", "vungle_modal");
this.repository.save(cookie2, this.repoCallback);
}
}
int showCloseDelay = this.advertisement.getShowCloseDelay(this.placement.isIncentivized());
if (showCloseDelay > 0) {
this.scheduler.schedule(new Runnable() {
@Override
public void run() {
MRAIDAdPresenter.this.backEnabled = true;
}
}, showCloseDelay);
} else {
this.backEnabled = true;
}
this.adView.updateWindow();
AdContract.AdvertisementPresenter.EventListener eventListener = this.bus;
if (eventListener != null) {
eventListener.onNext("start", null, this.placement.getId());
}
}
private void recordMraidError(String str) {
if (this.report == null || TextUtils.isEmpty(str)) {
return;
}
this.report.recordError(str);
this.repository.save(this.report, this.repoCallback);
}
public void recordPlayRemoteUrl() {
Report report;
Advertisement advertisement = (Advertisement) this.repository.load(this.advertisement.getId(), Advertisement.class).get();
if (advertisement == null || (report = this.report) == null) {
return;
}
report.setAllAssetDownloaded(advertisement.assetsFullyDownloaded);
this.repository.save(this.report, this.repoCallback, false);
}
private void reportErrorAndCloseAd(@NonNull VungleException vungleException) {
makeBusError(vungleException);
closeView();
}
@Override
public void detach(@AdContract.AdStopReason int i) {
AsyncFileUtils.ExistenceOperation existenceOperation = this.fileExistenceOperation;
if (existenceOperation != null) {
existenceOperation.cancel();
}
stop(i);
this.webClient.setWebViewObserver(null);
this.adView.destroyAdView(this.omTracker.stop());
}
@Override
public void generateSaveState(@Nullable OptionsState optionsState) {
if (optionsState == null) {
return;
}
this.repository.save(this.report, this.repoCallback);
optionsState.put(EXTRA_REPORT, this.report.getId());
optionsState.put(EXTRA_INCENTIVIZED_SENT, this.sendReportIncentivized.get());
}
@Override
public boolean handleExit() {
if (this.backEnabled) {
this.adView.showWebsite("javascript:window.vungle.mraidBridgeExt.requestMRAIDClose()");
return false;
}
return false;
}
@Override
public void onMraidAction(@NonNull String str) {
str.hashCode();
char c = 65535;
switch (str.hashCode()) {
case -314498168:
if (str.equals(JavascriptBridge.MraidHandler.PRIVACY_ACTION)) {
c = 0;
break;
}
break;
case 94756344:
if (str.equals("close")) {
c = 1;
break;
}
break;
case 1427818632:
if (str.equals(JavascriptBridge.MraidHandler.DOWNLOAD_ACTION)) {
c = 2;
break;
}
break;
}
switch (c) {
case 0:
return;
case 1:
closeView();
return;
case 2:
download();
return;
default:
throw new IllegalArgumentException("Unknown action " + str);
}
}
@Override
public void onReceivedError(String str, boolean z) {
recordMraidError(str);
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName() + "#onReceivedError", str);
if (z) {
reportErrorAndCloseAd(new VungleException(38));
}
}
@Override
public void onRenderProcessUnresponsive(@NonNull WebView webView, @Nullable WebViewRenderProcess webViewRenderProcess) {
VungleException vungleException = new VungleException(32);
handleWebViewException(vungleException);
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName() + "#onRenderProcessUnresponsive", vungleException.getLocalizedMessage());
}
@Override
public void onViewConfigurationChanged() {
this.adView.updateWindow();
this.webClient.notifyPropertiesChange(true);
}
@Override
public void onViewTouched(MotionEvent motionEvent) {
ClickCoordinateTracker clickCoordinateTracker = this.clickCoordinateTracker;
if (clickCoordinateTracker != null) {
clickCoordinateTracker.trackCoordinate(motionEvent);
}
}
@Override
public boolean onWebRenderingProcessGone(WebView webView, boolean z) {
handleWebViewException(new VungleException(31));
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName() + "onWebRenderingProcessGone", new VungleException(31).getLocalizedMessage());
return true;
}
@Override
public boolean processCommand(@NonNull String str, @NonNull JsonObject jsonObject) {
char c;
float f;
char c2;
char c3;
Handler handler = new Handler(Looper.getMainLooper());
str.hashCode();
switch (str.hashCode()) {
case -1912374177:
if (str.equals(SUCCESSFUL_VIEW)) {
c = 0;
break;
}
c = 65535;
break;
case -1422950858:
if (str.equals(ACTION)) {
c = 1;
break;
}
c = 65535;
break;
case -735200587:
if (str.equals(ACTION_WITH_VALUE)) {
c = 2;
break;
}
c = 65535;
break;
case -660787472:
if (str.equals(CONSENT_ACTION)) {
c = 3;
break;
}
c = 65535;
break;
case -511324706:
if (str.equals(OPEN_PRIVACY)) {
c = 4;
break;
}
c = 65535;
break;
case -418575596:
if (str.equals(OPEN_NON_MRAID)) {
c = 5;
break;
}
c = 65535;
break;
case -348095344:
if (str.equals(USE_CUSTOM_PRIVACY)) {
c = 6;
break;
}
c = 65535;
break;
case 3417674:
if (str.equals("open")) {
c = 7;
break;
}
c = 65535;
break;
case 3566511:
if (str.equals(TPAT)) {
c = '\b';
break;
}
c = 65535;
break;
case 94756344:
if (str.equals("close")) {
c = '\t';
break;
}
c = 65535;
break;
case 96784904:
if (str.equals("error")) {
c = '\n';
break;
}
c = 65535;
break;
case 133423073:
if (str.equals(SET_ORIENTATION_PROPERTIES)) {
c = 11;
break;
}
c = 65535;
break;
case 1614272768:
if (str.equals(USE_CUSTOM_CLOSE)) {
c = '\f';
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
switch (c) {
case 0:
AdContract.AdvertisementPresenter.EventListener eventListener = this.bus;
if (eventListener != null) {
eventListener.onNext(SUCCESSFUL_VIEW, null, this.placement.getId());
}
Cookie cookie = this.cookieMap.get(Cookie.CONFIG_COOKIE);
if (this.placement.isIncentivized() && cookie != null && cookie.getBoolean("isReportIncentivizedEnabled").booleanValue() && !this.sendReportIncentivized.getAndSet(true)) {
JsonObject jsonObject2 = new JsonObject();
jsonObject2.add("placement_reference_id", new JsonPrimitive(this.placement.getId()));
jsonObject2.add("app_id", new JsonPrimitive(this.advertisement.getAppID()));
jsonObject2.add(ReportDBAdapter.ReportColumns.COLUMN_AD_START_TIME, new JsonPrimitive(Long.valueOf(this.report.getAdStartTime())));
jsonObject2.add("user", new JsonPrimitive(this.report.getUserID()));
this.analytics.ri(jsonObject2);
}
return true;
case 1:
break;
case 2:
String asString = jsonObject.get(NotificationCompat.CATEGORY_EVENT).getAsString();
String asString2 = jsonObject.get(AppMeasurementSdk.ConditionalUserProperty.VALUE).getAsString();
this.report.recordAction(asString, asString2, System.currentTimeMillis());
this.repository.save(this.report, this.repoCallback);
if (asString.equals("videoViewed")) {
try {
f = Float.parseFloat(asString2);
} catch (NumberFormatException unused) {
Log.e(TAG, "value for videoViewed is null !");
f = 0.0f;
}
AdContract.AdvertisementPresenter.EventListener eventListener2 = this.bus;
if (eventListener2 != null && f > 0.0f && !this.adViewed) {
this.adViewed = true;
eventListener2.onNext("adViewed", null, this.placement.getId());
String[] strArr = this.impressionUrls;
if (strArr != null) {
this.analytics.ping(strArr);
}
}
if (this.duration > 0) {
this.durationRecorder.update();
}
}
if (asString.equals("videoLength")) {
this.duration = Long.parseLong(asString2);
reportAction("videoLength", asString2);
handler.post(new Runnable() {
@Override
public void run() {
MRAIDAdPresenter.this.webClient.notifyPropertiesChange(true);
}
});
}
handler.post(new Runnable() {
@Override
public void run() {
MRAIDAdPresenter.this.adView.setVisibility(true);
}
});
break;
case 3:
Cookie cookie2 = this.cookieMap.get(Cookie.CONSENT_COOKIE);
if (cookie2 == null) {
cookie2 = new Cookie(Cookie.CONSENT_COOKIE);
}
cookie2.putValue("consent_status", jsonObject.get(NotificationCompat.CATEGORY_EVENT).getAsString());
cookie2.putValue("consent_source", "vungle_modal");
cookie2.putValue("timestamp", Long.valueOf(System.currentTimeMillis() / 1000));
this.repository.save(cookie2, this.repoCallback);
return true;
case 4:
this.adView.open(null, jsonObject.get("url").getAsString(), new PresenterAppLeftCallback(this.bus, this.placement), null);
return true;
case 5:
case 7:
reportAction(JavascriptBridge.MraidHandler.DOWNLOAD_ACTION, null);
if ("open".equalsIgnoreCase(str)) {
reportAction("mraidOpen", null);
} else {
reportAction("nonMraidOpen", null);
}
String deeplinkUrl = this.advertisement.getDeeplinkUrl();
String asString3 = jsonObject.get("url").getAsString();
if ((deeplinkUrl != null && !deeplinkUrl.isEmpty()) || (asString3 != null && !asString3.isEmpty())) {
this.adView.open(deeplinkUrl, asString3, new PresenterAppLeftCallback(this.bus, this.placement), new PresenterAdOpenCallback() {
@Override
public void onAdOpenType(PresenterAdOpenCallback.AdOpenType adOpenType) {
if (adOpenType == PresenterAdOpenCallback.AdOpenType.DEEP_LINK) {
MRAIDAdPresenter.this.reportAction(MRAIDAdPresenter.OPEN_DEEPLINK_SUCCESS, null);
}
}
});
} else {
Log.e(TAG, "CTA destination URL is not configured properly");
}
AdContract.AdvertisementPresenter.EventListener eventListener3 = this.bus;
if (eventListener3 != null) {
eventListener3.onNext("open", "adClick", this.placement.getId());
}
return true;
case 6:
String asString4 = jsonObject.get(USE_CUSTOM_PRIVACY).getAsString();
asString4.hashCode();
switch (asString4.hashCode()) {
case 3178655:
if (asString4.equals("gone")) {
c2 = 0;
break;
}
c2 = 65535;
break;
case 3569038:
if (asString4.equals(InneractiveMediationDefs.SHOW_HOUSE_AD_YES)) {
c2 = 1;
break;
}
c2 = 65535;
break;
case 97196323:
if (asString4.equals("false")) {
c2 = 2;
break;
}
c2 = 65535;
break;
default:
c2 = 65535;
break;
}
switch (c2) {
case 0:
case 1:
case 2:
return true;
default:
throw new IllegalArgumentException("Unknown value " + asString4);
}
case '\b':
this.analytics.ping(this.advertisement.getTpatUrls(jsonObject.get(NotificationCompat.CATEGORY_EVENT).getAsString()));
return true;
case '\t':
reportAction("mraidClose", null);
closeView();
return true;
case '\n':
String asString5 = JsonUtil.getAsString(jsonObject, "code", null);
final String format = String.format("%s Creative Id: %s", asString5, this.advertisement.getCreativeId());
Log.e(TAG, "Receive Creative error: " + format);
recordMraidError(asString5);
ThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
MRAIDAdPresenter.this.handleWebViewException(new VungleException(40, format));
}
});
return true;
case 11:
String asString6 = JsonUtil.getAsString(jsonObject, "forceOrientation", null);
if (!TextUtils.isEmpty(asString6)) {
String lowerCase = asString6.toLowerCase();
lowerCase.hashCode();
if (lowerCase.equals("portrait")) {
this.adView.setOrientation(7);
} else if (lowerCase.equals("landscape")) {
this.adView.setOrientation(6);
}
}
return true;
case '\f':
String asString7 = jsonObject.get("sdkCloseButton").getAsString();
asString7.hashCode();
switch (asString7.hashCode()) {
case -1901805651:
if (asString7.equals("invisible")) {
c3 = 0;
break;
}
c3 = 65535;
break;
case 3178655:
if (asString7.equals("gone")) {
c3 = 1;
break;
}
c3 = 65535;
break;
case 466743410:
if (asString7.equals("visible")) {
c3 = 2;
break;
}
c3 = 65535;
break;
default:
c3 = 65535;
break;
}
switch (c3) {
case 0:
case 1:
case 2:
return true;
default:
throw new IllegalArgumentException("Unknown value " + asString7);
}
default:
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName() + "#processCommand", "Unknown MRAID Command");
return true;
}
return true;
}
public void reportAction(@NonNull String str, @Nullable String str2) {
if (str.equals("videoLength")) {
long parseLong = Long.parseLong(str2);
this.duration = parseLong;
this.report.setVideoLength(parseLong);
this.repository.save(this.report, this.repoCallback);
return;
}
this.report.recordAction(str, str2, System.currentTimeMillis());
this.repository.save(this.report, this.repoCallback);
}
@Override
public void restoreFromSave(@Nullable OptionsState optionsState) {
if (optionsState == null) {
return;
}
boolean z = optionsState.getBoolean(EXTRA_INCENTIVIZED_SENT, false);
if (z) {
this.sendReportIncentivized.set(z);
}
if (this.report == null) {
this.adView.close();
VungleLogger.error(MRAIDAdPresenter.class.getSimpleName() + "#restoreFromSave", "The advertisement was not started and cannot be restored.");
}
}
@Override
public void setAdVisibility(boolean z) {
this.webClient.setAdVisibility(z);
if (z) {
this.durationRecorder.start();
} else {
this.durationRecorder.stop();
}
}
@Override
public void setEventListener(@Nullable AdContract.AdvertisementPresenter.EventListener eventListener) {
this.bus = eventListener;
}
@Override
public void start() {
if (!this.adView.hasWebView()) {
reportErrorAndCloseAd(new VungleException(31));
return;
}
this.adView.setImmersiveMode();
this.adView.resumeWeb();
setAdVisibility(true);
}
@Override
public void stop(@AdContract.AdStopReason int i) {
boolean z = (i & 1) != 0;
boolean z2 = (i & 2) != 0;
boolean z3 = (i & 4) != 0;
this.adView.pauseWeb();
setAdVisibility(false);
if (z || !z2 || this.isDestroying.getAndSet(true)) {
return;
}
WebViewAPI webViewAPI = this.webClient;
if (webViewAPI != null) {
webViewAPI.setMRAIDDelegate(null);
}
if (z3) {
reportAction("mraidCloseByApi", null);
}
this.repository.save(this.report, this.repoCallback);
AdContract.AdvertisementPresenter.EventListener eventListener = this.bus;
if (eventListener != null) {
eventListener.onNext("end", this.report.isCTAClicked() ? "isCTAClicked" : null, this.placement.getId());
}
}
@Override
public void attach(@NonNull WebAdContract.WebAdView webAdView, @Nullable OptionsState optionsState) {
this.isDestroying.set(false);
this.adView = webAdView;
webAdView.setPresenter(this);
AdContract.AdvertisementPresenter.EventListener eventListener = this.bus;
if (eventListener != null) {
eventListener.onNext(Constants.ATTACH, this.advertisement.getCreativeId(), this.placement.getId());
}
this.omTracker.start();
int settings = this.advertisement.getAdConfig().getSettings();
if (settings > 0) {
this.backEnabled = (settings & 2) == 2;
}
int i = -1;
int adOrientation = this.advertisement.getAdConfig().getAdOrientation();
int i2 = 6;
if (adOrientation == 3) {
int orientation = this.advertisement.getOrientation();
if (orientation == 0) {
i = 7;
} else if (orientation == 1) {
i = 6;
}
i2 = i;
} else if (adOrientation == 0) {
i2 = 7;
} else if (adOrientation != 1) {
i2 = 4;
}
Log.d(TAG, "Requested Orientation " + i2);
webAdView.setOrientation(i2);
prepare(optionsState);
SessionTracker.getInstance().trackEvent(new SessionData.Builder().setEvent(SessionEvent.PLAY_AD).addData(SessionAttribute.SUCCESS, true).addData(SessionAttribute.EVENT_ID, this.advertisement.getId()).build());
}
}