package com.mbridge.msdk.video.bt.module; import android.content.Context; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.os.Build; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Base64; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import com.bytedance.sdk.openadsdk.api.plugin.PluginConstants; import com.mbridge.msdk.click.c; import com.mbridge.msdk.foundation.controller.a; import com.mbridge.msdk.foundation.same.c.b; import com.mbridge.msdk.foundation.tools.aa; import com.mbridge.msdk.foundation.tools.w; import com.mbridge.msdk.mbjscommon.windvane.h; import com.mbridge.msdk.video.js.a.j; import com.mbridge.msdk.video.module.a.a.d; import com.mbridge.msdk.video.module.a.a.i; import com.mbridge.msdk.videocommon.view.RoundImageView; import com.mbridge.msdk.videocommon.view.StarLevelView; import com.mbridge.msdk.widget.MBDownloadProgressBar; import java.util.Locale; import org.json.JSONException; import org.json.JSONObject; public class MBridgeBTNativeEC extends BTBaseView { private TextView A; private StarLevelView B; private boolean C = false; private boolean D = false; private int E = 0; private Runnable F; private boolean G = false; private View H; private MBDownloadProgressBar I; private String J; /* renamed from: K reason: collision with root package name */ private j f124K; private WebView L; private ViewGroup p; private ViewGroup q; private RelativeLayout r; private ImageView s; private RoundImageView t; private ImageView u; private ImageView v; private ImageView w; private ImageView x; private TextView y; private TextView z; @Override // com.mbridge.msdk.video.bt.module.BTBaseView public void onDestory() { } public MBridgeBTNativeEC(Context context) { super(context); } public MBridgeBTNativeEC(Context context, AttributeSet attributeSet) { super(context, attributeSet); } @Override // com.mbridge.msdk.video.bt.module.BTBaseView public void setUnitId(String str) { this.J = str; } public void setJSCommon(j jVar) { this.f124K = jVar; } public void setCreateWebView(WebView webView) { this.L = webView; } /* access modifiers changed from: protected */ public void onAttachedToWindow() { super.onAttachedToWindow(); if (this.F == null) { this.F = new Runnable() { /* class com.mbridge.msdk.video.bt.module.MBridgeBTNativeEC.AnonymousClass1 */ public final void run() { MBridgeBTNativeEC.this.D = true; if (MBridgeBTNativeEC.this.H != null) { MBridgeBTNativeEC.this.H.setVisibility(0); } } }; } Runnable runnable = this.F; if (runnable != null) { postDelayed(runnable, (long) (this.E * 1000)); } if (!this.h && this.L != null) { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("id", this.d); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("unitId", this.J); jSONObject.put("data", jSONObject2); w.a(BTBaseView.TAG, "NativeEC Call H5 onCloseBtnClicked " + jSONObject.toString()); } catch (JSONException e) { w.a(BTBaseView.TAG, e.getMessage()); } h.a().a(this.L, "onCloseBtnClicked", Base64.encodeToString(jSONObject.toString().getBytes(), 2)); } if (this.L != null) { JSONObject jSONObject3 = new JSONObject(); try { jSONObject3.put("id", this.d); JSONObject jSONObject4 = new JSONObject(); jSONObject4.put("unitId", this.J); jSONObject3.put("data", jSONObject4); w.a(BTBaseView.TAG, "NativeEC Call H5 onEndCardShow " + jSONObject3.toString()); } catch (JSONException e2) { w.a(BTBaseView.TAG, e2.getMessage()); } h.a().a(this.L, "onNativeECShow", Base64.encodeToString(jSONObject3.toString().getBytes(), 2)); } } /* access modifiers changed from: protected */ public void onDetachedFromWindow() { super.onDetachedFromWindow(); Runnable runnable = this.F; if (runnable != null) { removeCallbacks(runnable); } } public void preLoadData() { Bitmap blurBitmap; try { if (this.b != null && this.h) { if (this.b.getCbd() > -2) { this.E = this.b.getCbd(); } else if (this.e != null) { this.E = this.e.o(); } b.a(this.a.getApplicationContext()).a(this.b.getImageUrl(), new d(this.t, this.b, this.J)); b.a(this.a.getApplicationContext()).a(this.b.getIconUrl(), new i(this.u, aa.b(a.f().j(), 8.0f))); this.y.setText(this.b.getAppName()); this.z.setText(this.b.getAppDesc()); TextView textView = this.A; textView.setText(this.b.getNumberRating() + ")"); this.B.removeAllViews(); this.I.setUniqueKey(this.b.getAkdlui()); this.I.setLinkType(this.b.getLinkType()); this.I.setCtaldtypeUrl(this.b.getCMPTEntryUrl()); this.I.setText(this.b.getAdCall()); double rating = this.b.getRating(); if (rating <= 0.0d) { rating = 5.0d; } this.B.initScore(rating); if (Build.VERSION.SDK_INT < 17) { this.s.setVisibility(8); return; } try { Bitmap a = a(this.t.getDrawable()); if (!(a == null || (blurBitmap = blurBitmap(a)) == null)) { this.s.setImageBitmap(blurBitmap); } } catch (Throwable unused) { this.s.setVisibility(8); } if (!TextUtils.isEmpty(this.b.getendcard_url()) && this.b.getendcard_url().contains("alecfc=1")) { this.C = true; } if (!TextUtils.isEmpty(this.b.getendcard_url()) && this.b.getendcard_url().contains("wlgo=1")) { this.G = true; } String language = Locale.getDefault().getLanguage(); if (TextUtils.isEmpty(language) || !language.equals("zh")) { this.v.setImageDrawable(getResources().getDrawable(getResources().getIdentifier("mbridge_reward_flag_en", "drawable", a.f().d()))); } else { this.v.setImageDrawable(getResources().getDrawable(getResources().getIdentifier("mbridge_reward_flag_cn", "drawable", a.f().d()))); } if (!this.G) { this.v.setVisibility(4); this.x.setVisibility(4); } com.mbridge.msdk.c.a b = com.mbridge.msdk.c.b.a().b(a.f().k()); if (b != null) { final String ax = b.ax(); if (TextUtils.isEmpty(ax)) { this.w.setVisibility(8); } this.w.setOnClickListener(new View.OnClickListener() { /* class com.mbridge.msdk.video.bt.module.MBridgeBTNativeEC.AnonymousClass2 */ public final void onClick(View view) { c.b(MBridgeBTNativeEC.this.a, ax); } }); } else { this.w.setVisibility(8); } if (!this.D) { this.H.setVisibility(8); } } } catch (Throwable th) { w.a(BTBaseView.TAG, th.getMessage()); } } @Override // com.mbridge.msdk.video.bt.module.BTBaseView public void onSelfConfigurationChanged(Configuration configuration) { super.onSelfConfigurationChanged(configuration); this.g = configuration.orientation; w.d(BTBaseView.TAG, " native onSelfConfigurationChanged:" + this.g); if (this.g == 2) { removeView(this.p); a(this.q); return; } removeView(this.q); a(this.p); } private void a(View view) { if (view == null) { init(this.a); preLoadData(); return; } if (view.getParent() != null) { ((ViewGroup) view.getParent()).removeView(view); } addView(view); b(view); a(); } /* access modifiers changed from: protected */ @Override // com.mbridge.msdk.video.bt.module.BTBaseView public final void a() { try { if (this.h) { this.r.setOnClickListener(new View.OnClickListener() { /* class com.mbridge.msdk.video.bt.module.MBridgeBTNativeEC.AnonymousClass3 */ public final void onClick(View view) { if (MBridgeBTNativeEC.this.C) { MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, 1, view.getContext()); MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, view.getX(), view.getY()); } } }); this.H.setOnClickListener(new View.OnClickListener() { /* class com.mbridge.msdk.video.bt.module.MBridgeBTNativeEC.AnonymousClass4 */ public final void onClick(View view) { if (MBridgeBTNativeEC.this.L != null) { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("id", MBridgeBTNativeEC.this.d); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("unitId", MBridgeBTNativeEC.this.J); jSONObject.put("data", jSONObject2); w.a(BTBaseView.TAG, "NativeEC Call H5 onCloseBtnClicked " + jSONObject.toString()); } catch (JSONException e) { w.a(BTBaseView.TAG, e.getMessage()); } h.a().a(MBridgeBTNativeEC.this.L, "onCloseBtnClicked", Base64.encodeToString(jSONObject.toString().getBytes(), 2)); } } }); this.I.setOnClickListener(new com.mbridge.msdk.widget.a() { /* class com.mbridge.msdk.video.bt.module.MBridgeBTNativeEC.AnonymousClass5 */ /* access modifiers changed from: protected */ @Override // com.mbridge.msdk.widget.a public final void a(View view) { MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, 0, view.getContext()); MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, view.getX(), view.getY()); } }); this.u.setOnClickListener(new com.mbridge.msdk.widget.a() { /* class com.mbridge.msdk.video.bt.module.MBridgeBTNativeEC.AnonymousClass6 */ /* access modifiers changed from: protected */ @Override // com.mbridge.msdk.widget.a public final void a(View view) { if (MBridgeBTNativeEC.this.I.NotProgressBarInterceptedClick()) { MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, 0, view.getContext()); } MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, view.getX(), view.getY()); } }); this.t.setOnClickListener(new com.mbridge.msdk.widget.a() { /* class com.mbridge.msdk.video.bt.module.MBridgeBTNativeEC.AnonymousClass7 */ /* access modifiers changed from: protected */ @Override // com.mbridge.msdk.widget.a public final void a(View view) { if (MBridgeBTNativeEC.this.I.NotProgressBarInterceptedClick()) { MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, 0, view.getContext()); } MBridgeBTNativeEC.a(MBridgeBTNativeEC.this, view.getX(), view.getY()); } }); } } catch (Throwable th) { w.a(BTBaseView.TAG, th.getMessage()); } } private boolean b(View view) { try { this.r = (RelativeLayout) view.findViewById(findID("mbridge_native_ec_layout")); this.s = (ImageView) view.findViewById(findID("mbridge_iv_adbanner_bg")); this.t = (RoundImageView) view.findViewById(findID("mbridge_iv_adbanner")); this.u = (ImageView) view.findViewById(findID("mbridge_iv_icon")); this.v = (ImageView) view.findViewById(findID("mbridge_iv_flag")); this.w = (ImageView) view.findViewById(findID("mbridge_iv_link")); this.y = (TextView) view.findViewById(findID("mbridge_tv_apptitle")); this.z = (TextView) view.findViewById(findID("mbridge_tv_appdesc")); this.A = (TextView) view.findViewById(findID("mbridge_tv_number")); this.B = (StarLevelView) view.findViewById(findID("mbridge_sv_starlevel")); this.H = view.findViewById(findID("mbridge_iv_close")); this.I = (MBDownloadProgressBar) view.findViewById(findID("mbridge_tv_cta")); this.x = (ImageView) view.findViewById(findID("mbridge_iv_logo")); return isNotNULL(this.s, this.t, this.u, this.y, this.z, this.A, this.B, this.H, this.I); } catch (Throwable th) { w.b(BTBaseView.TAG, th.getMessage(), th); return false; } } public Bitmap blurBitmap(Bitmap bitmap) { try { Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); RenderScript create = RenderScript.create(this.a.getApplicationContext()); ScriptIntrinsicBlur create2 = ScriptIntrinsicBlur.create(create, Element.U8_4(create)); Allocation createFromBitmap = Allocation.createFromBitmap(create, bitmap); Allocation createFromBitmap2 = Allocation.createFromBitmap(create, createBitmap); create2.setRadius(10.0f); create2.setInput(createFromBitmap); create2.forEach(createFromBitmap2); createFromBitmap2.copyTo(createBitmap); bitmap.recycle(); create.destroy(); return createBitmap; } catch (Throwable unused) { return null; } } private Bitmap a(Drawable drawable) { try { int intrinsicWidth = drawable.getIntrinsicWidth(); int intrinsicHeight = drawable.getIntrinsicHeight(); Bitmap createBitmap = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(createBitmap); drawable.setBounds(0, 0, intrinsicWidth, intrinsicHeight); drawable.draw(canvas); return createBitmap; } catch (Throwable th) { w.a(BTBaseView.TAG, th.getMessage()); return null; } } @Override // com.mbridge.msdk.video.bt.module.BTBaseView public void init(Context context) { boolean z2; int findLayout = findLayout(isLandscape() ? "mbridge_reward_endcard_native_land" : "mbridge_reward_endcard_native_hor"); if (findLayout > 0) { if (isLandscape()) { ViewGroup viewGroup = (ViewGroup) this.f.inflate(findLayout, (ViewGroup) null); this.q = viewGroup; addView(viewGroup); z2 = b(this.q); } else { ViewGroup viewGroup2 = (ViewGroup) this.f.inflate(findLayout, (ViewGroup) null); this.p = viewGroup2; addView(viewGroup2); z2 = b(this.p); } this.h = z2; a(); } } /* JADX WARNING: Removed duplicated region for block: B:13:0x001e A[ADDED_TO_REGION, Catch:{ all -> 0x0013 }] */ /* JADX WARNING: Removed duplicated region for block: B:27:? A[RETURN, SYNTHETIC] */ static /* synthetic */ void a(MBridgeBTNativeEC mBridgeBTNativeEC, int i, Context context) { JSONObject jSONObject; JSONException e; JSONObject jSONObject2 = null; try { jSONObject = new JSONObject(); try { jSONObject.put(com.mbridge.msdk.foundation.same.a.o, mBridgeBTNativeEC.a(i)); } catch (JSONException e2) { e = e2; jSONObject2 = jSONObject; } } catch (JSONException e3) { e = e3; try { e.printStackTrace(); jSONObject = jSONObject2; if (mBridgeBTNativeEC.f124K == null) { } } catch (Throwable th) { w.a(BTBaseView.TAG, th.getMessage()); return; } } if (mBridgeBTNativeEC.f124K == null) { if (!(context == null || context == context.getApplicationContext())) { mBridgeBTNativeEC.f124K.a(context); } if (mBridgeBTNativeEC.b != null) { com.mbridge.msdk.video.bt.a.c a = com.mbridge.msdk.video.bt.a.c.a(); mBridgeBTNativeEC.f124K.a(a.d(mBridgeBTNativeEC.J + "_" + mBridgeBTNativeEC.b.getRequestId())); } mBridgeBTNativeEC.f124K.click(1, jSONObject != null ? jSONObject.toString() : ""); } } static /* synthetic */ void a(MBridgeBTNativeEC mBridgeBTNativeEC, float f, float f2) { if (mBridgeBTNativeEC.L != null) { try { JSONObject jSONObject = new JSONObject(); jSONObject.put(PluginConstants.KEY_ERROR_CODE, n); jSONObject.put("id", mBridgeBTNativeEC.d); JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("x", String.valueOf(f)); jSONObject2.put("y", String.valueOf(f2)); jSONObject.put("data", jSONObject2); h.a().a(mBridgeBTNativeEC.L, "onClicked", Base64.encodeToString(jSONObject.toString().getBytes(), 2)); } catch (Exception unused) { com.mbridge.msdk.video.bt.a.c.a().a(mBridgeBTNativeEC.L, "onClicked", mBridgeBTNativeEC.d); } } } }