MBMediaView.java 源代码
package com.mbridge.msdk.nativex.view;
import android.R;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Base64;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.webkit.URLUtil;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.view.ViewCompat;
import com.anythink.core.api.ATAdConst;
import com.anythink.expressad.foundation.g.h;
import com.anythink.expressad.video.module.a.a.m;
import com.mbridge.msdk.foundation.db.p;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.tools.k;
import com.mbridge.msdk.foundation.tools.q;
import com.mbridge.msdk.foundation.tools.t;
import com.mbridge.msdk.foundation.tools.u;
import com.mbridge.msdk.foundation.tools.x;
import com.mbridge.msdk.foundation.webview.BrowserView;
import com.mbridge.msdk.mbnative.controller.NativeController;
import com.mbridge.msdk.mbsignalcommon.windvane.WindVaneWebView;
import com.mbridge.msdk.nativex.view.MediaViewPlayerView;
import com.mbridge.msdk.nativex.view.mbfullview.BaseView;
import com.mbridge.msdk.nativex.view.mbfullview.MBridgeFullView;
import com.mbridge.msdk.nativex.view.mbfullview.MBridgeTopFullView;
import com.mbridge.msdk.out.Campaign;
import com.mbridge.msdk.out.NativeListener;
import com.mbridge.msdk.out.OnMBMediaViewListener;
import com.mbridge.msdk.out.OnMBMediaViewListenerPlus;
import com.mbridge.msdk.playercommon.VideoPlayerStatusListener;
import com.mbridge.msdk.video.signal.communication.IRewardCommunication;
import com.mbridge.msdk.videocommon.view.MyImageView;
import com.umeng.analytics.pro.ai;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MBMediaView extends LinearLayout implements VideoPlayerStatusListener, IRewardCommunication {
public static final int OPEN_FULLSCREEN_ON_VIDEO_TYPE_1_LANDING_PAGE = 1;
public static final int OPEN_FULLSCREEN_ON_VIDEO_TYPE_2_NORMAL_FULLSCREEN = 2;
public static final int OPEN_FULLSCREEN_ON_VIDEO_TYPE_3_NORMAL_FULLSCREEN_ENDCARD = 3;
public static final int OPEN_FULLSCREEN_ON_VIDEO_TYPE_4_NORMAL_FULLSCREEN_LP = 4;
public static final int OPEN_FULLSCREEN_ON_VIDEO_TYPE_6_SMALLVIDEO = 6;
public static final String TAG = "MBMediaView";
public static final int WHAT_VIEW_FULL_SCREEN = 2;
public static final int WHAT_VIEW_SMALL_SCREEN = 1;
private static int f17879o = 2;
private static int f17880p = 1;
private ProgressBar A;
private View B;
private BaseView C;
private RelativeLayout D;
private RelativeLayout E;
private TextView F;
private ProgressBar G;
private RelativeLayout H;
private int I;
private Handler J;
private CampaignEx K;
private int L;
private int M;
private double N;
private double O;
private int P;
private int Q;
private e R;
private SensorManager S;
private Sensor T;
private com.mbridge.msdk.videocommon.download.a U;
private a V;
private OnMBMediaViewListener W;
private boolean f17881a;
private OnMBMediaViewListenerPlus aa;
private int ab;
private boolean ac;
private boolean ad;
private RelativeLayout ae;
private ImageView af;
private int ag;
private boolean ah;
private Context ai;
private boolean aj;
private Runnable ak;
private boolean f17882b;
private boolean f17883c;
private boolean f17884d;
private boolean f17885e;
private boolean f17886f;
private boolean f17887g;
private boolean f17888h;
private volatile boolean f17889i;
private volatile boolean f17890j;
private boolean f17891k;
private boolean f17892l;
private ArrayList<String> f17893m;
private ArrayList<String> f17894n;
private boolean f17895q;
private boolean f17896r;
private int f17897s;
private MediaViewPlayerView f17898t;
private RelativeLayout f17899u;
private RelativeLayout f17900v;
private RelativeLayout f17901w;
private WindVaneWebViewForNV f17902x;
private WindVaneWebViewForNV f17903y;
private MyImageView f17904z;
public static class AnonymousClass9 {
static final int[] f17922a;
static {
int[] iArr = new int[BaseView.a.values().length];
f17922a = iArr;
try {
iArr[BaseView.a.FULL_MIDDLE_VIEW.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
f17922a[BaseView.a.FULL_TOP_VIEW.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
public enum a {
BIG_IMAGE,
VIDEO,
GIF
}
private static final class b implements Runnable {
WeakReference<MBMediaView> f17927a;
public b(MBMediaView mBMediaView) {
this.f17927a = new WeakReference<>(mBMediaView);
}
@Override
public final void run() {
MBMediaView mBMediaView = this.f17927a.get();
if (mBMediaView != null) {
try {
if (mBMediaView.V != null && mBMediaView.V == a.BIG_IMAGE) {
mBMediaView.e();
mBMediaView.V = a.VIDEO;
mBMediaView.changeNoticeURL();
}
} catch (Throwable th) {
q.a(MBMediaView.TAG, th.getMessage(), th);
}
}
}
}
public static final class d implements com.mbridge.msdk.mbsignalcommon.base.a {
private d() {
}
@Override
public final boolean a(String str) {
try {
if (!TextUtils.isEmpty(str)) {
if (t.a.a(str)) {
t.a(com.mbridge.msdk.foundation.controller.a.e().g(), str, null);
return true;
}
if (URLUtil.isNetworkUrl(str)) {
return false;
}
t.b(com.mbridge.msdk.foundation.controller.a.e().g(), str, null);
return true;
}
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
return false;
}
}
private class e implements SensorEventListener {
private e() {
}
@Override
public final void onAccuracyChanged(Sensor sensor, int i6) {
}
@Override
public final void onSensorChanged(SensorEvent sensorEvent) {
int i6;
if (MBMediaView.this.ah) {
return;
}
try {
float[] fArr = sensorEvent.values;
float f6 = -fArr[0];
float f7 = -fArr[1];
float f8 = -fArr[2];
if (((f6 * f6) + (f7 * f7)) * 4.0f >= f8 * f8) {
i6 = 90 - Math.round(((float) Math.atan2(-f7, f6)) * 57.29578f);
while (i6 >= 360) {
i6 -= 360;
}
while (i6 < 0) {
i6 += 360;
}
} else {
i6 = -1;
}
float A = MBMediaView.this.A();
int j6 = u.j(MBMediaView.this.getContext());
if ((i6 > 45 && i6 < 135) || (i6 > 225 && i6 < 315)) {
if (A >= j6 && !MBMediaView.this.f17890j) {
MBMediaView.this.f17889i = true;
MBMediaView.this.f17890j = true;
MBMediaView.this.J.postDelayed(new Runnable() {
@Override
public final void run() {
try {
com.mbridge.msdk.nativex.view.mbfullview.a.a(MBMediaView.this.getContext()).a(MBMediaView.this.C, MBMediaView.this.f17889i);
MBMediaView.this.D();
MBMediaView.this.h();
MBMediaView.this.f();
MBMediaView.this.g();
if (MBMediaView.this.f17903y != null) {
MBMediaView.this.f17903y.orientation(MBMediaView.this.f17889i);
}
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
}
}, 200L);
return;
}
return;
}
if (((i6 > 135 && i6 < 225) || ((i6 > 315 && i6 < 360) || ((i6 >= 0 && i6 <= 45) || i6 == -1))) && A <= j6 && MBMediaView.this.f17890j) {
MBMediaView.this.f17889i = false;
MBMediaView.this.f17890j = false;
MBMediaView.this.J.postDelayed(new Runnable() {
@Override
public final void run() {
try {
com.mbridge.msdk.nativex.view.mbfullview.a.a(MBMediaView.this.getContext()).a(MBMediaView.this.C, MBMediaView.this.f17889i);
MBMediaView.this.C();
MBMediaView.this.h();
MBMediaView.this.f();
MBMediaView.this.g();
if (MBMediaView.this.f17903y != null) {
MBMediaView.this.f17903y.orientation(MBMediaView.this.f17889i);
}
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
}
}, 200L);
}
} catch (Throwable th) {
q.a(MBMediaView.TAG, th.getMessage(), th);
}
}
}
public static final class f implements com.mbridge.msdk.videocommon.listener.a {
WeakReference<MBMediaView> f17932a;
public f(MBMediaView mBMediaView) {
this.f17932a = new WeakReference<>(mBMediaView);
}
@Override
public final void a(String str, String str2) {
}
@Override
public final void a(String str) {
MBMediaView mBMediaView = this.f17932a.get();
if (mBMediaView != null) {
mBMediaView.J.post(new b(mBMediaView));
}
}
}
public static final class g extends WebViewClient {
WeakReference<MBMediaView> f17933a;
public g(MBMediaView mBMediaView) {
this.f17933a = new WeakReference<>(mBMediaView);
}
@Override
public final void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
try {
MBMediaView mBMediaView = this.f17933a.get();
if (mBMediaView != null && mBMediaView.V != null && mBMediaView.V == a.BIG_IMAGE) {
mBMediaView.l();
mBMediaView.V = a.GIF;
mBMediaView.changeNoticeURL();
}
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
}
}
public MBMediaView(Context context) {
super(context);
this.f17881a = true;
this.f17882b = true;
this.f17883c = true;
this.f17884d = true;
this.f17885e = true;
this.f17886f = false;
this.f17887g = true;
this.f17888h = false;
this.f17889i = false;
this.f17890j = false;
this.f17891k = true;
this.f17892l = true;
this.f17893m = new ArrayList<>();
this.f17894n = new ArrayList<>();
this.f17895q = false;
this.f17896r = false;
this.f17897s = 0;
this.U = null;
this.V = null;
this.ac = false;
this.ad = false;
this.ah = false;
this.aj = false;
this.ak = new Runnable() {
@Override
public final void run() {
try {
if (!MBMediaView.this.f17888h) {
MBMediaView mBMediaView = MBMediaView.this;
if (!mBMediaView.a((View) mBMediaView)) {
MBMediaView.Q(MBMediaView.this);
} else {
MBMediaView.R(MBMediaView.this);
}
}
MBMediaView.this.J.postDelayed(this, 300L);
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
}
};
a(context);
}
static void L(MBMediaView mBMediaView) {
CampaignEx.b mediaViewHolder;
CampaignEx campaignEx = mBMediaView.K;
if (campaignEx != null && (mediaViewHolder = campaignEx.getMediaViewHolder()) != null && !mediaViewHolder.f16698b && mBMediaView.K.getNativeVideoTracking() != null && mBMediaView.K.getNativeVideoTracking().c() != null) {
mediaViewHolder.f16698b = true;
Context context = mBMediaView.getContext();
CampaignEx campaignEx2 = mBMediaView.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), mBMediaView.K.getNativeVideoTracking().c(), false, false);
}
}
static void M(MBMediaView mBMediaView) {
CampaignEx.b mediaViewHolder;
CampaignEx campaignEx = mBMediaView.K;
if (campaignEx != null && (mediaViewHolder = campaignEx.getMediaViewHolder()) != null && !mediaViewHolder.f16699c && mBMediaView.K.getNativeVideoTracking() != null && mBMediaView.K.getNativeVideoTracking().d() != null) {
mediaViewHolder.f16699c = true;
Context context = mBMediaView.getContext();
CampaignEx campaignEx2 = mBMediaView.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), mBMediaView.K.getNativeVideoTracking().d(), false, false);
}
}
static void N(MBMediaView mBMediaView) {
CampaignEx.b mediaViewHolder;
CampaignEx campaignEx = mBMediaView.K;
if (campaignEx != null && (mediaViewHolder = campaignEx.getMediaViewHolder()) != null && !mediaViewHolder.f16701e && mBMediaView.K.getNativeVideoTracking() != null && mBMediaView.K.getNativeVideoTracking().f() != null) {
mediaViewHolder.f16701e = true;
Context context = mBMediaView.getContext();
CampaignEx campaignEx2 = mBMediaView.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), mBMediaView.K.getNativeVideoTracking().f(), false, false);
}
}
static void O(MBMediaView mBMediaView) {
CampaignEx.b mediaViewHolder;
CampaignEx campaignEx = mBMediaView.K;
if (campaignEx != null && (mediaViewHolder = campaignEx.getMediaViewHolder()) != null && !mediaViewHolder.f16702f && mBMediaView.K.getNativeVideoTracking() != null && mBMediaView.K.getNativeVideoTracking().g() != null) {
mediaViewHolder.f16702f = true;
Context context = mBMediaView.getContext();
CampaignEx campaignEx2 = mBMediaView.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), mBMediaView.K.getNativeVideoTracking().g(), false, false);
}
}
static void Q(MBMediaView mBMediaView) {
try {
MediaViewPlayerView mediaViewPlayerView = mBMediaView.f17898t;
if (mediaViewPlayerView != null && mediaViewPlayerView.hasPrepare() && mBMediaView.f17898t.isPlaying()) {
try {
MediaViewPlayerView mediaViewPlayerView2 = mBMediaView.f17898t;
if (mediaViewPlayerView2 != null) {
mediaViewPlayerView2.pause();
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
} catch (Throwable th2) {
q.d(TAG, th2.getMessage());
}
}
static void R(MBMediaView mBMediaView) {
try {
MediaViewPlayerView mediaViewPlayerView = mBMediaView.f17898t;
if (mediaViewPlayerView != null && mediaViewPlayerView.hasPrepare() && !mBMediaView.f17898t.isPlaying() && !mBMediaView.f17898t.isComplete() && mBMediaView.f17898t.hasPrepare()) {
mBMediaView.f17898t.startOrPlayVideo();
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void h() {
try {
if (this.V != a.VIDEO || this.f17899u == null) {
return;
}
int A = (int) A();
int j6 = u.j(getContext());
if (!this.f17888h) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.f17899u.getLayoutParams();
layoutParams.width = this.M;
layoutParams.height = this.L;
layoutParams.addRule(13);
this.f17899u.setLayoutParams(layoutParams);
} else {
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) this.D.getLayoutParams();
layoutParams2.width = A;
layoutParams2.height = j6;
layoutParams2.addRule(13);
this.D.setLayoutParams(layoutParams2);
}
q();
if (!this.f17888h) {
a(this.f17898t, this.M, this.L);
} else {
a(this.f17898t, A, j6);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private void i() {
try {
this.f17898t.showSoundIndicator(this.f17892l);
this.f17898t.showProgressView(this.f17891k);
OnMBMediaViewListener onMBMediaViewListener = this.W;
if (onMBMediaViewListener != null) {
onMBMediaViewListener.onExitFullscreen();
}
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = this.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onExitFullscreen();
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private void m() {
try {
CampaignEx campaignEx = this.K;
if (campaignEx == null) {
return;
}
String imageUrl = campaignEx.getImageUrl();
if (x.a(imageUrl) || getContext() == null) {
return;
}
com.mbridge.msdk.foundation.same.c.b.a(com.mbridge.msdk.foundation.controller.a.e().g()).a(imageUrl, new com.mbridge.msdk.foundation.same.c.c() {
@Override
public final void onFailedLoad(String str, String str2) {
}
@Override
public final void onSuccessLoad(Bitmap bitmap, String str) {
if (MBMediaView.this.f17904z != null && MBMediaView.this.V == a.BIG_IMAGE) {
if (bitmap != null) {
MBMediaView.this.P = bitmap.getWidth();
MBMediaView.this.Q = bitmap.getHeight();
MBMediaView.this.f17904z.setImageUrl(str);
MBMediaView.this.f17904z.setImageBitmap(bitmap);
}
MBMediaView.this.f17904z.setOnClickListener(new com.mbridge.msdk.widget.a() {
@Override
protected final void a(View view) {
if (MBMediaView.this.ai == null) {
MBMediaView.this.b(view.getContext());
} else {
MBMediaView mBMediaView = MBMediaView.this;
mBMediaView.b(mBMediaView.ai);
}
}
});
}
}
});
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
private void n() {
try {
CampaignEx campaignEx = this.K;
if (campaignEx == null) {
return;
}
String gifUrl = campaignEx.getGifUrl();
if (x.a(gifUrl) || getContext() == null) {
return;
}
this.f17902x.loadDataWithBaseURL(null, "<!DOCTYPE html><html lang=\"en\"><head> <meta charset=\"UTF-8\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"> <title>Document</title> <style> *{ margin: 0; padding: 0; } html, body{ width: 100%; height: 100%; } body{ background-image: url('gifUrl'); background-position: center; background-size: contain; background-repeat: no-repeat; } </style></head><body></body></html>".replace("gifUrl", gifUrl), "text/html", com.anythink.expressad.foundation.f.a.F, null);
this.f17902x.setInterceptTouch(true);
this.f17901w.setOnClickListener(new com.mbridge.msdk.widget.a() {
@Override
protected final void a(View view) {
if (MBMediaView.this.ai == null) {
MBMediaView.this.b(view.getContext());
} else {
MBMediaView mBMediaView = MBMediaView.this;
mBMediaView.b(mBMediaView.ai);
}
q.b(MBMediaView.TAG, "CLICK WEBVIEW LAYOUT ");
}
});
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public String o() {
try {
CampaignEx campaignEx = this.K;
if (campaignEx == null || !x.b(campaignEx.getCampaignUnitId())) {
return null;
}
return this.K.getCampaignUnitId();
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
return null;
}
}
private void p() {
try {
if (this.K == null) {
q.b(TAG, "campaign is null addPlayerView return");
}
MediaViewPlayerView mediaViewPlayerView = this.f17898t;
if (mediaViewPlayerView != null && mediaViewPlayerView.getParent() != null) {
((ViewGroup) this.f17898t.getParent()).removeView(this.f17898t);
}
k();
MediaViewPlayerView mediaViewPlayerView2 = new MediaViewPlayerView(getContext());
this.f17898t = mediaViewPlayerView2;
mediaViewPlayerView2.showProgressView(this.f17891k);
this.f17898t.showSoundIndicator(this.f17892l);
if (this.f17886f) {
this.f17898t.openSound();
} else {
this.f17898t.closeSound();
}
this.f17898t.setAllowLoopPlay(this.f17882b);
this.f17898t.initPlayerViewData(r(), this.K, u(), this, this.U, o());
this.f17898t.setOnMediaViewPlayerViewListener(new c(this));
this.f17899u.addView(this.f17898t, -1, -1);
try {
MediaViewPlayerView mediaViewPlayerView3 = this.f17898t;
if (mediaViewPlayerView3 == null) {
return;
}
mediaViewPlayerView3.setOnClickListener(new com.mbridge.msdk.widget.a() {
@Override
protected final void a(View view) {
try {
if (!MBMediaView.this.f17888h) {
MBMediaView.d(MBMediaView.this);
}
MBMediaView.this.f17898t.showSoundIndicator(true);
MBMediaView.this.f17898t.showProgressView(true);
if (MBMediaView.this.f17884d && !MBMediaView.this.f17888h && (MBMediaView.this.B == null || MBMediaView.this.B.getParent() == null)) {
if (!MBMediaView.this.f17898t.halfLoadingViewisVisible() && MBMediaView.this.f17898t.isPlaying()) {
MBMediaView.h(MBMediaView.this);
return;
}
q.b(MBMediaView.TAG, "is loading or no playing return;");
return;
}
if (MBMediaView.this.f17888h) {
q.b(MBMediaView.TAG, "fullScreenShowUI");
MBMediaView.i(MBMediaView.this);
} else if (MBMediaView.this.ai == null) {
MBMediaView.this.b(view.getContext());
} else {
MBMediaView mBMediaView = MBMediaView.this;
mBMediaView.b(mBMediaView.ai);
}
} catch (Throwable th) {
q.a(MBMediaView.TAG, th.getMessage(), th);
}
}
});
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
} catch (Throwable th2) {
q.d(TAG, th2.getMessage());
}
}
@Override
public void cai(Object obj, String str) {
int i6;
q.a(TAG, "cai:" + str);
if (TextUtils.isEmpty(str)) {
com.mbridge.msdk.mbsignalcommon.communication.b.a(obj, "params is null");
return;
}
if (!TextUtils.isEmpty(str)) {
try {
try {
String optString = new JSONObject(str).optString("packageName");
if (TextUtils.isEmpty(optString)) {
com.mbridge.msdk.mbsignalcommon.communication.b.a(obj, "packageName is empty");
}
if (u.c(com.mbridge.msdk.foundation.controller.a.e().g(), optString)) {
i6 = 1;
} else {
i6 = 2;
}
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("code", com.mbridge.msdk.mbsignalcommon.communication.b.f17803b);
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("result", i6);
jSONObject.put("data", jSONObject2);
com.mbridge.msdk.mbsignalcommon.windvane.g.a().a(obj, Base64.encodeToString(jSONObject.toString().getBytes(), 2));
} catch (Exception e6) {
com.mbridge.msdk.mbsignalcommon.communication.b.a(obj, e6.getMessage());
q.a(TAG, e6.getMessage());
}
} catch (Throwable th) {
com.mbridge.msdk.mbsignalcommon.communication.b.a(obj, "exception: " + th.getLocalizedMessage());
q.a(TAG, "cai", th);
}
} catch (JSONException e7) {
com.mbridge.msdk.mbsignalcommon.communication.b.a(obj, "exception: " + e7.getLocalizedMessage());
q.a(TAG, "cai", e7);
}
}
}
public boolean canShowVideo() {
if (a(false) != a.VIDEO) {
return false;
}
return true;
}
public void changeNoticeURL() {
String str;
CampaignEx campaignEx = this.K;
if (campaignEx != null) {
String noticeUrl = campaignEx.getNoticeUrl();
if (!TextUtils.isEmpty(noticeUrl)) {
if (noticeUrl.contains("is_video")) {
a aVar = this.V;
if (aVar == a.VIDEO) {
if (noticeUrl.contains("is_video=2")) {
noticeUrl = noticeUrl.replace("is_video=2", "is_video=1");
}
} else if (aVar == a.BIG_IMAGE && noticeUrl.contains("is_video=1")) {
noticeUrl = noticeUrl.replace("is_video=1", "is_video=2");
}
} else {
a aVar2 = this.V;
if (aVar2 == a.VIDEO) {
str = "1";
} else if (aVar2 == a.BIG_IMAGE) {
str = "2";
} else {
str = "";
}
StringBuilder sb = new StringBuilder(noticeUrl);
if (noticeUrl.contains("?")) {
sb.append("&is_video=");
sb.append(str);
} else {
sb.append("?is_video=");
sb.append(str);
}
noticeUrl = sb.toString();
}
this.K.setNoticeUrl(noticeUrl);
}
}
}
public void destory() {
try {
MediaViewPlayerView mediaViewPlayerView = this.f17898t;
if (mediaViewPlayerView != null) {
mediaViewPlayerView.release();
}
a();
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void exitFullScreen() {
try {
w();
if (this.f17882b) {
this.f17898t.onClickPlayButton();
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
public String getAddNVT2ToNoticeURL() {
CampaignEx campaignEx = this.K;
if (campaignEx != null) {
String noticeUrl = campaignEx.getNoticeUrl();
if (!TextUtils.isEmpty(noticeUrl) && !noticeUrl.contains("nv_t2")) {
return noticeUrl + "&nv_t2=" + this.K.getNvT2();
}
return noticeUrl;
}
return null;
}
@Override
public void getEndScreenInfo(Object obj, String str) {
String str2;
try {
ArrayList arrayList = new ArrayList();
arrayList.add(this.K);
String a7 = a(arrayList, o(), "MAL_16.0.11,3.0.1");
if (!TextUtils.isEmpty(a7)) {
str2 = Base64.encodeToString(a7.getBytes(), 2);
} else {
str2 = "";
}
q.d(TAG, "getEndScreenInfo-mCampaign.name:" + this.K.getAppName());
com.mbridge.msdk.mbsignalcommon.windvane.g.a().a(obj, str2);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public BaseView getFullScreenViewByStyle(Context context, BaseView.a aVar) {
BaseView mBridgeFullView;
BaseView baseView;
int i6 = AnonymousClass9.f17922a[aVar.ordinal()];
if (i6 != 1) {
if (i6 != 2) {
baseView = null;
baseView.setStytle(aVar);
return baseView;
}
mBridgeFullView = new MBridgeTopFullView(context);
} else {
mBridgeFullView = new MBridgeFullView(context);
}
baseView = mBridgeFullView;
baseView.setStytle(aVar);
return baseView;
}
public BaseView.a handleViewStyleResult(Context context) {
int nvT2 = this.K.getNvT2();
if (nvT2 != 1) {
if (nvT2 != 2 && nvT2 != 3 && nvT2 != 4) {
if (nvT2 == 6) {
return BaseView.a.FULL_TOP_VIEW;
}
} else {
return BaseView.a.FULL_MIDDLE_VIEW;
}
} else {
b(context);
}
return null;
}
@Override
public void handlerPlayableException(Object obj, String str) {
}
public void hideEndCardWebViewCloseBtn() {
ImageView imageView = this.af;
if (imageView != null && imageView.getVisibility() == 0) {
this.af.setVisibility(8);
}
}
@Override
public void install(Object obj, String str) {
WindVaneWebView windVaneWebView;
try {
Context context = this.ai;
if (context != null) {
b(context);
} else if ((obj instanceof com.mbridge.msdk.mbsignalcommon.windvane.a) && (windVaneWebView = ((com.mbridge.msdk.mbsignalcommon.windvane.a) obj).f17834a) != null) {
b(windVaneWebView.getContext());
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
public boolean ismCurIsFullScreen() {
return this.f17888h;
}
@Override
public void notifyCloseBtn(Object obj, String str) {
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
try {
if (this.f17883c) {
try {
SensorManager sensorManager = (SensorManager) getContext().getSystemService(ai.ac);
this.S = sensorManager;
this.T = sensorManager.getDefaultSensor(1);
e eVar = new e();
this.R = eVar;
this.S.registerListener(eVar, this.T, 2);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
this.f17887g = isHardwareAccelerated();
this.ag = getOrientation();
d();
this.J.postDelayed(this.ak, m.ad);
} catch (Throwable th2) {
q.d(TAG, th2.getMessage());
}
}
@Override
public void onBufferingEnd() {
q.b("bufferend", "bufferend");
}
@Override
public void onBufferingStart(String str) {
q.b("bufferMsg", str);
}
@Override
protected void onConfigurationChanged(Configuration configuration) {
boolean z6;
super.onConfigurationChanged(configuration);
if (this.ah) {
int i6 = this.ag;
int i7 = configuration.orientation;
if (i6 == i7) {
return;
}
this.ag = i7;
boolean z7 = true;
if (i7 == 0) {
z6 = true;
} else {
z6 = false;
}
this.f17889i = z6;
if (this.ag != 0) {
z7 = false;
}
this.f17890j = z7;
this.J.postDelayed(new Runnable() {
@Override
public final void run() {
try {
com.mbridge.msdk.nativex.view.mbfullview.a.a(MBMediaView.this.getContext()).a(MBMediaView.this.C, MBMediaView.this.f17889i);
if (MBMediaView.this.ag == 0) {
MBMediaView.this.D();
} else {
MBMediaView.this.C();
}
MBMediaView.this.h();
MBMediaView.this.f();
MBMediaView.this.g();
if (MBMediaView.this.f17903y != null) {
MBMediaView.this.f17903y.orientation(MBMediaView.this.f17889i);
}
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
}
}, 200L);
}
}
@Override
protected void onDetachedFromWindow() {
e eVar;
super.onDetachedFromWindow();
try {
this.J.removeCallbacks(this.ak);
Handler handler = this.J;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
try {
SensorManager sensorManager = this.S;
if (sensorManager != null && (eVar = this.R) != null) {
sensorManager.unregisterListener(eVar);
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
a();
} catch (Throwable th2) {
q.d(TAG, th2.getMessage());
}
}
@Override
protected void onMeasure(int i6, int i7) {
super.onMeasure(i6, i7);
try {
this.L = getHeight();
int width = getWidth();
this.M = width;
if (width == 0) {
this.M = getMeasuredWidth();
}
if (this.L == 0) {
this.L = getMeasuredHeight();
}
if (this.M == 0 && this.L == 0) {
this.M = (int) A();
}
a aVar = this.V;
if (aVar == a.VIDEO && !this.f17888h) {
ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (this.L == 0 || ((layoutParams != null && layoutParams.height == -2) || (layoutParams != null && layoutParams.height == -1))) {
this.L = (int) ((this.M * this.O) / this.N);
}
h();
return;
}
if (aVar == a.BIG_IMAGE && !this.f17888h) {
f();
} else if (aVar == a.GIF && !this.f17888h) {
g();
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
@Override
public void onPlayCompleted() {
}
@Override
public void onPlayError(String str) {
com.mbridge.msdk.foundation.entity.m mVar;
try {
q.b("error", str);
CampaignEx campaignEx = this.K;
if (campaignEx != null && campaignEx.getMediaViewHolder() != null && !this.K.getMediaViewHolder().f16700d && !TextUtils.isEmpty(this.K.getCampaignUnitId()) && this.K.getNativeVideoTracking() != null && this.K.getNativeVideoTracking().h() != null) {
this.K.getMediaViewHolder().f16700d = true;
Context context = getContext();
CampaignEx campaignEx2 = this.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), this.K.getNativeVideoTracking().h(), false, false);
}
try {
p a7 = p.a(com.mbridge.msdk.foundation.db.g.a(getContext()));
if (!TextUtils.isEmpty(this.K.getNoticeUrl())) {
int n6 = com.mbridge.msdk.foundation.tools.m.n(getContext());
mVar = new com.mbridge.msdk.foundation.entity.m(com.anythink.expressad.foundation.d.p.f3621b, n6, this.K.getNoticeUrl(), str, com.mbridge.msdk.foundation.tools.m.a(getContext(), n6));
} else if (!TextUtils.isEmpty(this.K.getClickURL())) {
int n7 = com.mbridge.msdk.foundation.tools.m.n(getContext());
mVar = new com.mbridge.msdk.foundation.entity.m(com.anythink.expressad.foundation.d.p.f3621b, n7, this.K.getClickURL(), str, com.mbridge.msdk.foundation.tools.m.a(getContext(), n7));
} else {
mVar = null;
}
if (mVar != null) {
mVar.n(this.K.getId());
mVar.e(this.K.getVideoUrlEncode());
mVar.p(str);
mVar.k(this.K.getRequestId());
mVar.l(this.K.getRequestIdNotice());
mVar.m(o());
a7.a(mVar);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
NativeController.insertExcludeId(this.K.getCampaignUnitId(), this.K);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
@Override
public void onPlayProgress(int i6, int i7) {
int i8;
String str;
CampaignEx.b mediaViewHolder;
CampaignEx.b mediaViewHolder2;
Map<Integer, String> map;
try {
CampaignEx campaignEx = this.K;
if (campaignEx != null && (mediaViewHolder2 = campaignEx.getMediaViewHolder()) != null && !mediaViewHolder2.f16704h && (map = mediaViewHolder2.f16708l) != null && map.size() > 0) {
Map<Integer, String> map2 = mediaViewHolder2.f16708l;
Iterator<Map.Entry<Integer, String>> it = map2.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, String> next = it.next();
Integer key = next.getKey();
String value = next.getValue();
if (i6 >= key.intValue() && !TextUtils.isEmpty(value)) {
Context context = getContext();
CampaignEx campaignEx2 = this.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), value, false, false);
it.remove();
}
}
if (map2.size() <= 0) {
mediaViewHolder2.f16704h = true;
}
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
int i9 = 0;
try {
CampaignEx campaignEx3 = this.K;
if (campaignEx3 != null && (mediaViewHolder = campaignEx3.getMediaViewHolder()) != null && !mediaViewHolder.f16705i && i7 != 0) {
List<Map<Integer, String>> b6 = this.K.getNativeVideoTracking().b();
int i10 = ((i6 + 1) * 100) / i7;
if (b6 != null) {
int i11 = 0;
while (i11 < b6.size()) {
Map<Integer, String> map3 = b6.get(i11);
if (map3 != null && map3.size() > 0) {
Iterator<Map.Entry<Integer, String>> it2 = map3.entrySet().iterator();
while (it2.hasNext()) {
Map.Entry<Integer, String> next2 = it2.next();
int intValue = next2.getKey().intValue();
String value2 = next2.getValue();
if (intValue <= i10 && !TextUtils.isEmpty(value2)) {
Context context2 = getContext();
CampaignEx campaignEx4 = this.K;
com.mbridge.msdk.click.a.a(context2, campaignEx4, campaignEx4.getCampaignUnitId(), new String[]{value2}, false, true);
it2.remove();
b6.remove(i11);
i11--;
}
}
}
i11++;
}
if (b6.size() <= 0) {
mediaViewHolder.f16705i = true;
}
}
}
} catch (Throwable unused) {
q.d(TAG, "reportPlayPercentageData error");
}
if (s() != 100 && !this.aj) {
if (t() != null) {
i9 = t().f();
}
int s6 = s();
if (s6 == 0) {
return;
}
if (i9 > s6) {
i9 = s6 / 2;
}
if (i9 >= 0 && i6 >= (i8 = (i9 * i7) / 100)) {
if (this.K.getAdType() != 94 && this.K.getAdType() != 287) {
str = this.K.getId() + this.K.getVideoUrlEncode() + this.K.getBidToken();
} else {
str = this.K.getRequestId() + this.K.getId() + this.K.getVideoUrlEncode();
}
com.mbridge.msdk.videocommon.download.a a7 = com.mbridge.msdk.videocommon.download.c.getInstance().a(o(), str);
if (a7 != null) {
a7.j();
this.aj = true;
q.d(TAG, "CDRate is : " + i8 + " and start download !");
}
}
}
}
@Override
public void onPlayProgressMS(int i6, int i7) {
}
@Override
public void onPlaySetDataSourceError(String str) {
q.b("errorstr", str);
}
@Override
public void onPlayStarted(int i6) {
}
@Override
public void onWindowFocusChanged(boolean z6) {
MediaViewPlayerView mediaViewPlayerView;
super.onWindowFocusChanged(z6);
try {
this.f17885e = z6;
if (this.V == a.VIDEO && (mediaViewPlayerView = this.f17898t) != null) {
mediaViewPlayerView.setIsFrontDesk(z6);
}
try {
if (this.f17888h) {
MediaViewPlayerView mediaViewPlayerView2 = this.f17898t;
if (mediaViewPlayerView2 != null) {
if (this.f17885e) {
if (mediaViewPlayerView2.isPlaying()) {
q.b(TAG, "fullscreen windowfocuse true isPlaying do nothing return");
} else {
MediaViewPlayerView mediaViewPlayerView3 = this.f17898t;
if (mediaViewPlayerView3 != null && !mediaViewPlayerView3.isComplete() && !this.f17898t.getIsActiviePause()) {
this.f17898t.onClickPlayButton();
}
}
} else {
mediaViewPlayerView2.pause();
}
} else {
q.d(TAG, "fullscreen playerview is null return");
}
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
requestLayout();
} catch (Throwable th2) {
q.d(TAG, th2.getMessage());
}
}
@Override
public void openURL(Object obj, String str) {
WindVaneWebView windVaneWebView;
q.d(TAG, "openURL:" + str);
if (TextUtils.isEmpty(str)) {
com.mbridge.msdk.mbsignalcommon.communication.b.a(obj, "params is null");
return;
}
Context g6 = com.mbridge.msdk.foundation.controller.a.e().g();
if (!TextUtils.isEmpty(str)) {
if (g6 == null) {
try {
if ((obj instanceof com.mbridge.msdk.mbsignalcommon.windvane.a) && (windVaneWebView = ((com.mbridge.msdk.mbsignalcommon.windvane.a) obj).f17834a) != null) {
g6 = windVaneWebView.getContext();
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
if (g6 == null) {
return;
}
try {
JSONObject jSONObject = new JSONObject(str);
String optString = jSONObject.optString("url");
int optInt = jSONObject.optInt("type");
if (optInt == 1) {
com.mbridge.msdk.click.b.a(g6, optString);
} else if (optInt == 2) {
com.mbridge.msdk.click.b.b(g6, optString);
}
} catch (JSONException e7) {
q.d(TAG, e7.getMessage());
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
}
public void setAllowLoopPlay(boolean z6) {
this.f17882b = z6;
}
public void setAllowScreenChange(boolean z6) {
this.f17883c = z6;
}
public void setAllowVideoRefresh(boolean z6) {
this.f17881a = z6;
}
public void setFollowActivityOrientation(boolean z6) {
this.ah = z6;
}
public void setFullScreenViewBackgroundColor(int i6) {
this.f17897s = i6;
}
public void setIsAllowFullScreen(boolean z6) {
this.f17884d = z6;
}
public void setNativeAd(Campaign campaign) {
String str;
if (campaign == null) {
return;
}
try {
CampaignEx campaignEx = this.K;
if (campaignEx != null && campaignEx == campaign) {
return;
}
this.f17885e = true;
this.f17887g = true;
this.f17888h = false;
this.f17889i = false;
this.f17890j = false;
this.f17896r = false;
y();
CampaignEx campaignEx2 = (CampaignEx) campaign;
this.K = campaignEx2;
if (campaignEx2.getMediaViewHolder() == null) {
CampaignEx.b bVar = new CampaignEx.b();
bVar.f16708l = this.K.getAdvImpList();
this.K.setMediaViewHolder(bVar);
}
if (this.K.getAdType() != 94 && this.K.getAdType() != 287) {
str = this.K.getId() + this.K.getVideoUrlEncode() + this.K.getBidToken();
this.U = com.mbridge.msdk.videocommon.download.c.getInstance().a(o(), str);
if (!this.f17895q) {
d();
return;
}
return;
}
str = this.K.getRequestId() + this.K.getId() + this.K.getVideoUrlEncode();
this.U = com.mbridge.msdk.videocommon.download.c.getInstance().a(o(), str);
if (!this.f17895q) {
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void setOnMediaViewListener(OnMBMediaViewListener onMBMediaViewListener) {
this.W = onMBMediaViewListener;
}
@Override
public void setOrientation(Object obj, String str) {
}
public void setProgressVisibility(boolean z6) {
this.f17891k = z6;
MediaViewPlayerView mediaViewPlayerView = this.f17898t;
if (mediaViewPlayerView != null) {
mediaViewPlayerView.showProgressView(z6);
}
}
public void setSoundIndicatorVisibility(boolean z6) {
this.f17892l = z6;
MediaViewPlayerView mediaViewPlayerView = this.f17898t;
if (mediaViewPlayerView != null) {
mediaViewPlayerView.showSoundIndicator(z6);
}
}
public void setVideoSoundOnOff(boolean z6) {
this.f17886f = z6;
MediaViewPlayerView mediaViewPlayerView = this.f17898t;
if (mediaViewPlayerView != null) {
if (z6) {
mediaViewPlayerView.openSound();
} else {
mediaViewPlayerView.closeSound();
}
}
}
public void showEndCardWebViewCloseBtn() {
ImageView imageView = this.af;
if (imageView != null && imageView.getVisibility() != 0) {
this.af.setVisibility(0);
}
}
@Override
public void toggleCloseBtn(Object obj, String str) {
try {
if (!TextUtils.isEmpty(str)) {
try {
new JSONObject(str).optInt("state", 1);
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
q.d(TAG, "SHOW CLOSE BTN ");
showEndCardWebViewCloseBtn();
com.mbridge.msdk.mbsignalcommon.windvane.g.a().a(obj, a(0));
} catch (Exception e7) {
q.d(TAG, e7.getMessage());
com.mbridge.msdk.mbsignalcommon.windvane.g.a().b(obj, a(1));
}
}
@Override
public void triggerCloseBtn(Object obj, String str) {
try {
exitFullScreen();
com.mbridge.msdk.mbsignalcommon.windvane.g.a().a(obj, a(0));
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
com.mbridge.msdk.mbsignalcommon.windvane.g.a().b(obj, a(1));
}
}
public void updateViewManger(boolean z6) {
boolean z7;
com.mbridge.msdk.nativex.view.mbfullview.a a7 = com.mbridge.msdk.nativex.view.mbfullview.a.a(getContext());
boolean z8 = true;
int i6 = 0;
if (a7 != null) {
try {
this.C.getmAnimationPlayer().clearAnimation();
if (!this.f17898t.isComplete()) {
z7 = true;
} else {
z7 = false;
}
a7.a(z6, z7, this.C);
a7.a(z6, this.C, this.ab);
} catch (NullPointerException e6) {
e6.printStackTrace();
return;
}
}
BaseView baseView = this.C;
if ((baseView instanceof MBridgeTopFullView) && a7 != null) {
if (z6) {
z8 = false;
}
if (baseView instanceof MBridgeTopFullView) {
MBridgeTopFullView mBridgeTopFullView = (MBridgeTopFullView) baseView;
if (!z8) {
i6 = 8;
}
mBridgeTopFullView.getMBridgeFullViewDisplayIcon().setVisibility(i6);
mBridgeTopFullView.getMBridgeFullViewDisplayTitle().setVisibility(i6);
mBridgeTopFullView.getMBridgeFullViewDisplayDscription().setVisibility(i6);
mBridgeTopFullView.getStarLevelLayoutView().setVisibility(i6);
}
}
}
public static final class c implements com.mbridge.msdk.nativex.listener.a {
WeakReference<MBMediaView> f17928a;
public c(MBMediaView mBMediaView) {
this.f17928a = new WeakReference<>(mBMediaView);
}
@Override
public final void a() {
MBMediaView mBMediaView = this.f17928a.get();
if (mBMediaView != null) {
MBMediaView.L(mBMediaView);
}
}
@Override
public final void b() {
MBMediaView mBMediaView = this.f17928a.get();
if (mBMediaView != null) {
MBMediaView.M(mBMediaView);
}
}
@Override
public final void c() {
MBMediaView mBMediaView = this.f17928a.get();
if (mBMediaView != null) {
MBMediaView.N(mBMediaView);
}
}
@Override
public final void d() {
MBMediaView mBMediaView = this.f17928a.get();
if (mBMediaView != null) {
MBMediaView.O(mBMediaView);
}
}
@Override
public final void a(String str) {
MBMediaView mBMediaView = this.f17928a.get();
if (mBMediaView != null) {
mBMediaView.a(str);
}
}
@Override
public final void b(String str) {
MBMediaView mBMediaView = this.f17928a.get();
if (mBMediaView != null) {
mBMediaView.b(str);
}
}
}
public float A() {
try {
float i6 = u.i(getContext());
return this.f17889i ? i6 + u.k(getContext()) : i6;
} catch (Throwable th) {
q.d(TAG, th.getMessage());
return 0.0f;
}
}
private float B() {
try {
float j6 = u.j(getContext());
return !this.f17889i ? j6 + u.k(getContext()) : j6;
} catch (Throwable th) {
q.d(TAG, th.getMessage());
return 0.0f;
}
}
public void C() {
try {
if (this.E == null && this.af == null) {
return;
}
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(u.b(getContext(), 30.0f), u.b(getContext(), 30.0f));
layoutParams.addRule(11);
layoutParams.addRule(10);
layoutParams.topMargin = u.b(getContext(), 8.0f);
layoutParams.rightMargin = u.b(getContext(), 8.0f);
RelativeLayout relativeLayout = this.E;
if (relativeLayout != null) {
relativeLayout.setLayoutParams(layoutParams);
}
ImageView imageView = this.af;
if (imageView != null) {
imageView.setLayoutParams(layoutParams);
}
updateViewManger(false);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void D() {
try {
if (this.E == null && this.af == null) {
return;
}
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(u.b(getContext(), 30.0f), u.b(getContext(), 30.0f));
layoutParams.addRule(11);
layoutParams.addRule(10);
if (this.ab == 0 && com.mbridge.msdk.foundation.tools.g.a(getContext())) {
layoutParams.rightMargin = u.k(getContext()) + u.b(getContext(), 8.0f);
} else {
layoutParams.rightMargin = u.b(getContext(), 8.0f);
}
layoutParams.topMargin = u.b(getContext(), 8.0f);
RelativeLayout relativeLayout = this.E;
if (relativeLayout != null) {
relativeLayout.setLayoutParams(layoutParams);
}
ImageView imageView = this.af;
if (imageView != null) {
imageView.setLayoutParams(layoutParams);
}
updateViewManger(true);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
private void E() {
int i6;
try {
CampaignEx campaignEx = this.K;
if (campaignEx == null || campaignEx.getNativeVideoTracking() == null) {
return;
}
String[] a7 = this.K.getNativeVideoTracking().a();
if (this.f17889i) {
i6 = f17879o;
} else {
i6 = f17880p;
}
for (String str : a7) {
if (!TextUtils.isEmpty(str)) {
Context context = getContext();
CampaignEx campaignEx2 = this.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), str + "&orienation=" + i6, false, false);
}
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
public WindVaneWebViewForNV F() {
try {
WindVaneWebViewForNV windVaneWebViewForNV = this.f17903y;
if (windVaneWebViewForNV != null && this.ad) {
return windVaneWebViewForNV;
}
if (this.ad) {
return null;
}
b(true);
return null;
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
return null;
}
}
private void d() {
try {
this.V = a(true);
changeNoticeURL();
a aVar = this.V;
if (aVar == a.BIG_IMAGE) {
j();
m();
} else if (aVar == a.VIDEO) {
e();
} else if (aVar == a.GIF) {
n();
l();
}
this.f17895q = true;
} catch (Throwable th) {
q.a(TAG, th.getMessage(), th);
}
}
public void e() {
z();
k();
}
public void f() {
int i6;
int i7;
int i8;
try {
if (this.V != a.BIG_IMAGE || (i6 = this.M) == 0 || (i7 = this.Q) == 0 || (i8 = this.P) == 0) {
return;
}
int i9 = (i6 * i7) / i8;
MyImageView myImageView = this.f17904z;
if (myImageView == null || i9 == 0) {
return;
}
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) myImageView.getLayoutParams();
layoutParams.width = this.M;
layoutParams.height = i9;
this.f17904z.setLayoutParams(layoutParams);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void g() {
RelativeLayout relativeLayout;
int i6;
int i7;
try {
if (this.V == a.GIF) {
int i8 = this.M;
if (i8 != 0 && (i6 = this.Q) != 0 && (i7 = this.P) != 0) {
int i9 = (i8 * i6) / i7;
RelativeLayout relativeLayout2 = this.f17901w;
if (relativeLayout2 != null && i9 != 0) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) relativeLayout2.getLayoutParams();
layoutParams.width = this.M;
layoutParams.height = i9;
layoutParams.addRule(13);
this.f17901w.setLayoutParams(layoutParams);
}
} else if (i8 != 0 && (relativeLayout = this.f17901w) != null) {
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams();
int i10 = this.M;
layoutParams2.width = i10;
layoutParams2.height = (i10 * 627) / 1200;
layoutParams2.addRule(13);
this.f17901w.setLayoutParams(layoutParams2);
}
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
private void j() {
try {
u.a((ImageView) this.f17904z);
this.f17904z.setVisibility(0);
this.f17899u.setVisibility(8);
this.f17901w.setVisibility(8);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
private void k() {
try {
this.f17899u.setVisibility(0);
this.f17904z.setVisibility(8);
this.f17901w.setVisibility(8);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void l() {
try {
this.f17899u.setVisibility(8);
this.f17904z.setVisibility(8);
this.f17901w.setVisibility(0);
this.f17902x.setVisibility(0);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void q() {
try {
if (getVisibility() != 0) {
return;
}
if (a((View) this)) {
com.mbridge.msdk.b.d t6 = t();
int d6 = t6 != null ? t6.d() : 0;
Message obtainMessage = this.J.obtainMessage();
obtainMessage.what = 3;
obtainMessage.obj = this;
this.J.sendMessageDelayed(obtainMessage, d6 * 1000);
}
if (this.V == a.VIDEO) {
MediaViewPlayerView mediaViewPlayerView = this.f17898t;
if (mediaViewPlayerView == null) {
p();
return;
}
if (this.K != mediaViewPlayerView.getCampaign()) {
this.f17898t.release();
p();
if (getParent() != null) {
((View) getParent()).invalidate();
}
requestLayout();
}
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
private String r() {
try {
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
if (this.K == null) {
return null;
}
com.mbridge.msdk.videocommon.download.a aVar = this.U;
if (aVar != null && aVar.f() == 5) {
String d6 = this.U.d();
if (new File(d6).exists() && this.U.e() == u.a(new File(d6))) {
return d6;
}
}
String videoUrlEncode = this.K.getVideoUrlEncode();
if (x.b(videoUrlEncode)) {
return videoUrlEncode;
}
return null;
}
private int s() {
if (t() != null) {
return t().e();
}
return 100;
}
private com.mbridge.msdk.b.d t() {
try {
CampaignEx campaignEx = this.K;
if (campaignEx != null && !x.a(campaignEx.getCampaignUnitId())) {
String campaignUnitId = this.K.getCampaignUnitId();
String h6 = com.mbridge.msdk.foundation.controller.a.e().h();
if (!x.a(campaignUnitId) && !x.a(h6)) {
com.mbridge.msdk.b.d e6 = com.mbridge.msdk.b.b.a().e(h6, campaignUnitId);
return e6 != null ? e6 : com.mbridge.msdk.b.d.d(campaignUnitId);
}
return com.mbridge.msdk.b.d.d(campaignUnitId);
}
return null;
} catch (Exception e7) {
q.d(TAG, e7.getMessage());
return null;
}
}
private boolean u() {
com.mbridge.msdk.b.d t6;
try {
t6 = t();
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
if (t6 == null) {
return false;
}
int i6 = t6.i();
if (i6 == 1) {
return u.b(getContext());
}
if (i6 == 2) {
return false;
}
return i6 == 3 ? u.c(getContext()) : u.b(getContext());
}
public View v() {
try {
this.ae = new RelativeLayout(getContext());
this.ae.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
ImageView imageView = new ImageView(getContext());
this.af = imageView;
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(u.b(getContext(), 30.0f), u.b(getContext(), 30.0f));
layoutParams.addRule(11);
layoutParams.addRule(10);
layoutParams.topMargin = u.b(getContext(), 8.0f);
layoutParams.rightMargin = u.b(getContext(), 8.0f);
this.af.setLayoutParams(layoutParams);
this.af.setBackgroundResource(k.a(getContext(), "mbridge_nativex_close", h.f3993c));
this.af.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MBMediaView.this.exitFullScreen();
}
});
this.f17903y.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
this.ae.addView(this.f17903y);
this.ae.addView(this.af);
return this.ae;
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
return null;
}
}
public void w() {
try {
FrameLayout frameLayout = (FrameLayout) getRootView().findViewById(R.id.content);
FrameLayout frameLayout2 = (FrameLayout) getRootView().findViewById(100);
RelativeLayout relativeLayout = (RelativeLayout) getRootView().findViewById(101);
RelativeLayout relativeLayout2 = (RelativeLayout) getRootView().findViewById(103);
if (relativeLayout2 == null && relativeLayout != null) {
relativeLayout2 = (RelativeLayout) relativeLayout.findViewById(103);
}
RelativeLayout relativeLayout3 = (RelativeLayout) getRootView().findViewById(k.a(getContext(), "mbridge_full_rl_playcontainer", "id"));
if (relativeLayout3 == null && relativeLayout2 != null) {
relativeLayout3 = (RelativeLayout) relativeLayout2.findViewById(k.a(getContext(), "mbridge_full_rl_playcontainer", "id"));
}
RelativeLayout relativeLayout4 = (RelativeLayout) getRootView().findViewById(k.a(getContext(), "mbridge_full_player_parent", "id"));
if (relativeLayout4 == null && relativeLayout3 != null) {
relativeLayout4 = (RelativeLayout) relativeLayout3.findViewById(k.a(getContext(), "mbridge_full_player_parent", "id"));
}
ProgressBar progressBar = (ProgressBar) getRootView().findViewById(k.a(getContext(), "mbridge_full_pb_loading", "id"));
RelativeLayout relativeLayout5 = (RelativeLayout) getRootView().findViewById(k.a(getContext(), "mbridge_full_rl_install", "id"));
LinearLayout linearLayout = (LinearLayout) getRootView().findViewById(k.a(getContext(), "mbridge_full_ll_pro_dur", "id"));
ViewGroup viewGroup = frameLayout2 != null ? (ViewGroup) frameLayout2.getParent() : null;
if (relativeLayout2 != null) {
relativeLayout2.removeView(linearLayout);
} else if (linearLayout != null && linearLayout.getParent() != null) {
((ViewGroup) linearLayout.getParent()).removeView(linearLayout);
}
RelativeLayout relativeLayout6 = this.ae;
if (relativeLayout6 != null) {
if (relativeLayout2 != null) {
relativeLayout2.removeView(relativeLayout6);
} else if (relativeLayout6.getParent() != null) {
((ViewGroup) this.ae.getParent()).removeView(this.ae);
}
this.f17903y.setBackListener(null);
this.f17903y.setObject(null);
this.f17903y = null;
this.ae = null;
}
if (relativeLayout2 != null) {
relativeLayout2.removeView(relativeLayout5);
} else if (relativeLayout5 != null && relativeLayout5.getParent() != null) {
((ViewGroup) relativeLayout5.getParent()).removeView(relativeLayout5);
}
if (relativeLayout2 != null) {
relativeLayout2.removeView(progressBar);
} else if (progressBar != null && progressBar.getParent() != null) {
((ViewGroup) progressBar.getParent()).removeView(progressBar);
}
if (relativeLayout4 != null) {
relativeLayout4.removeView(this.f17898t);
}
if (relativeLayout3 != null) {
relativeLayout3.removeView(relativeLayout4);
} else if (relativeLayout4 != null && relativeLayout4.getParent() != null) {
((ViewGroup) relativeLayout4.getParent()).removeView(relativeLayout4);
}
if (relativeLayout2 != null) {
relativeLayout2.removeView(relativeLayout3);
} else if (relativeLayout3 != null && relativeLayout3.getParent() != null) {
((ViewGroup) relativeLayout3.getParent()).removeView(relativeLayout3);
} else {
BaseView baseView = this.C;
if (baseView != null) {
baseView.removeView(this.D);
}
}
if (relativeLayout != null) {
relativeLayout.removeView(relativeLayout2);
} else if (relativeLayout2 != null && relativeLayout2.getParent() != null) {
((ViewGroup) relativeLayout2.getParent()).removeView(relativeLayout2);
} else {
View view = this.B;
if (view != null) {
((ViewGroup) view).removeView(this.C);
((ViewGroup) this.B.getParent()).removeView(this.B);
}
}
if (frameLayout != null) {
if (relativeLayout != null) {
frameLayout.removeView(relativeLayout);
} else {
frameLayout.removeView(this.B);
if (this.B.getParent() != null) {
((ViewGroup) this.B.getParent()).removeView(this.B);
this.B.setVisibility(8);
}
}
}
setVisibility(0);
requestLayout();
if (viewGroup != null) {
if (this.f17898t.getParent() != null && this.f17898t.getParent() != viewGroup) {
((ViewGroup) this.f17898t.getParent()).removeView(this.f17898t);
}
viewGroup.addView(this.f17898t, this.I);
viewGroup.removeView(frameLayout2);
viewGroup.invalidate();
}
i();
this.f17888h = false;
MediaViewPlayerView mediaViewPlayerView = this.f17898t;
if (mediaViewPlayerView != null) {
mediaViewPlayerView.setExitFullScreen();
if (this.f17886f) {
this.f17898t.openSound();
} else {
this.f17898t.closeSound();
}
this.f17898t.gonePauseView();
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private boolean x() {
try {
this.D = this.C.getMBridgeFullPlayContainer();
this.H = this.C.getMBridgeFullPlayerParent();
this.E = this.C.getMBridgeFullClose();
this.F = this.C.getMBridgeFullTvInstall();
this.G = this.C.getMBridgeFullPb();
return true;
} catch (Throwable th) {
q.d(TAG, th.getMessage());
return false;
}
}
private void y() {
try {
this.f17889i = u.i(getContext()) >= u.j(getContext());
this.f17890j = this.f17889i;
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
private void z() {
String[] split;
try {
CampaignEx campaignEx = this.K;
if (campaignEx == null || x.a(campaignEx.getVideoResolution()) || (split = this.K.getVideoResolution().split("x")) == null || split.length != 2) {
return;
}
String str = split[0];
String str2 = split[1];
double b6 = u.b(str);
double b7 = u.b(str2);
if (b6 <= 0.0d || b7 <= 0.0d) {
return;
}
this.N = b6;
this.O = b7;
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void setOnMediaViewListener(OnMBMediaViewListenerPlus onMBMediaViewListenerPlus) {
this.aa = onMBMediaViewListenerPlus;
}
private void b() {
int a7 = k.a(getContext(), "mbridge_nativex_mbmediaview", "layout");
if (a7 == -1) {
q.d(TAG, "can not find mediaview resource");
return;
}
View inflate = LayoutInflater.from(getContext()).inflate(a7, (ViewGroup) null);
this.f17900v = (RelativeLayout) inflate.findViewById(k.a(getContext(), "mbridge_rl_mediaview_root", "id"));
this.f17899u = (RelativeLayout) inflate.findViewById(k.a(getContext(), "mbridge_ll_playerview_container", "id"));
this.f17904z = (MyImageView) inflate.findViewById(k.a(getContext(), "mbridge_my_big_img", "id"));
this.A = (ProgressBar) inflate.findViewById(k.a(getContext(), "mbridge_native_pb", "id"));
this.f17901w = (RelativeLayout) inflate.findViewById(k.a(getContext(), "mbridge_nativex_webview_layout", "id"));
this.f17902x = (WindVaneWebViewForNV) inflate.findViewById(k.a(getContext(), "mbridge_nativex_webview_layout_webview", "id"));
this.f17900v.setClickable(true);
addView(inflate, -1, -1);
}
private void c() {
this.J = new Handler() {
@Override
public final void handleMessage(Message message) {
Object obj;
if (message != null) {
try {
int i6 = message.what;
if (i6 == 1) {
MBMediaView.this.q();
} else if (i6 == 3 && (obj = message.obj) != null && (obj instanceof View)) {
if (MBMediaView.this.a((View) obj)) {
MBMediaView.b(MBMediaView.this);
}
}
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
}
}
};
}
private boolean c(Context context) {
return (context.getResources().getConfiguration().screenLayout & 15) >= 3;
}
static void o(MBMediaView mBMediaView) {
try {
ProgressBar progressBar = mBMediaView.A;
if (progressBar != null) {
progressBar.setVisibility(8);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
static void c(MBMediaView mBMediaView, Campaign campaign, String str) {
try {
OnMBMediaViewListener onMBMediaViewListener = mBMediaView.W;
if (onMBMediaViewListener != null) {
onMBMediaViewListener.onFinishRedirection(campaign, str);
}
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = mBMediaView.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onFinishRedirection(campaign, str);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private void a(Context context) {
try {
c();
b();
this.ai = context;
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
static void m(MBMediaView mBMediaView) {
try {
ProgressBar progressBar = mBMediaView.A;
if (progressBar != null) {
progressBar.setVisibility(0);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
static void i(MBMediaView mBMediaView) {
try {
MediaViewPlayerView mediaViewPlayerView = mBMediaView.f17898t;
if (mediaViewPlayerView == null) {
return;
}
mediaViewPlayerView.onClickPlayerView();
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
static void n(MBMediaView mBMediaView) {
try {
ProgressBar progressBar = mBMediaView.G;
if (progressBar != null) {
progressBar.setVisibility(0);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private void a() {
com.mbridge.msdk.videocommon.download.a aVar = this.U;
if (aVar != null) {
aVar.b((com.mbridge.msdk.videocommon.listener.a) null);
}
}
protected final void a(String str) {
try {
if (TextUtils.isEmpty(str) || this.f17893m.contains(str)) {
return;
}
this.f17893m.add(str);
OnMBMediaViewListener onMBMediaViewListener = this.W;
if (onMBMediaViewListener != null) {
onMBMediaViewListener.onVideoStart();
}
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = this.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onVideoStart();
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
static void d(MBMediaView mBMediaView) {
CampaignEx.b mediaViewHolder;
CampaignEx campaignEx = mBMediaView.K;
if (campaignEx == null || (mediaViewHolder = campaignEx.getMediaViewHolder()) == null || mediaViewHolder.f16703g || mBMediaView.K.getNativeVideoTracking() == null || mBMediaView.K.getNativeVideoTracking().l() == null) {
return;
}
mediaViewHolder.f16703g = true;
Context context = mBMediaView.getContext();
CampaignEx campaignEx2 = mBMediaView.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), mBMediaView.K.getNativeVideoTracking().l(), false, false);
}
protected final void b(String str) {
try {
if (TextUtils.isEmpty(str) || this.f17894n.contains(str)) {
return;
}
this.f17894n.add(str);
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = this.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onVideoComplete();
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private void b(View view) {
if (view == null) {
return;
}
try {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
layoutParams.width = -1;
if (this.f17889i) {
layoutParams.height = -1;
} else {
layoutParams.height = (((int) A()) * 9) / 16;
layoutParams.addRule(13);
}
view.setLayoutParams(layoutParams);
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private a a(boolean z6) {
try {
CampaignEx campaignEx = this.K;
if (campaignEx == null) {
return null;
}
if (x.a(campaignEx.getVideoUrlEncode())) {
a aVar = x.b(this.K.getImageUrl()) ? a.BIG_IMAGE : null;
if (!x.b(this.K.getGifUrl())) {
return aVar;
}
if (x.a(this.K.getImageUrl())) {
aVar = a.GIF;
}
this.f17902x.setWebViewClient(new g(this));
n();
return aVar;
}
if (this.f17887g && this.U != null) {
if (x.b(this.K.getVideoUrlEncode()) && x.a(this.K.getImageUrl())) {
return a.VIDEO;
}
if (!x.b(this.K.getVideoUrlEncode()) || !x.b(this.K.getImageUrl())) {
return null;
}
if (com.mbridge.msdk.videocommon.download.k.a(this.U, s())) {
return a.VIDEO;
}
a aVar2 = a.BIG_IMAGE;
if (z6 && this.f17881a) {
this.U.b(new f(this));
}
return aVar2;
}
return a.BIG_IMAGE;
} catch (Throwable th) {
q.d(TAG, th.getMessage());
return a.BIG_IMAGE;
}
}
static void h(MBMediaView mBMediaView) {
try {
if (mBMediaView.getRootView() != null && (mBMediaView.getRootView() instanceof ViewGroup)) {
BaseView.a handleViewStyleResult = mBMediaView.handleViewStyleResult(mBMediaView.getContext());
if (handleViewStyleResult == null) {
return;
}
BaseView fullScreenViewByStyle = mBMediaView.getFullScreenViewByStyle(mBMediaView.getContext(), handleViewStyleResult);
mBMediaView.C = fullScreenViewByStyle;
if (fullScreenViewByStyle != null && mBMediaView.x()) {
com.mbridge.msdk.nativex.view.mbfullview.a a7 = com.mbridge.msdk.nativex.view.mbfullview.a.a(mBMediaView.getContext());
BaseView baseView = mBMediaView.C;
a7.a(baseView.style, mBMediaView.K, baseView);
mBMediaView.f17888h = true;
mBMediaView.f17896r = false;
MediaViewPlayerView mediaViewPlayerView = mBMediaView.f17898t;
if (mediaViewPlayerView != null) {
mediaViewPlayerView.setEnterFullScreen();
mBMediaView.f17898t.setIsActivePause(false);
}
try {
OnMBMediaViewListener onMBMediaViewListener = mBMediaView.W;
if (onMBMediaViewListener != null) {
onMBMediaViewListener.onEnterFullscreen();
}
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = mBMediaView.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onEnterFullscreen();
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
FrameLayout frameLayout = (FrameLayout) mBMediaView.getRootView().findViewById(R.id.content);
RelativeLayout relativeLayout = new RelativeLayout(mBMediaView.getContext());
mBMediaView.B = relativeLayout;
relativeLayout.setClickable(true);
ViewGroup viewGroup = (ViewGroup) mBMediaView.f17898t.getParent();
int childCount = viewGroup.getChildCount();
int i6 = 0;
while (i6 < childCount && viewGroup.getChildAt(i6) != mBMediaView.f17898t) {
i6++;
}
mBMediaView.I = i6;
FrameLayout frameLayout2 = new FrameLayout(mBMediaView.getContext());
frameLayout2.setId(100);
viewGroup.addView(frameLayout2, i6, new ViewGroup.LayoutParams(mBMediaView.getWidth(), mBMediaView.getHeight()));
viewGroup.removeView(mBMediaView.f17898t);
ViewGroup.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
relativeLayout.setId(101);
new RelativeLayout.LayoutParams(-1, -1);
mBMediaView.H.addView(mBMediaView.f17898t, new RelativeLayout.LayoutParams(-1, -1));
frameLayout.addView(relativeLayout, layoutParams);
int i7 = AnonymousClass9.f17922a[mBMediaView.C.style.ordinal()] != 2 ? ViewCompat.MEASURED_STATE_MASK : -1;
int i8 = mBMediaView.f17897s;
if (i8 != 0) {
relativeLayout.setBackgroundColor(i8);
} else {
relativeLayout.setBackgroundColor(i7);
}
mBMediaView.C.setId(103);
RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -1);
int[] iArr = new int[2];
frameLayout.getLocationInWindow(iArr);
int i9 = iArr[1];
mBMediaView.ab = i9;
if (i9 == 0) {
if (Build.VERSION.SDK_INT >= 23) {
WindowInsets rootWindowInsets = mBMediaView.getRootWindowInsets();
if (rootWindowInsets != null) {
layoutParams2.setMargins(0, rootWindowInsets.getStableInsetTop(), 0, 0);
}
} else {
layoutParams2.setMargins(0, u.e(mBMediaView.getContext()), 0, 0);
}
}
relativeLayout.addView(mBMediaView.C, layoutParams2);
try {
mBMediaView.y();
mBMediaView.a(mBMediaView.D, mBMediaView.A(), mBMediaView.B());
com.mbridge.msdk.nativex.view.mbfullview.a.a(mBMediaView.getContext()).a(mBMediaView.C, mBMediaView.f17889i);
if (mBMediaView.f17889i) {
mBMediaView.D();
} else {
mBMediaView.C();
}
mBMediaView.J.postDelayed(new Runnable() {
@Override
public final void run() {
MBMediaView.this.f17896r = true;
if (MBMediaView.this.f17888h) {
TextView unused = MBMediaView.this.F;
}
}
}, m.ad);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
try {
mBMediaView.B.setFocusableInTouchMode(true);
mBMediaView.B.requestFocus();
mBMediaView.B.setOnKeyListener(new View.OnKeyListener() {
@Override
public final boolean onKey(View view, int i10, KeyEvent keyEvent) {
try {
if (keyEvent.getKeyCode() == 4) {
MBMediaView.this.w();
return true;
}
return false;
} catch (Throwable th2) {
q.d(MBMediaView.TAG, th2.getMessage());
return false;
}
}
});
mBMediaView.B.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MBMediaView.i(MBMediaView.this);
}
});
mBMediaView.E.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MBMediaView.this.w();
}
});
mBMediaView.F.setOnClickListener(new com.mbridge.msdk.widget.a() {
@Override
protected final void a(View view) {
try {
MBMediaView.this.b(view.getContext());
} catch (Exception e7) {
q.d(MBMediaView.TAG, e7.getMessage());
}
}
});
} catch (Exception e7) {
q.d(TAG, e7.getMessage());
}
MediaViewPlayerView mediaViewPlayerView2 = mBMediaView.f17898t;
if (mediaViewPlayerView2 != null) {
mediaViewPlayerView2.openSound();
}
MediaViewPlayerView mediaViewPlayerView3 = mBMediaView.f17898t;
mediaViewPlayerView3.setMediaViewPlayListener(new MediaViewPlayerView.a(mediaViewPlayerView3) {
@Override
public final void a() {
int nvT2 = MBMediaView.this.K.getNvT2();
if (MBMediaView.this.f17888h && (nvT2 == 3 || nvT2 == 4)) {
WindVaneWebViewForNV F = MBMediaView.this.F();
if (F != null) {
View v6 = MBMediaView.this.v();
if (v6 == null) {
super.a();
return;
}
if (nvT2 == 3 && MBMediaView.this.ac) {
com.mbridge.msdk.nativex.view.mbfullview.a.a(MBMediaView.this.getContext()).a(v6, MBMediaView.this.C);
Context context = MBMediaView.this.getContext();
CampaignEx campaignEx = MBMediaView.this.K;
String campaignUnitId = MBMediaView.this.K.getCampaignUnitId();
if (campaignEx != null) {
try {
if (campaignEx.getNativeVideoTracking() != null && campaignEx.getNativeVideoTracking().j() != null) {
for (String str : campaignEx.getNativeVideoTracking().j()) {
if (!TextUtils.isEmpty(str)) {
com.mbridge.msdk.click.a.a(context, campaignEx, campaignUnitId, str, false, true);
}
}
}
} catch (Exception e8) {
e8.printStackTrace();
}
}
} else if (nvT2 == 4) {
com.mbridge.msdk.nativex.view.mbfullview.a.a(MBMediaView.this.getContext()).a(v6, MBMediaView.this.C);
String clickURL = MBMediaView.this.K.getClickURL();
if (!TextUtils.isEmpty(clickURL)) {
com.mbridge.msdk.click.a.a(MBMediaView.this.getContext(), MBMediaView.this.K, MBMediaView.this.o(), MBMediaView.this.getAddNVT2ToNoticeURL(), true, false);
MBMediaView.this.f17903y.loadUrl(clickURL);
}
} else {
super.a();
return;
}
F.webViewShow(MBMediaView.this.K, MBMediaView.this.o());
F.orientation(MBMediaView.this.f17889i);
return;
}
super.a();
return;
}
super.a();
}
});
mBMediaView.b(false);
CampaignEx campaignEx = mBMediaView.K;
if (campaignEx == null || campaignEx.getMediaViewHolder() == null || mBMediaView.K.getMediaViewHolder().f16707k || TextUtils.isEmpty(mBMediaView.K.getCampaignUnitId()) || mBMediaView.K.getNativeVideoTracking() == null || mBMediaView.K.getNativeVideoTracking().a() == null) {
return;
}
mBMediaView.K.getMediaViewHolder().f16707k = true;
mBMediaView.E();
return;
}
return;
}
q.b(TAG, "rootView is null");
} catch (Exception e8) {
q.d(TAG, e8.getMessage());
}
}
static void p(MBMediaView mBMediaView) {
try {
ProgressBar progressBar = mBMediaView.G;
if (progressBar != null) {
progressBar.setVisibility(8);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
public MBMediaView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.f17881a = true;
this.f17882b = true;
this.f17883c = true;
this.f17884d = true;
this.f17885e = true;
this.f17886f = false;
this.f17887g = true;
this.f17888h = false;
this.f17889i = false;
this.f17890j = false;
this.f17891k = true;
this.f17892l = true;
this.f17893m = new ArrayList<>();
this.f17894n = new ArrayList<>();
this.f17895q = false;
this.f17896r = false;
this.f17897s = 0;
this.U = null;
this.V = null;
this.ac = false;
this.ad = false;
this.ah = false;
this.aj = false;
this.ak = new Runnable() {
@Override
public final void run() {
try {
if (!MBMediaView.this.f17888h) {
MBMediaView mBMediaView = MBMediaView.this;
if (!mBMediaView.a((View) mBMediaView)) {
MBMediaView.Q(MBMediaView.this);
} else {
MBMediaView.R(MBMediaView.this);
}
}
MBMediaView.this.J.postDelayed(this, 300L);
} catch (Exception e6) {
q.d(MBMediaView.TAG, e6.getMessage());
}
}
};
a(context);
}
private void b(boolean z6) {
try {
int nvT2 = this.K.getNvT2();
if (this.f17903y == null) {
WindVaneWebViewForNV windVaneWebViewForNV = new WindVaneWebViewForNV(getContext());
this.f17903y = windVaneWebViewForNV;
windVaneWebViewForNV.setObject(this);
this.f17903y.setBackListener(new com.mbridge.msdk.nativex.listener.b() {
@Override
public final void a() {
MBMediaView.this.exitFullScreen();
}
});
this.f17903y.setWebViewListener(new com.mbridge.msdk.mbsignalcommon.b.b() {
@Override
public final void a(WebView webView, String str) {
super.a(webView, str);
MBMediaView.this.ac = true;
}
@Override
public final void a(WebView webView, int i6, String str, String str2) {
super.a(webView, i6, str, str2);
MBMediaView.this.ac = false;
}
});
}
if (nvT2 != 3) {
if (nvT2 == 4) {
this.ad = true;
CampaignEx campaignEx = this.K;
if (campaignEx != null) {
BrowserView.MBDownloadListener mBDownloadListener = new BrowserView.MBDownloadListener(campaignEx);
mBDownloadListener.setTitle(this.K.getAppName());
this.f17903y.setDownloadListener(mBDownloadListener);
this.f17903y.setFilter(new d());
return;
}
return;
}
return;
}
String str = this.K.getendcard_url();
if (TextUtils.isEmpty(str)) {
return;
}
this.K.getMediaViewHolder();
if (str.contains(".zip") && str.contains(com.anythink.expressad.videocommon.b.k.f5481b)) {
String b6 = com.mbridge.msdk.videocommon.download.g.a().b(str);
if (x.b(b6)) {
this.ad = true;
this.f17903y.loadUrl(b6);
return;
}
return;
}
String b7 = com.mbridge.msdk.videocommon.download.h.a().b(str);
if (x.b(b7)) {
q.a(TAG, "load html...");
this.ad = true;
this.f17903y.loadDataWithBaseURL(str, b7, "text/html", "UTF-8", null);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
public boolean a(View view) {
if (view != null) {
try {
if (view.getVisibility() == 0) {
Rect rect = new Rect();
if (!view.getLocalVisibleRect(rect)) {
return false;
}
long height = rect.height() * rect.width();
long height2 = view.getHeight() * view.getWidth();
long j6 = ((float) height2) * 0.5f;
if (height2 > 0 && u.l(getContext()) && this.f17885e && height >= j6) {
if (isShown()) {
return true;
}
}
}
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
return false;
}
private void a(View view, float f6, float f7) {
if (view == null) {
return;
}
try {
double d6 = this.N;
double d7 = 0.0d;
if (d6 > 0.0d) {
double d8 = this.O;
if (d8 > 0.0d) {
double d9 = d6 / d8;
if (f6 > 0.0f && f7 > 0.0f) {
d7 = f6 / f7;
}
double a7 = u.a(Double.valueOf(d9));
double a8 = u.a(Double.valueOf(d7));
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.f17899u.getLayoutParams();
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) view.getLayoutParams();
boolean z6 = c(getContext()) && this.f17889i;
int i6 = -1;
if (a7 > a8) {
double d10 = (f6 * this.O) / this.N;
layoutParams2.width = -1;
if (!z6) {
i6 = (int) d10;
}
layoutParams2.height = i6;
layoutParams2.addRule(13);
layoutParams.width = this.M;
layoutParams.height = (int) d10;
layoutParams.addRule(13);
} else if (a7 < a8) {
double d11 = f7 * d9;
layoutParams2.width = z6 ? -1 : (int) d11;
layoutParams2.height = -1;
layoutParams2.addRule(13);
layoutParams.width = (int) d11;
layoutParams.height = this.L;
layoutParams.addRule(13);
} else {
layoutParams2.width = -1;
layoutParams2.height = -1;
layoutParams.width = this.M;
layoutParams.height = this.L;
layoutParams.addRule(13);
}
if (!this.f17888h) {
this.f17899u.setLayoutParams(layoutParams);
}
view.setLayoutParams(layoutParams2);
return;
}
}
b(view);
} catch (Throwable th) {
q.d(TAG, th.getMessage());
}
}
public void b(Context context) {
try {
try {
OnMBMediaViewListener onMBMediaViewListener = this.W;
if (onMBMediaViewListener != null) {
onMBMediaViewListener.onVideoAdClicked(this.K);
}
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = this.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onVideoAdClicked(this.K);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
if (this.K != null && !x.a(o())) {
if (!this.K.isReportClick()) {
this.K.setReportClick(true);
CampaignEx campaignEx = this.K;
if (campaignEx != null && campaignEx.getNativeVideoTracking() != null && this.K.getNativeVideoTracking().e() != null) {
Context context2 = getContext();
CampaignEx campaignEx2 = this.K;
com.mbridge.msdk.click.a.a(context2, campaignEx2, campaignEx2.getCampaignUnitId(), this.K.getNativeVideoTracking().e(), false, false);
}
}
com.mbridge.msdk.click.a aVar = new com.mbridge.msdk.click.a(getContext(), o());
aVar.a(new NativeListener.NativeTrackingListener() {
@Override
public final void onDismissLoading(Campaign campaign) {
}
@Override
public final void onDownloadFinish(Campaign campaign) {
}
@Override
public final void onDownloadProgress(int i6) {
}
@Override
public final void onDownloadStart(Campaign campaign) {
}
@Override
public final void onFinishRedirection(Campaign campaign, String str) {
try {
MBMediaView.o(MBMediaView.this);
MBMediaView.p(MBMediaView.this);
MBMediaView.c(MBMediaView.this, campaign, str);
} catch (Exception e7) {
q.d(MBMediaView.TAG, e7.getMessage());
}
}
@Override
public final boolean onInterceptDefaultLoadingDialog() {
return true;
}
@Override
public final void onRedirectionFailed(Campaign campaign, String str) {
try {
MBMediaView.o(MBMediaView.this);
MBMediaView.p(MBMediaView.this);
MBMediaView.b(MBMediaView.this, campaign, str);
} catch (Exception e7) {
q.d(MBMediaView.TAG, e7.getMessage());
}
}
@Override
public final void onShowLoading(Campaign campaign) {
}
@Override
public final void onStartRedirection(Campaign campaign, String str) {
try {
MBMediaView.m(MBMediaView.this);
MBMediaView.n(MBMediaView.this);
MBMediaView.a(MBMediaView.this, campaign, str);
} catch (Exception e7) {
q.d(MBMediaView.TAG, e7.getMessage());
}
}
});
aVar.a(this.K);
}
} catch (Exception e7) {
q.d(TAG, e7.getMessage());
}
}
static void b(MBMediaView mBMediaView) {
CampaignEx campaignEx = mBMediaView.K;
if (campaignEx == null || campaignEx.getMediaViewHolder() == null) {
return;
}
com.mbridge.msdk.foundation.controller.a.e().a(mBMediaView.getContext());
com.mbridge.msdk.mbnative.d.b.a(mBMediaView.K, mBMediaView.getContext(), mBMediaView.o(), null);
CampaignEx.b mediaViewHolder = mBMediaView.K.getMediaViewHolder();
if (!mediaViewHolder.f16697a && mBMediaView.V == a.VIDEO && x.b(mBMediaView.K.getImpressionURL())) {
mediaViewHolder.f16697a = true;
String impressionURL = mBMediaView.K.getImpressionURL();
if (!impressionURL.contains("is_video=1")) {
StringBuilder sb = new StringBuilder(impressionURL);
if (impressionURL.contains("?")) {
sb.append("&is_video=1");
} else {
sb.append("?is_video=1");
}
impressionURL = sb.toString();
}
Context context = mBMediaView.getContext();
CampaignEx campaignEx2 = mBMediaView.K;
com.mbridge.msdk.click.a.a(context, campaignEx2, campaignEx2.getCampaignUnitId(), impressionURL, false, true);
}
}
private String a(int i6) {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("code", i6);
String jSONObject2 = jSONObject.toString();
return !TextUtils.isEmpty(jSONObject2) ? Base64.encodeToString(jSONObject2.getBytes(), 2) : "";
} catch (Throwable unused) {
q.d(TAG, "code to string is error");
return "";
}
}
static void b(MBMediaView mBMediaView, Campaign campaign, String str) {
try {
OnMBMediaViewListener onMBMediaViewListener = mBMediaView.W;
if (onMBMediaViewListener != null) {
onMBMediaViewListener.onRedirectionFailed(campaign, str);
}
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = mBMediaView.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onRedirectionFailed(campaign, str);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
private String a(List<CampaignEx> list, String str, String str2) {
if (list == null) {
return null;
}
try {
if (list.size() <= 0) {
return null;
}
JSONArray parseCamplistToJson = CampaignEx.parseCamplistToJson(list);
JSONObject jSONObject = new JSONObject();
jSONObject.put("campaignList", parseCamplistToJson);
jSONObject.put("unit_id", str);
jSONObject.put(ATAdConst.NETWORK_REQUEST_PARAMS_KEY.SDK_INFO, str2);
return jSONObject.toString();
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
return null;
}
}
static void a(MBMediaView mBMediaView, Campaign campaign, String str) {
try {
OnMBMediaViewListener onMBMediaViewListener = mBMediaView.W;
if (onMBMediaViewListener != null) {
onMBMediaViewListener.onStartRedirection(campaign, str);
}
OnMBMediaViewListenerPlus onMBMediaViewListenerPlus = mBMediaView.aa;
if (onMBMediaViewListenerPlus != null) {
onMBMediaViewListenerPlus.onStartRedirection(campaign, str);
}
} catch (Exception e6) {
q.d(TAG, e6.getMessage());
}
}
}