package com.mbridge.msdk.video.module; import android.content.Context; import android.content.res.Configuration; import android.text.TextUtils; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.mbridge.msdk.foundation.controller.c; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.same.a; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.foundation.tools.ak; import com.mbridge.msdk.video.module.a.a.j; import com.mbridge.msdk.video.signal.factory.b; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes4.dex */ public class MBridgeVideoEndCoverView extends MBridgeBaseView { private final String m; private View n; private ImageView o; private ImageView p; private TextView q; private TextView r; private TextView s; private b t; public MBridgeVideoEndCoverView(Context context) { super(context); this.m = "MBridgeVideoEndCoverView"; } public MBridgeVideoEndCoverView(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.m = "MBridgeVideoEndCoverView"; } @Override // com.mbridge.msdk.video.module.MBridgeBaseView public void init(Context context) { int findLayout = findLayout("mbridge_reward_videoend_cover"); if (findLayout >= 0) { View inflate = this.c.inflate(findLayout, (ViewGroup) null); this.n = inflate; if (inflate != null) { this.e = a(inflate); addView(this.n, -1, -1); c(); } } } @Override // com.mbridge.msdk.video.module.MBridgeBaseView, android.view.ViewGroup public boolean onInterceptTouchEvent(MotionEvent motionEvent) { this.f = motionEvent.getRawX(); this.g = motionEvent.getRawY(); return super.onInterceptTouchEvent(motionEvent); } @Override // com.mbridge.msdk.video.module.MBridgeBaseView public void onSelfConfigurationChanged(Configuration configuration) { super.onSelfConfigurationChanged(configuration); this.d = configuration.orientation; removeView(this.n); View view = this.n; if (view == null) { init(this.a); preLoadData(this.t); return; } if (view.getParent() != null) { ((ViewGroup) this.n.getParent()).removeView(this.n); } addView(this.n); a(this.n); c(); } private boolean a(View view) { if (view == null) { return true; } try { this.o = (ImageView) view.findViewById(findID("mbridge_vec_iv_icon")); this.p = (ImageView) view.findViewById(findID("mbridge_vec_iv_close")); this.q = (TextView) view.findViewById(findID("mbridge_vec_tv_title")); this.r = (TextView) view.findViewById(findID("mbridge_vec_tv_desc")); this.s = (TextView) view.findViewById(findID("mbridge_vec_btn")); return true; } catch (Throwable th) { af.b("MBridgeVideoEndCoverView", th.getMessage()); return false; } } @Override // com.mbridge.msdk.video.module.MBridgeBaseView public final void c() { super.c(); this.p.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.video.module.MBridgeVideoEndCoverView.1 @Override // android.view.View.OnClickListener public final void onClick(View view) { MBridgeVideoEndCoverView.this.notifyListener.a(104, ""); } }); this.o.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.video.module.MBridgeVideoEndCoverView.2 @Override // android.view.View.OnClickListener public final void onClick(View view) { MBridgeVideoEndCoverView.this.a(); } }); this.s.setOnClickListener(new View.OnClickListener() { // from class: com.mbridge.msdk.video.module.MBridgeVideoEndCoverView.3 @Override // android.view.View.OnClickListener public final void onClick(View view) { MBridgeVideoEndCoverView.this.a(); } }); } public final void a() { JSONObject jSONObject; JSONException e; JSONObject jSONObject2; JSONException e2; try { JSONObject jSONObject3 = new JSONObject(); try { jSONObject2 = new JSONObject(); try { jSONObject2.put(a.h, ak.b(c.m().c(), this.f)); jSONObject2.put(a.i, ak.b(c.m().c(), this.g)); jSONObject2.put(a.m, 0); try { this.d = getContext().getResources().getConfiguration().orientation; } catch (Exception e3) { e3.printStackTrace(); } jSONObject2.put(a.k, this.d); jSONObject2.put(a.l, ak.d(getContext())); } catch (JSONException e4) { e2 = e4; af.b("MBridgeVideoEndCoverView", e2.getMessage()); jSONObject = new JSONObject(); jSONObject.put(a.j, jSONObject2); this.notifyListener.a(105, jSONObject); } } catch (JSONException e5) { jSONObject2 = jSONObject3; e2 = e5; } jSONObject = new JSONObject(); try { jSONObject.put(a.j, jSONObject2); } catch (JSONException e6) { e = e6; e.printStackTrace(); this.notifyListener.a(105, jSONObject); } } catch (JSONException e7) { jSONObject = null; e = e7; } this.notifyListener.a(105, jSONObject); } public void preLoadData(b bVar) { ImageView imageView; this.t = bVar; try { CampaignEx campaignEx = this.b; if (campaignEx == null || !this.e || campaignEx == null) { return; } if (!TextUtils.isEmpty(campaignEx.getIconUrl()) && (imageView = this.o) != null) { com.mbridge.msdk.foundation.same.c.b.a(this.a.getApplicationContext()).a(this.b.getIconUrl(), new j(imageView, ak.a(c.m().c(), 8.0f))); } TextView textView = this.q; if (textView != null) { textView.setText(this.b.getAppName()); } TextView textView2 = this.s; if (textView2 != null) { textView2.setText(this.b.getAdCall()); } TextView textView3 = this.r; if (textView3 != null) { textView3.setText(this.b.getAppDesc()); } } catch (Throwable th) { af.a("MBridgeVideoEndCoverView", th.getMessage()); } } }