- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
251 lines
7.3 KiB
Java
251 lines
7.3 KiB
Java
package com.mbridge.msdk.out;
|
|
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import android.widget.RelativeLayout;
|
|
import com.mbridge.msdk.foundation.c.b;
|
|
import com.mbridge.msdk.foundation.controller.c;
|
|
import com.mbridge.msdk.foundation.tools.af;
|
|
import com.mbridge.msdk.foundation.tools.ak;
|
|
import com.mbridge.msdk.mbbanner.a.a;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class MBBannerView extends RelativeLayout implements BaseExtraInterfaceForHandler {
|
|
private String bidToken;
|
|
private a controller;
|
|
private boolean hadAttached;
|
|
private boolean isVisible;
|
|
private BannerAdListener mBannerAdListener;
|
|
private MBridgeIds mBridgeIds;
|
|
private String unitId;
|
|
|
|
public MBBannerView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public MBBannerView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public MBBannerView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.hadAttached = false;
|
|
this.isVisible = false;
|
|
c.m().a(context);
|
|
}
|
|
|
|
public void init(BannerSize bannerSize, String str, String str2) {
|
|
this.unitId = str2;
|
|
this.mBridgeIds = new MBridgeIds(TextUtils.isEmpty(str) ? "" : str, str2);
|
|
String e = ak.e(str2);
|
|
if (!TextUtils.isEmpty(e)) {
|
|
ak.b(str2, e);
|
|
}
|
|
a aVar = new a(this, bannerSize, str, str2);
|
|
this.controller = aVar;
|
|
aVar.c(this.isVisible);
|
|
this.controller.b(this.hadAttached);
|
|
}
|
|
|
|
public void updateBannerSize(BannerSize bannerSize) {
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
aVar.a(bannerSize);
|
|
}
|
|
}
|
|
|
|
public void setRefreshTime(int i) {
|
|
a aVar = this.controller;
|
|
if (aVar == null || i < 0) {
|
|
return;
|
|
}
|
|
aVar.a(i);
|
|
}
|
|
|
|
public void setAllowShowCloseBtn(boolean z) {
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
aVar.a(z);
|
|
}
|
|
}
|
|
|
|
public void load() {
|
|
String a = com.mbridge.msdk.mbbanner.common.d.a.a(this.bidToken);
|
|
com.mbridge.msdk.foundation.same.report.d.c a2 = com.mbridge.msdk.mbbanner.common.d.a.a(this.unitId, a);
|
|
a2.i("0");
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
aVar.b(this.hadAttached);
|
|
this.controller.a("", a);
|
|
} else {
|
|
b bVar = new b(880042);
|
|
bVar.b(a);
|
|
callbackAndReportFail(a2, bVar);
|
|
}
|
|
}
|
|
|
|
public void loadFromBid(String str) {
|
|
this.bidToken = str;
|
|
String a = com.mbridge.msdk.mbbanner.common.d.a.a(str);
|
|
com.mbridge.msdk.foundation.same.report.d.c a2 = com.mbridge.msdk.mbbanner.common.d.a.a(this.unitId, a);
|
|
a2.i("1");
|
|
if (this.controller != null) {
|
|
if (!TextUtils.isEmpty(str)) {
|
|
this.controller.b(this.hadAttached);
|
|
this.controller.a(0);
|
|
this.controller.a(str, a);
|
|
return;
|
|
} else {
|
|
b bVar = new b(880035);
|
|
bVar.b(a);
|
|
callbackAndReportFail(a2, bVar);
|
|
return;
|
|
}
|
|
}
|
|
b bVar2 = new b(880042);
|
|
bVar2.b(a);
|
|
callbackAndReportFail(a2, bVar2);
|
|
}
|
|
|
|
private void callbackAndReportFail(com.mbridge.msdk.foundation.same.report.d.c cVar, b bVar) {
|
|
String str = "";
|
|
if (bVar != null) {
|
|
try {
|
|
str = bVar.b();
|
|
} catch (Throwable th) {
|
|
af.b("BannerView", th.getMessage());
|
|
}
|
|
}
|
|
cVar.a(bVar);
|
|
cVar.c(true);
|
|
com.mbridge.msdk.mbbanner.common.d.a.a("2000047", cVar, null);
|
|
BannerAdListener bannerAdListener = this.mBannerAdListener;
|
|
if (bannerAdListener != null) {
|
|
bannerAdListener.onLoadFailed(this.mBridgeIds, str);
|
|
}
|
|
}
|
|
|
|
public String getRequestId() {
|
|
a aVar = this.controller;
|
|
return aVar != null ? aVar.a() : "";
|
|
}
|
|
|
|
public String getCreativeIdWithUnitId() {
|
|
a aVar = this.controller;
|
|
return aVar != null ? aVar.b() : "";
|
|
}
|
|
|
|
public void setBannerAdListener(BannerAdListener bannerAdListener) {
|
|
this.mBannerAdListener = bannerAdListener;
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
aVar.a(bannerAdListener);
|
|
}
|
|
}
|
|
|
|
public void release() {
|
|
if (this.mBannerAdListener != null) {
|
|
this.mBannerAdListener = null;
|
|
}
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
aVar.a((BannerAdListener) null);
|
|
this.controller.c();
|
|
}
|
|
removeAllViews();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void onAttachedToWindow() {
|
|
super.onAttachedToWindow();
|
|
updateAttachedState(true);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void onDetachedFromWindow() {
|
|
super.onDetachedFromWindow();
|
|
updateAttachedState(false);
|
|
}
|
|
|
|
private void updateAttachedState(boolean z) {
|
|
this.hadAttached = z;
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
aVar.b(z);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onWindowVisibilityChanged(int i) {
|
|
super.onWindowVisibilityChanged(i);
|
|
this.isVisible = i == 0;
|
|
if (this.controller != null) {
|
|
if (i == 0) {
|
|
delayedNotify();
|
|
} else {
|
|
if (com.mbridge.msdk.foundation.d.b.c) {
|
|
return;
|
|
}
|
|
this.controller.c(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onVisibilityChanged(View view, int i) {
|
|
super.onVisibilityChanged(view, i);
|
|
this.isVisible = i == 0;
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
if (i == 0) {
|
|
delayedNotify();
|
|
} else {
|
|
aVar.c(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void delayedNotify() {
|
|
postDelayed(new Runnable() { // from class: com.mbridge.msdk.out.MBBannerView.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (MBBannerView.this.controller == null || com.mbridge.msdk.foundation.d.b.c) {
|
|
return;
|
|
}
|
|
MBBannerView.this.controller.c(true);
|
|
}
|
|
}, 200L);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onSizeChanged(int i, int i2, int i3, int i4) {
|
|
super.onSizeChanged(i, i2, i3, i4);
|
|
a aVar = this.controller;
|
|
if (aVar != null) {
|
|
aVar.a(i, i2, i3, i4);
|
|
}
|
|
}
|
|
|
|
public void onPause() {
|
|
if (this.controller == null || !TextUtils.isEmpty(this.bidToken)) {
|
|
return;
|
|
}
|
|
this.controller.e();
|
|
}
|
|
|
|
public void onResume() {
|
|
if (this.controller == null || !TextUtils.isEmpty(this.bidToken) || com.mbridge.msdk.foundation.d.b.c) {
|
|
return;
|
|
}
|
|
this.controller.f();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.out.BaseExtraInterfaceForHandler
|
|
public void setExtraInfo(JSONObject jSONObject) {
|
|
c.m().a(this.unitId, jSONObject);
|
|
}
|
|
}
|