package com.mbridge.msdk.advanced.view; import android.content.Context; import android.content.res.Configuration; import android.util.AttributeSet; import android.util.Base64; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.RelativeLayout; import com.mbridge.msdk.advanced.js.a; import com.mbridge.msdk.advanced.js.b; import com.mbridge.msdk.foundation.tools.aa; import com.mbridge.msdk.foundation.tools.s; import com.mbridge.msdk.foundation.tools.w; import com.mbridge.msdk.mbjscommon.windvane.h; import java.util.HashMap; import org.json.JSONObject; public class MBNativeAdvancedView extends RelativeLayout { private static String a = "MBAdvancedNativeView"; private MBNativeAdvancedWebview b; private View c; private boolean d; private boolean e; private boolean f; private a g; private Context h; public void setH5Ready(boolean z) { this.d = z; } public void setVideoReady(boolean z) { this.e = z; } public boolean isEndCardReady() { return this.f; } public void setEndCardReady(boolean z) { this.f = z; } public boolean isH5Ready() { return this.d; } public boolean isVideoReady() { return this.e; } public void resetLoadState() { this.f = false; this.e = false; this.d = false; } public a getAdvancedNativeJSBridgeImpl() { return this.g; } public void setAdvancedNativeJSBridgeImpl(a aVar) { this.g = aVar; MBNativeAdvancedWebview mBNativeAdvancedWebview = this.b; if (mBNativeAdvancedWebview != null) { mBNativeAdvancedWebview.setObject(aVar); } } public MBNativeAdvancedView(Context context) { this(context, null); } public MBNativeAdvancedView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public MBNativeAdvancedView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.h = context; } /* access modifiers changed from: protected */ public void onConfigurationChanged(Configuration configuration) { super.onConfigurationChanged(configuration); } public MBNativeAdvancedWebview getAdvancedNativeWebview() { return this.b; } public void setAdvancedNativeWebview(MBNativeAdvancedWebview mBNativeAdvancedWebview) { this.b = mBNativeAdvancedWebview; a aVar = this.g; if (aVar != null) { mBNativeAdvancedWebview.setObject(aVar); } } public void changeCloseBtnState(int i) { View view = this.c; if (view == null) { return; } if (i == 2) { view.setVisibility(8); } else { view.setVisibility(0); } } public View getCloseView() { return this.c; } public void setCloseView(View view) { this.c = view; if (view != null) { view.setContentDescription("closeButton"); } } public void clearResState() { this.f = false; this.e = false; this.d = false; } public void clearResStateAndRemoveClose() { clearResState(); View view = this.c; if (view != null && view.getParent() != null) { removeView(this.c); } } public static void transInfoForMraid(WebView webView, int i, int i2, int i3, int i4) { w.d(a, "transInfoForMraid"); try { int i5 = com.mbridge.msdk.foundation.controller.a.f().j().getResources().getConfiguration().orientation; JSONObject jSONObject = new JSONObject(); jSONObject.put("orientation", i5 == 2 ? "landscape" : i5 == 1 ? "portrait" : "undefined"); jSONObject.put("locked", "true"); float x = (float) s.x(com.mbridge.msdk.foundation.controller.a.f().j()); float y = (float) s.y(com.mbridge.msdk.foundation.controller.a.f().j()); HashMap z = s.z(com.mbridge.msdk.foundation.controller.a.f().j()); int intValue = ((Integer) z.get("width")).intValue(); int intValue2 = ((Integer) z.get("height")).intValue(); HashMap hashMap = new HashMap(); hashMap.put("placementType", "inline"); hashMap.put("state", "default"); hashMap.put("viewable", "true"); hashMap.put("currentAppOrientation", jSONObject); float f2 = (float) i; float f3 = (float) i2; float f4 = (float) i3; float f5 = (float) i4; com.mbridge.msdk.mbjscommon.mraid.a.a().a(webView, f2, f3, f4, f5); com.mbridge.msdk.mbjscommon.mraid.a.a().b(webView, f2, f3, f4, f5); com.mbridge.msdk.mbjscommon.mraid.a.a().b(webView, x, y); com.mbridge.msdk.mbjscommon.mraid.a.a().c(webView, (float) intValue, (float) intValue2); com.mbridge.msdk.mbjscommon.mraid.a.a().a(webView, hashMap); com.mbridge.msdk.mbjscommon.mraid.a.a().a(webView); } catch (Throwable th) { w.b(a, "transInfoForMraid", th); } } public void destroy() { removeAllViews(); MBNativeAdvancedWebview mBNativeAdvancedWebview = this.b; if (mBNativeAdvancedWebview != null && !mBNativeAdvancedWebview.isDestoryed()) { this.b.release(); b.a(this.b, "onSystemDestory", ""); } if (this.h != null) { this.h = null; } } public void show() { MBNativeAdvancedWebview mBNativeAdvancedWebview = this.b; if (mBNativeAdvancedWebview != null && mBNativeAdvancedWebview.getParent() == null) { addView(this.b, new ViewGroup.LayoutParams(-1, -1)); } int[] iArr = new int[2]; this.b.getLocationInWindow(iArr); MBNativeAdvancedWebview mBNativeAdvancedWebview2 = this.b; transInfoForMraid(mBNativeAdvancedWebview2, iArr[0], iArr[1], mBNativeAdvancedWebview2.getWidth(), this.b.getHeight()); MBNativeAdvancedWebview mBNativeAdvancedWebview3 = this.b; if (mBNativeAdvancedWebview3 != null) { mBNativeAdvancedWebview3.setObject(this.g); this.b.post(new Runnable() { /* class com.mbridge.msdk.advanced.view.MBNativeAdvancedView.AnonymousClass1 */ public final void run() { String jSONObject; try { w.a(MBNativeAdvancedView.a, "webviewshow"); try { int[] iArr = new int[2]; MBNativeAdvancedView.this.b.getLocationOnScreen(iArr); String str = MBNativeAdvancedView.a; w.d(str, "coordinate:" + iArr[0] + "--" + iArr[1]); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("startX", aa.a(com.mbridge.msdk.foundation.controller.a.f().j(), (float) iArr[0])); jSONObject2.put("startY", aa.a(com.mbridge.msdk.foundation.controller.a.f().j(), (float) iArr[1])); jSONObject = jSONObject2.toString(); } catch (Throwable th) { w.b(MBNativeAdvancedView.a, th.getMessage(), th); } h.a().a((WebView) MBNativeAdvancedView.this.b, "webviewshow", Base64.encodeToString(jSONObject.toString().getBytes(), 2)); } catch (Exception e) { e.printStackTrace(); } } }); } View view = this.c; if (view != null) { if (view.getParent() == null) { RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(aa.b(getContext(), 28.0f), aa.b(getContext(), 16.0f)); layoutParams.addRule(10); layoutParams.addRule(11); layoutParams.rightMargin = aa.b(getContext(), 2.0f); layoutParams.topMargin = aa.b(getContext(), 2.0f); addView(this.c, layoutParams); } else { bringChildToFront(this.c); } } clearResState(); } }