正在查看: MX Player v1.97.8 应用的 DTBAdView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: MX Player v1.97.8 应用的 DTBAdView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.amazon.device.ads;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.webkit.CookieManager;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import android.widget.ScrollView;
import com.amazon.device.ads.DTBAdView;
import com.amazon.identity.auth.device.utils.AccountConstants;
import defpackage.i0;
import defpackage.k0;
import defpackage.l0;
import defpackage.lg;
import defpackage.p04;
import defpackage.rl4;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
public class DTBAdView extends WebView {
public static final String AMAZON_AD_INFO = "amazon_ad_info";
static final String AMAZON_BRIDGE = "amzn_bridge";
public static final String BID_HTML = "bid_html_template";
public static final String BID_IDENTIFIER = "bid_identifier";
private static final String ENV_TEMPLATE = "window.MRAID_ENV={version:'%s',sdk:'%s',sdkVersion:'%s',appId:'%s',ifa:'%s',limitAdTracking:%b,coppa:%b,impFired:true};";
private static final String ENV_TEMPLATE_INFO = "window.MRAID_ENV={version:'%s',sdk:'%s',sdkVersion:'%s',appId:'%s',ifa:'%s',limitAdTracking:%b,coppa:%b,amznAdInfo:%s,impFired:true};";
public static final String EVENT_SERVER_PARAMETER = "event_server_parameter";
public static final String EXPECTED_HEIGHT = "expected_height";
public static final String EXPECTED_WIDTH = "expected_width";
public static final String HOSTNAME_IDENTIFIER = "hostname_identifier";
static final String LOG_TAG = "DTBAdView";
static final String MRAID_IDENTIFIER = "MRAID_ENV";
public static final String REQUEST_QUEUE = "amazon_request_queue";
public static final String SMARTBANNER_STATE = "smart_banner_state";
public static final String START_LOAD_TIME = "start_load_time";
public static final String VIDEO = "video_flag";
static final String VIDEO_COMPLETE_EVENT = "AD_VIDEO_PLAYER_COMPLETED";
static final String VIDEO_EVENT_JSON_SUBTYPE = "subtype";
static final String VIDEO_EVENT_JS_COMMAND_TYPE = "apsvid";
private String bidId;
private DTBAdMRAIDController controller;
private int exposurePercent;
ViewTreeObserver.OnGlobalFocusChangeListener focusChangeListener;
ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener;
private String hostname;
private boolean ignoreDetachment;
private boolean isFirstDisplay;
private boolean isVideo;
private boolean isVisible;
private boolean localOnly;
ViewTreeObserver.OnScrollChangedListener scrollChangeListener;
private boolean scrollEnabled;
private long startTime;
DTBAdViewSupportClient supportClient;
private long timeClicked;
private long timePressed;
private WebBridge webBridge;
public class WebBridge {
Exception execException;
public WebBridge() {
}
public void lambda$echo$0(String str) {
DTBAdView.this.evaluateJavascript(str, null);
}
private void logFromJavasScript(String str) {
DtbLog.debug("mraid:JSNative", str);
}
public void echo(JSONObject jSONObject) {
try {
final String format = String.format("window.promiseResolve(%d, '%s');", Integer.valueOf(jSONObject.getInt("promiseId")), jSONObject.getJSONObject("arguments").getString("greeting") + " Returned");
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
DTBAdView.WebBridge.this.lambda$echo$0(format);
}
});
} catch (JSONException e) {
DtbLog.debug(DTBAdView.LOG_TAG, "JSON conversion failed:" + e);
}
}
public Exception getExecutionException() {
return this.execException;
}
public void handleMraidCommand(JSONObject jSONObject) throws JSONException {
this.execException = null;
String string = jSONObject.getString(DTBAdView.VIDEO_EVENT_JSON_SUBTYPE);
Class<MraidCommand> findMraidCommandByName = MraidCommand.findMraidCommandByName(string);
if (findMraidCommandByName == null) {
DtbLog.error(lg0.e("MRAID Command:", string, " is not found"));
DTBAdView.this.controller.fireErrorEvent(string, rg2.d(string, " is not supported"));
DTBAdView.this.controller.commandCompleted(string);
return;
}
try {
MraidCommand newInstance = findMraidCommandByName.newInstance();
DtbLog.debug(DTBAdView.LOG_TAG, "execute command " + newInstance.getName());
newInstance.execute(jSONObject.getJSONObject("arguments"), DTBAdView.this.controller);
} catch (JSONException e) {
throw e;
} catch (Exception e2) {
this.execException = e2;
StringBuilder c = lg.c("Error execution command ", string, " ");
c.append(e2.getLocalizedMessage());
DtbLog.debug(c.toString());
}
}
public void handleServiceCall(JSONObject jSONObject) throws JSONException {
if ("log".equals(jSONObject.getString(DTBAdView.VIDEO_EVENT_JSON_SUBTYPE))) {
logFromJavasScript(jSONObject.getJSONObject("arguments").getString("message"));
}
}
public void handleVideoEvent(JSONObject jSONObject) throws JSONException {
if (!DTBAdView.VIDEO_COMPLETE_EVENT.equals(jSONObject.getString(DTBAdView.VIDEO_EVENT_JSON_SUBTYPE)) || DTBAdView.this.controller == null) {
return;
}
DTBAdView.this.controller.onVideoCompleted();
}
@JavascriptInterface
public void postMessage(String str) {
try {
JSONObject jSONObject = new JSONObject(str);
if (!jSONObject.has(AccountConstants.SUB_AUTHENTICATOR_TYPE_ATTRIBUTE)) {
DtbLog.error("Unrecognized bridge call");
return;
}
String string = jSONObject.getString(AccountConstants.SUB_AUTHENTICATOR_TYPE_ATTRIBUTE);
if ("service".equals(string)) {
handleServiceCall(jSONObject);
} else if ("mraid".equals(string)) {
handleMraidCommand(jSONObject);
} else if (DTBAdView.VIDEO_EVENT_JS_COMMAND_TYPE.equals(string)) {
handleVideoEvent(jSONObject);
}
} catch (JSONException e) {
DtbLog.debug(DTBAdView.LOG_TAG, "JSON conversion failed:" + e);
}
}
}
public DTBAdView(Context context, DTBAdInterstitialListener dTBAdInterstitialListener) {
super(context);
this.scrollEnabled = true;
this.ignoreDetachment = false;
this.isFirstDisplay = true;
this.isVisible = false;
this.exposurePercent = -1;
this.localOnly = WebResourceOptions.isLocalSourcesOnly();
CookieManager.getInstance().setAcceptCookie(true);
try {
this.controller = new DTBAdMRAIDInterstitialController(this, dTBAdInterstitialListener);
commonInit();
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to initialize DTBAdView class with DTBAdInterstitialListener");
i0.a(k0.b, l0.b, "Fail to initialize DTBAdView class with DTBAdInterstitialListener", e);
}
}
private void commonInit() {
getSettings().setJavaScriptEnabled(true);
getSettings().setAllowContentAccess(true);
getSettings().setDomStorageEnabled(true);
getSettings().setAppCacheEnabled(true);
getSettings().setAllowFileAccess(false);
getSettings().setLoadsImagesAutomatically(true);
getSettings().setMediaPlaybackRequiresUserGesture(false);
if (AdRegistration.isTestMode()) {
WebView.setWebContentsDebuggingEnabled(true);
}
getSettings().setBlockNetworkImage(false);
DTBAdViewSupportClient dTBAdViewSupportClient = new DTBAdViewSupportClient(getContext(), this.controller);
this.supportClient = dTBAdViewSupportClient;
setWebViewClient(dTBAdViewSupportClient);
setScrollEnabled(false);
WebBridge webBridge = new WebBridge();
this.webBridge = webBridge;
addJavascriptInterface(webBridge, AMAZON_BRIDGE);
WebResourceService.init();
this.globalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
DTBAdView.this.verifyIsVisible();
}
};
this.focusChangeListener = new ViewTreeObserver.OnGlobalFocusChangeListener() {
@Override
public void onGlobalFocusChanged(View view, View view2) {
DTBAdView.this.verifyIsVisible();
}
};
this.scrollChangeListener = new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
DTBAdView.this.verifyIsVisible();
}
};
setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view, MotionEvent motionEvent) {
boolean lambda$commonInit$0;
lambda$commonInit$0 = DTBAdView.this.lambda$commonInit$0(view, motionEvent);
return lambda$commonInit$0;
}
});
}
private void computeExposureInScrollView(ScrollView scrollView, boolean z) {
ViewGroup viewGroup;
Activity activity = DTBAdUtil.getActivity((View) getParent());
if (activity == null || (viewGroup = (ViewGroup) activity.findViewById(android.R.id.content)) == null) {
return;
}
int[] iArr = new int[2];
viewGroup.getLocationInWindow(iArr);
int i = iArr[0];
Rect rect = new Rect(i, iArr[1], viewGroup.getWidth() + i, viewGroup.getHeight() + iArr[1]);
int[] iArr2 = new int[2];
getLocationInWindow(iArr2);
float height = getHeight() * getWidth();
int i2 = iArr2[0];
Rect rect2 = new Rect(i2, iArr2[1], getWidth() + i2, getHeight() + iArr2[1]);
if (scrollView == null) {
rect2.intersect(rect);
} else {
int[] iArr3 = new int[2];
scrollView.getLocationInWindow(iArr3);
int i3 = iArr3[0];
Rect rect3 = new Rect(i3, iArr3[1], scrollView.getWidth() + i3, scrollView.getHeight() + iArr3[1]);
rect3.intersect(rect);
rect2.intersect(rect3);
}
int i4 = height != 0.0f ? (int) ((((rect2.bottom - rect2.top) * (rect2.right - rect2.left)) * 100.0f) / height) : 0;
if (i4 != this.exposurePercent || z) {
this.exposurePercent = i4;
this.controller.fireExposureChange(i4, rect2);
this.controller.setCurrentPositionProperty();
}
}
private ScrollView getScrollViewParent() {
View view = this;
while (true) {
Object parent = view.getParent();
if (!(parent instanceof ViewGroup)) {
return null;
}
if (parent instanceof ScrollView) {
return (ScrollView) parent;
}
view = (View) parent;
}
}
public boolean lambda$commonInit$0(View view, MotionEvent motionEvent) {
return detectAdClick(motionEvent);
}
private void loadLocalFile(String str, StringBuilder sb) {
if (!this.localOnly) {
try {
String loadFile = WebResourceService.getInstance().loadFile(str);
if (loadFile != null) {
sb.append("<script>");
sb.append(loadFile);
sb.append("</script>");
return;
}
} catch (Exception unused) {
DtbLog.error(LOG_TAG, "Failed to read local file");
}
}
sb.append("<script>");
try {
InputStream open = getContext().getAssets().open(str + ".js");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine.trim());
sb.append("\n");
}
bufferedReader.close();
open.close();
} catch (Exception unused2) {
DtbLog.error(bl0.c("Error reading file:", str));
}
sb.append("</script>");
}
private void setIsVisible(boolean z) {
this.isVisible = z;
if (z) {
return;
}
this.exposurePercent = -1;
DTBAdMRAIDController dTBAdMRAIDController = this.controller;
if (dTBAdMRAIDController != null) {
dTBAdMRAIDController.fireExposureChange(0, new Rect(0, 0, 0, 0));
}
}
public void verifyIsVisible() {
if (getParent() == null || getVisibility() != 0) {
if (this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController = this.controller;
if (dTBAdMRAIDController != null) {
dTBAdMRAIDController.onViewabilityChanged(false);
}
setIsVisible(false);
return;
}
return;
}
Activity currentActivity = AdRegistration.getCurrentActivity();
if (currentActivity == null) {
if (this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController2 = this.controller;
if (dTBAdMRAIDController2 != null) {
dTBAdMRAIDController2.onViewabilityChanged(false);
}
setIsVisible(false);
return;
}
return;
}
ViewGroup viewGroup = (ViewGroup) currentActivity.findViewById(android.R.id.content);
if (viewGroup == null) {
if (this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController3 = this.controller;
if (dTBAdMRAIDController3 != null) {
dTBAdMRAIDController3.onViewabilityChanged(false);
}
setIsVisible(false);
return;
}
return;
}
int[] iArr = new int[2];
viewGroup.getLocationInWindow(iArr);
int i = iArr[0];
Rect rect = new Rect(i, iArr[1], viewGroup.getWidth() + i, viewGroup.getHeight() + iArr[1]);
int[] iArr2 = new int[2];
getLocationInWindow(iArr2);
int i2 = iArr2[0];
Rect rect2 = new Rect(i2, iArr2[1], getWidth() + i2, getHeight() + iArr2[1]);
if (rect.contains(rect2) || Rect.intersects(rect, rect2)) {
ScrollView scrollViewParent = getScrollViewParent();
if (scrollViewParent != null) {
int[] iArr3 = new int[2];
scrollViewParent.getLocationInWindow(iArr3);
int i3 = iArr3[0];
Rect rect3 = new Rect(i3, iArr3[1], scrollViewParent.getWidth() + i3, scrollViewParent.getHeight() + iArr3[1]);
if (!Rect.intersects(rect2, rect3) && this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController4 = this.controller;
if (dTBAdMRAIDController4 != null) {
dTBAdMRAIDController4.onViewabilityChanged(false);
}
setIsVisible(false);
DtbLog.debug("SET MRAID Visible false because of scroll ");
} else if (Rect.intersects(rect2, rect3) && !this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController5 = this.controller;
if (dTBAdMRAIDController5 != null) {
dTBAdMRAIDController5.onViewabilityChanged(true);
}
setIsVisible(true);
DtbLog.debug("SET MRAID Visible true because of scroll ");
}
} else {
DTBAdMRAIDController dTBAdMRAIDController6 = this.controller;
if (dTBAdMRAIDController6 != null && !this.isVisible) {
dTBAdMRAIDController6.onViewabilityChanged(true);
}
setIsVisible(true);
}
} else if (this.isVisible) {
DTBAdMRAIDController dTBAdMRAIDController7 = this.controller;
if (dTBAdMRAIDController7 != null) {
dTBAdMRAIDController7.onViewabilityChanged(false);
}
setIsVisible(false);
DtbLog.debug("SET MRAID Visible false because of root");
}
if (this.isVisible) {
computeExposure();
}
}
public void cleanup() {
DTBAdMRAIDController dTBAdMRAIDController = this.controller;
dTBAdMRAIDController.adView = null;
dTBAdMRAIDController.customButtonListener = null;
this.controller = null;
}
public void computeExposure() {
computeExposure(false);
}
public void computeExposureInRootView() {
computeExposureInRootView(false);
}
public boolean detectAdClick(MotionEvent motionEvent) {
int action = motionEvent.getAction();
long c = p04.c();
if (action == 0) {
this.timePressed = c;
return false;
}
if (action != 1 || c - this.timeClicked < 1000) {
return false;
}
if (c - this.timePressed < 500) {
this.timeClicked = c;
this.controller.onAdClicked();
}
this.timePressed = 0L;
return false;
}
@Override
public void evaluateJavascript(String str, ValueCallback<String> valueCallback) {
super.evaluateJavascript(str, valueCallback);
}
public void fetchAd(Map<String, Object> map) {
fetchAd((String) null, map);
}
public void fetchAdWithLocation(String str) {
try {
StringBuilder sb = new StringBuilder();
sb.append("<script>");
sb.append(getEnvironment(null));
sb.append("</script>");
loadLocalFile("aps-mraid", sb);
sb.append("<script>");
sb.append("window.location=\"");
sb.append(str);
sb.append("\";");
sb.append("</script>");
loadDataWithBaseURL("https://c.amazon-adsystem.com/", sb.toString(), "text/html", "UTF-8", null);
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to execute fetchAdWithLocation method");
i0.a(k0.b, l0.b, "Fail to execute fetchAdWithLocation method", e);
}
}
public void finalize() {
try {
getViewTreeObserver().removeOnGlobalLayoutListener(this.globalLayoutListener);
getViewTreeObserver().removeOnScrollChangedListener(this.scrollChangeListener);
getViewTreeObserver().removeOnGlobalFocusChangeListener(this.focusChangeListener);
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to execute finalize method");
i0.a(k0.c, l0.b, "Fail to execute finalize method", e);
}
}
public String getBidId() {
return this.bidId;
}
public DTBAdMRAIDController getController() {
return this.controller;
}
public String getEnvironment(Bundle bundle) {
String string = bundle != null ? bundle.getString(AMAZON_AD_INFO) : null;
Context context = getContext();
String str = (String) context.getPackageManager().getApplicationLabel(context.getApplicationInfo());
String idfa = DtbSharedPreferences.getInstance().getIdfa();
if (DtbCommonUtils.isNullOrEmpty(idfa)) {
idfa = "unknown";
}
Boolean optOut = DtbSharedPreferences.getInstance().getOptOut();
if (optOut == null) {
optOut = Boolean.FALSE;
}
Boolean bool = Boolean.FALSE;
if (string == null) {
StringBuilder b = rl4.b("window.MRAID_ENV={version:'3.0',sdk:'", DtbCommonUtils.getSDKMRAIDVersion(), "',sdkVersion:'9.5.3',appId:'", str, "',ifa:'");
b.append(idfa);
b.append("',limitAdTracking:");
b.append(optOut);
b.append(",coppa:");
b.append(bool);
b.append(",impFired:true};");
return b.toString();
}
StringBuilder b2 = rl4.b("window.MRAID_ENV={version:'3.0',sdk:'", DtbCommonUtils.getSDKMRAIDVersion(), "',sdkVersion:'9.5.3',appId:'", str, "',ifa:'");
b2.append(idfa);
b2.append("',limitAdTracking:");
b2.append(optOut);
b2.append(",coppa:");
b2.append(bool);
b2.append(",amznAdInfo:");
b2.append(string);
b2.append(",impFired:true};");
return b2.toString();
}
public String getHostname() {
return this.hostname;
}
public long getStartTime() {
return this.startTime;
}
public boolean isVideo() {
return this.isVideo;
}
public boolean isVisible() {
return this.isVisible;
}
public void onAdRemoved() {
if (this.controller.getDtbOmSdkSessionManager() != null) {
this.controller.getDtbOmSdkSessionManager().stopOmAdSession();
}
this.controller.onAdRemoved();
}
@Override
public void onAttachedToWindow() {
try {
super.onAttachedToWindow();
getViewTreeObserver().addOnGlobalLayoutListener(this.globalLayoutListener);
getViewTreeObserver().addOnGlobalFocusChangeListener(this.focusChangeListener);
getViewTreeObserver().addOnScrollChangedListener(this.scrollChangeListener);
DTBAdMRAIDController controller = getController();
if (controller != null) {
controller.onAdOpened(this);
}
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to execute onAttachedToWindow method in DTBAdView class");
i0.a(k0.c, l0.b, "Fail to execute onAttachedToWindow method in DTBAdView class", e);
}
}
@Override
public void onDetachedFromWindow() {
try {
super.onDetachedFromWindow();
getViewTreeObserver().removeOnGlobalLayoutListener(this.globalLayoutListener);
getViewTreeObserver().removeOnScrollChangedListener(this.scrollChangeListener);
getViewTreeObserver().removeOnGlobalFocusChangeListener(this.focusChangeListener);
DTBAdMRAIDController controller = getController();
if (!(controller instanceof DTBAdMRAIDBannerController) || controller.getDtbOmSdkSessionManager() == null) {
return;
}
controller.getDtbOmSdkSessionManager().stopOmAdSession();
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to execute onDetachedFromWindow method in DTBAdView class");
i0.a(k0.c, l0.b, "Fail to execute onDetachedFromWindow method in DTBAdView class", e);
}
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (this.isFirstDisplay) {
if (DTBTimeTrace.getInstance() != null && AdRegistration.isTestMode()) {
DTBTimeTrace.getInstance().addPhase(DTBTimeTrace.TIMETRACE_AD_DISPLAY_SUCCEEDED);
DTBTimeTrace.getInstance().logTrace();
}
DTBActivityListener dTBActivityListener = this.controller;
if (dTBActivityListener instanceof DTBAdViewDisplayListener) {
((DTBAdViewDisplayListener) dTBActivityListener).onInitialDisplay();
}
this.isFirstDisplay = false;
}
}
@Override
public void onScrollChanged(int i, int i2, int i3, int i4) {
if (this.scrollEnabled) {
super.onScrollChanged(i, i2, i4, i3);
} else {
scrollTo(0, 0);
}
}
public void setIgnoreDetachment() {
this.ignoreDetachment = true;
}
public void setScrollEnabled(boolean z) {
this.scrollEnabled = z;
setVerticalScrollBarEnabled(z);
setHorizontalScrollBarEnabled(z);
}
public void computeExposure(boolean z) {
ScrollView scrollViewParent = getScrollViewParent();
if (scrollViewParent != null) {
computeExposureInScrollView(scrollViewParent, z);
return;
}
int[] iArr = new int[2];
getLocationInWindow(iArr);
int i = iArr[0];
Rect rect = new Rect(i, iArr[1], getWidth() + i, getHeight() + iArr[1]);
if (this.controller != null) {
computeExposureInRootView(z);
this.controller.onPositionChanged(rect);
}
}
public void computeExposureInRootView(boolean z) {
ViewGroup viewGroup;
View view = (View) getParent();
Activity activity = view != null ? DTBAdUtil.getActivity(view) : DTBAdUtil.getActivity(this);
if (activity == null || (viewGroup = (ViewGroup) activity.findViewById(android.R.id.content)) == null) {
return;
}
int[] iArr = new int[2];
viewGroup.getLocationInWindow(iArr);
int i = iArr[0];
Rect rect = new Rect(i, iArr[1], viewGroup.getWidth() + i, viewGroup.getHeight() + iArr[1]);
int[] iArr2 = new int[2];
getLocationOnScreen(iArr2);
int i2 = iArr2[0];
Rect rect2 = new Rect(i2, iArr2[1], getWidth() + i2, getHeight() + iArr2[1]);
float height = getHeight() * getWidth();
if (rect2.intersect(rect)) {
int i3 = (int) (((((rect2.bottom - rect2.top) * (rect2.right - rect2.left)) * 100.0d) / height) + 0.5d);
if (i3 != this.exposurePercent || z) {
this.exposurePercent = i3;
this.controller.fireExposureChange(i3, rect2);
return;
}
return;
}
if (this.exposurePercent != 0 || z) {
this.exposurePercent = 0;
rect2.top = rect2.bottom;
this.controller.fireExposureChange(0, rect2);
}
}
public void fetchAd(String str, Map<String, Object> map) {
try {
Bundle initializeEmptyBundle = DtbCommonUtils.initializeEmptyBundle();
for (Map.Entry<String, Object> entry : map.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
initializeEmptyBundle.putString(entry.getKey(), (String) value);
} else if (value instanceof Boolean) {
initializeEmptyBundle.putBoolean(entry.getKey(), ((Boolean) value).booleanValue());
} else if (value instanceof Integer) {
initializeEmptyBundle.putInt(entry.getKey(), ((Integer) value).intValue());
} else if (value instanceof Long) {
initializeEmptyBundle.putLong(entry.getKey(), ((Long) value).longValue());
}
}
fetchAd(str, initializeEmptyBundle);
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to execute fetchAd method with map bundle");
i0.a(k0.b, l0.b, "Fail to execute fetchAd method with map bundle", e);
}
}
public DTBAdView(Context context, DTBAdBannerListener dTBAdBannerListener) {
super(context);
this.scrollEnabled = true;
this.ignoreDetachment = false;
this.isFirstDisplay = true;
this.isVisible = false;
this.exposurePercent = -1;
this.localOnly = WebResourceOptions.isLocalSourcesOnly();
CookieManager.getInstance().setAcceptCookie(true);
try {
this.controller = new DTBAdMRAIDBannerController(this, dTBAdBannerListener);
commonInit();
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to initialize DTBAdView class with DTBAdBannerListener");
i0.a(k0.b, l0.b, "Fail to initialize DTBAdView class with DTBAdBannerListener", e);
}
}
public void fetchAd(String str) {
fetchAd(str, (Bundle) null);
}
public void fetchAd(Bundle bundle) {
fetchAd((String) null, bundle);
}
public void fetchAd(String str, Bundle bundle) {
if (str == null) {
try {
str = bundle.getString(BID_HTML, null);
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to execute fetchAd method with bundle");
i0.a(k0.b, l0.b, "Fail to execute fetchAd method with bundle", e);
return;
}
}
if (bundle != null) {
DTBAdMRAIDController dTBAdMRAIDController = this.controller;
if (dTBAdMRAIDController instanceof DTBAdMRAIDBannerController) {
DTBAdBannerListener dTBAdBannerListener = ((DTBAdMRAIDBannerController) dTBAdMRAIDController).bannerListener;
int i = bundle.getInt(EXPECTED_WIDTH, 0);
int i2 = bundle.getInt(EXPECTED_HEIGHT, 0);
if (i2 > 0 && i > 0 && (dTBAdBannerListener instanceof DTBExpectedSizeProvider)) {
DTBExpectedSizeProvider dTBExpectedSizeProvider = (DTBExpectedSizeProvider) dTBAdBannerListener;
dTBExpectedSizeProvider.setExpectedWidth(i);
dTBExpectedSizeProvider.setExpectedHeight(i2);
}
}
}
if (bundle != null) {
this.bidId = bundle.getString(BID_IDENTIFIER);
this.hostname = bundle.getString(HOSTNAME_IDENTIFIER);
this.isVideo = bundle.getBoolean(VIDEO);
}
this.startTime = new Date().getTime();
StringBuilder sb = new StringBuilder();
sb.append("<!DOCTYPE html><html><head>");
sb.append("<script>");
sb.append(getEnvironment(bundle));
sb.append("</script>");
loadLocalFile("aps-mraid", sb);
loadLocalFile("dtb-m", sb);
if (DtbOmSdkSessionManager.getFeatureEnableFlag()) {
loadLocalFile("omsdk-v1", sb);
}
sb.append("</head>");
sb.append("<body style='margin:0;padding:0;'>");
sb.append(str);
sb.append("</body></html>");
loadDataWithBaseURL("https://c.amazon-adsystem.com/", sb.toString(), "text/html", "UTF-8", null);
}
public DTBAdView(Context context, DTBAdExpandedListener dTBAdExpandedListener) {
this(context, dTBAdExpandedListener, 0);
}
public DTBAdView(Context context, DTBAdExpandedListener dTBAdExpandedListener, int i) {
super(context);
this.scrollEnabled = true;
this.ignoreDetachment = false;
this.isFirstDisplay = true;
this.isVisible = false;
this.exposurePercent = -1;
this.localOnly = WebResourceOptions.isLocalSourcesOnly();
CookieManager.getInstance().setAcceptCookie(true);
try {
DTBAdMRAIDExpandedController dTBAdMRAIDExpandedController = new DTBAdMRAIDExpandedController(this);
this.controller = dTBAdMRAIDExpandedController;
dTBAdMRAIDExpandedController.setMasterController(DTBAdMRAIDBannerController.findControllerByIndex(i));
dTBAdExpandedListener.onCreateExpandedController((DTBAdMRAIDExpandedController) this.controller);
commonInit();
} catch (RuntimeException e) {
DtbLog.error(LOG_TAG, "Fail to initialize DTBAdView class with DTBAdExpandedListener");
i0.a(k0.b, l0.b, "Fail to initialize DTBAdView class with DTBAdExpandedListener", e);
}
}
}