Wolves Themes v1.0版本的 MD5 值为:cddc92b47f6b7c4a195c9625507eb51c
以下内容为反编译后的 MraidActivity.java 源代码,内容仅作参考
package com.mopub.mobileads;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import com.google.android.gms.common.util.CrashUtils;
import com.mopub.common.AdReport;
import com.mopub.common.Constants;
import com.mopub.common.DataKeys;
import com.mopub.common.IntentActions;
import com.mopub.common.VisibleForTesting;
import com.mopub.common.logging.MoPubLog;
import com.mopub.mobileads.BaseInterstitialActivity;
import com.mopub.mobileads.CustomEventInterstitial;
import com.mopub.mraid.MraidController;
import com.mopub.mraid.MraidWebViewClient;
import com.mopub.mraid.MraidWebViewDebugListener;
import com.mopub.mraid.PlacementType;
import com.mopub.network.Networking;
public class MraidActivity extends BaseInterstitialActivity {
@Nullable
private MraidWebViewDebugListener mDebugListener;
@Nullable
private MraidController mMraidController;
@VisibleForTesting
protected static Intent createIntent(@NonNull Context context, @Nullable AdReport adReport, @Nullable String str, long j) {
Intent intent = new Intent(context, MraidActivity.class);
intent.putExtra(DataKeys.HTML_RESPONSE_BODY_KEY, str);
intent.putExtra(DataKeys.BROADCAST_IDENTIFIER_KEY, j);
intent.putExtra(DataKeys.AD_REPORT_KEY, adReport);
intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
return intent;
}
public static void preRenderHtml(@NonNull Context context, @NonNull CustomEventInterstitial.CustomEventInterstitialListener customEventInterstitialListener, @Nullable String str) {
preRenderHtml(customEventInterstitialListener, str, new BaseWebView(context));
}
@VisibleForTesting
static void preRenderHtml(@NonNull final CustomEventInterstitial.CustomEventInterstitialListener customEventInterstitialListener, @Nullable String str, @NonNull final BaseWebView baseWebView) {
baseWebView.enablePlugins(false);
baseWebView.enableJavascriptCaching();
baseWebView.setWebViewClient(new MraidWebViewClient() {
@Override
public void onPageFinished(WebView webView, String str2) {
CustomEventInterstitial.CustomEventInterstitialListener.this.onInterstitialLoaded();
baseWebView.loadUrl("javascript:mraidbridge.setState('default');");
baseWebView.loadUrl("javascript:mraidbridge.notifyReadyEvent();");
}
@Override
public void onReceivedError(WebView webView, int i, String str2, String str3) {
super.onReceivedError(webView, i, str2, str3);
CustomEventInterstitial.CustomEventInterstitialListener.this.onInterstitialFailed(MoPubErrorCode.MRAID_LOAD_ERROR);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str2) {
return true;
}
});
baseWebView.loadDataWithBaseURL(Networking.getBaseUrlScheme() + "://" + Constants.HOST + "/", str, "text/html", "UTF-8", null);
}
public static void start(@NonNull Context context, @Nullable AdReport adReport, @Nullable String str, long j) {
try {
context.startActivity(createIntent(context, adReport, str, j));
} catch (ActivityNotFoundException unused) {
Log.d("MraidInterstitial", "MraidActivity.class not found. Did you declare MraidActivity in your manifest?");
}
}
@Override
public View getAdView() {
String stringExtra = getIntent().getStringExtra(DataKeys.HTML_RESPONSE_BODY_KEY);
if (stringExtra == null) {
MoPubLog.w("MraidActivity received a null HTML body. Finishing the activity.");
finish();
return new View(this);
}
this.mMraidController = new MraidController(this, this.mAdReport, PlacementType.INTERSTITIAL);
this.mMraidController.setDebugListener(this.mDebugListener);
this.mMraidController.setMraidListener(new MraidController.MraidListener() {
@Override
public void onClose() {
MraidActivity.this.mMraidController.loadJavascript(BaseInterstitialActivity.JavaScriptWebViewCallbacks.WEB_VIEW_DID_CLOSE.getJavascript());
MraidActivity.this.finish();
}
@Override
public void onExpand() {
}
@Override
public void onFailedToLoad() {
MoPubLog.d("MraidActivity failed to load. Finishing the activity");
if (MraidActivity.this.getBroadcastIdentifier() != null) {
EventForwardingBroadcastReceiver.broadcastAction(MraidActivity.this, MraidActivity.this.getBroadcastIdentifier().longValue(), IntentActions.ACTION_INTERSTITIAL_FAIL);
}
MraidActivity.this.finish();
}
@Override
public void onLoaded(View view) {
MraidActivity.this.mMraidController.loadJavascript(BaseInterstitialActivity.JavaScriptWebViewCallbacks.WEB_VIEW_DID_APPEAR.getJavascript());
}
@Override
public void onOpen() {
if (MraidActivity.this.getBroadcastIdentifier() != null) {
EventForwardingBroadcastReceiver.broadcastAction(MraidActivity.this, MraidActivity.this.getBroadcastIdentifier().longValue(), IntentActions.ACTION_INTERSTITIAL_CLICK);
}
}
});
this.mMraidController.setUseCustomCloseListener(new MraidController.UseCustomCloseListener() {
@Override
public void useCustomCloseChanged(boolean z) {
if (z) {
MraidActivity.this.hideInterstitialCloseButton();
} else {
MraidActivity.this.showInterstitialCloseButton();
}
}
});
this.mMraidController.loadContent(stringExtra);
return this.mMraidController.getAdContainer();
}
@Override
public void onCreate(@Nullable Bundle bundle) {
super.onCreate(bundle);
if (getBroadcastIdentifier() != null) {
EventForwardingBroadcastReceiver.broadcastAction(this, getBroadcastIdentifier().longValue(), IntentActions.ACTION_INTERSTITIAL_SHOW);
}
getWindow().setFlags(16777216, 16777216);
}
@Override
public void onDestroy() {
if (this.mMraidController != null) {
this.mMraidController.destroy();
}
if (getBroadcastIdentifier() != null) {
EventForwardingBroadcastReceiver.broadcastAction(this, getBroadcastIdentifier().longValue(), IntentActions.ACTION_INTERSTITIAL_DISMISS);
}
super.onDestroy();
}
@Override
public void onPause() {
if (this.mMraidController != null) {
this.mMraidController.pause(isFinishing());
}
super.onPause();
}
@Override
public void onResume() {
super.onResume();
if (this.mMraidController != null) {
this.mMraidController.resume();
}
}
@VisibleForTesting
public void setDebugListener(@Nullable MraidWebViewDebugListener mraidWebViewDebugListener) {
this.mDebugListener = mraidWebViewDebugListener;
if (this.mMraidController != null) {
this.mMraidController.setDebugListener(mraidWebViewDebugListener);
}
}
}