翰林优商.apk(点击下载) / AdWebViewActivityProxy.java
package com.kwad.components.core.page;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import com.kwad.components.ad.a.h;
import com.kwad.components.core.page.c;
import com.kwad.components.core.page.widget.a;
import com.kwad.sdk.R;
import com.kwad.sdk.api.core.KsAdSdkDynamicImpl;
import com.kwad.sdk.api.core.ResContext;
import com.kwad.sdk.api.loader.Wrapper;
import com.kwad.sdk.api.proxy.app.AdWebViewActivity;
import com.kwad.sdk.core.e.b;
import com.kwad.sdk.core.response.a.d;
import com.kwad.sdk.core.response.model.AdInfo;
import com.kwad.sdk.core.response.model.AdTemplate;
import com.kwad.sdk.utils.af;
import com.kwad.sdk.utils.u;
import com.kwad.sdk.utils.v;
import org.json.JSONObject;
@KsAdSdkDynamicImpl(AdWebViewActivity.class)
public class AdWebViewActivityProxy extends com.kwad.components.core.j.a implements c.a {
public static final String KEY_LANDING_PAGE_TYPE = "key_landing_page_type";
public static final String KEY_MINI_WINDOW = "key_mini_window";
private static final String KEY_PAGE_TITLE = "key_page_title";
private static final String KEY_PAGE_URL = "key_page_url";
public static final String KEY_TEMPLATE = "key_template_json";
private static final String TAG = "AdWebViewActivityProxy";
public static boolean showingAdWebViewActivity = false;
private volatile boolean destroyed = false;
private c landingPageViewHelper;
private AdTemplate mAdTemplate;
private Context mContext;
private boolean mIsVPlusShown = false;
private Dialog mKsExitInterceptDialog;
private Dialog mKsExitInterceptDialogV2;
private boolean mNormalMode;
public static class a {
private String Is;
private String It;
private AdTemplate adTemplate;
/* renamed from: com.kwad.components.core.page.AdWebViewActivityProxy$a$a reason: collision with other inner class name */
public static class C0103a {
private String Is;
private String It;
private AdTemplate adTemplate;
public final C0103a N(AdTemplate adTemplate2) {
this.adTemplate = adTemplate2;
return this;
}
public final C0103a aq(String str) {
this.Is = str;
return this;
}
public final C0103a ar(String str) {
this.It = str;
return this;
}
public final a nu() {
return new a(this.Is, this.It, this.adTemplate, (byte) 0);
}
}
private a(String str, String str2, AdTemplate adTemplate2) {
this.Is = str;
this.It = str2;
this.adTemplate = adTemplate2;
}
/* synthetic */ a(String str, String str2, AdTemplate adTemplate2, byte b) {
this(str, str2, adTemplate2);
}
}
private com.kwad.components.core.page.widget.a buildDialog() {
return new com.kwad.components.core.page.widget.a(getActivity(), new a.AbstractC0105a() {
/* class com.kwad.components.core.page.AdWebViewActivityProxy.AnonymousClass3 */
@Override // com.kwad.components.core.page.widget.a.AbstractC0105a
public final void a(DialogInterface dialogInterface) {
com.kwad.sdk.core.report.a.t(AdWebViewActivityProxy.this.mAdTemplate, 104);
dialogInterface.dismiss();
}
@Override // com.kwad.components.core.page.widget.a.AbstractC0105a
public final void b(DialogInterface dialogInterface) {
try {
AdWebViewActivityProxy.super.onBackPressed();
} catch (Throwable unused) {
}
com.kwad.sdk.core.report.a.t(AdWebViewActivityProxy.this.mAdTemplate, 105);
}
@Override // com.kwad.components.core.page.widget.a.AbstractC0105a
public final void c(DialogInterface dialogInterface) {
com.kwad.sdk.core.report.a.t(AdWebViewActivityProxy.this.mAdTemplate, 106);
dialogInterface.dismiss();
}
});
}
private boolean isFormAdExitInterceptEnable() {
AdTemplate adTemplate;
if (this.mNormalMode || (adTemplate = this.mAdTemplate) == null || d.q(adTemplate)) {
return false;
}
if (!com.kwad.sdk.core.config.d.KV() || !this.mAdTemplate.mIsFromContent) {
return com.kwad.sdk.core.config.d.KW() && !this.mAdTemplate.mIsFromContent;
}
return true;
}
public static void launch(Context context, a aVar) {
if (context != null && !TextUtils.isEmpty(aVar.Is) && !TextUtils.isEmpty(aVar.It)) {
com.kwad.sdk.service.a.g(AdWebViewActivity.class, AdWebViewActivityProxy.class);
Intent intent = new Intent(context, AdWebViewActivity.class);
intent.addFlags(268435456);
intent.putExtra(KEY_PAGE_TITLE, aVar.Is);
intent.putExtra(KEY_PAGE_URL, aVar.It);
intent.putExtra("key_template_json", aVar.adTemplate.toJson().toString());
context.startActivity(intent);
}
}
public static void launch(Context context, AdTemplate adTemplate) {
if (!af.isNetworkConnected(context)) {
Context wrapContextIfNeed = Wrapper.wrapContextIfNeed(context);
u.V(wrapContextIfNeed, v.cD(wrapContextIfNeed));
return;
}
launch(context, adTemplate, 0);
}
public static void launch(Context context, AdTemplate adTemplate, int i) {
if (context != null && adTemplate != null) {
com.kwad.sdk.service.a.g(AdWebViewActivity.class, AdWebViewActivityProxy.class);
Intent intent = new Intent(context, AdWebViewActivity.class);
intent.addFlags(268435456);
intent.putExtra("key_template_json", adTemplate.toJson().toString());
intent.putExtra(KEY_LANDING_PAGE_TYPE, i);
if (adTemplate.mMiniWindowId != null) {
intent.putExtra(KEY_MINI_WINDOW, adTemplate.mMiniWindowId);
}
context.startActivity(intent);
if (context instanceof ResContext) {
context = ((ResContext) context).getDelegatedContext();
}
if (context instanceof Activity) {
((Activity) context).overridePendingTransition(0, 0);
}
}
}
public static void register() {
com.kwad.sdk.service.a.g(AdWebViewActivity.class, AdWebViewActivityProxy.class);
}
private void showDialog() {
if (this.mKsExitInterceptDialog == null) {
this.mKsExitInterceptDialog = buildDialog();
}
com.kwad.sdk.core.report.a.c(this.mAdTemplate, 103, (JSONObject) null);
this.mKsExitInterceptDialog.show();
}
private void showMiniWindowIfNeeded() {
final String stringExtra = getIntent().getStringExtra(KEY_MINI_WINDOW);
if (!TextUtils.isEmpty(stringExtra)) {
new Handler().post(new Runnable() {
/* class com.kwad.components.core.page.AdWebViewActivityProxy.AnonymousClass1 */
public final void run() {
Rect rect = new Rect();
DisplayMetrics displayMetrics = AdWebViewActivityProxy.this.getActivity().getResources().getDisplayMetrics();
rect.right = displayMetrics.widthPixels;
rect.left = rect.right - (displayMetrics.widthPixels / 4);
rect.bottom = (int) (((float) displayMetrics.heightPixels) * 0.83f);
rect.top = rect.bottom - (((displayMetrics.widthPixels / 4) * 16) / 9);
h hVar = (h) com.kwad.sdk.components.c.g(h.class);
if (hVar != null) {
hVar.a(AdWebViewActivityProxy.this.getActivity(), stringExtra, false, rect);
}
}
});
}
}
@Override // com.kwad.components.core.j.a
public String getPageName() {
return TAG;
}
@Override // com.kwad.components.core.page.c.a
public void onBackBtnClicked(View view) {
onBackPressed();
}
@Override // com.kwad.sdk.api.proxy.IActivityProxy
public void onBackPressed() {
if (isFormAdExitInterceptEnable()) {
try {
if (this.mKsExitInterceptDialogV2 == null) {
this.mKsExitInterceptDialogV2 = new com.kwad.components.core.page.widget.a(getActivity(), new a.AbstractC0105a() {
/* class com.kwad.components.core.page.AdWebViewActivityProxy.AnonymousClass2 */
@Override // com.kwad.components.core.page.widget.a.AbstractC0105a
public final void a(DialogInterface dialogInterface) {
com.kwad.sdk.core.report.a.t(AdWebViewActivityProxy.this.mAdTemplate, 104);
dialogInterface.dismiss();
}
@Override // com.kwad.components.core.page.widget.a.AbstractC0105a
public final void b(DialogInterface dialogInterface) {
if (!AdWebViewActivityProxy.this.destroyed) {
try {
AdWebViewActivityProxy.super.onBackPressed();
} catch (Throwable th) {
b.printStackTrace(th);
}
}
com.kwad.sdk.core.report.a.t(AdWebViewActivityProxy.this.mAdTemplate, 105);
}
@Override // com.kwad.components.core.page.widget.a.AbstractC0105a
public final void c(DialogInterface dialogInterface) {
com.kwad.sdk.core.report.a.t(AdWebViewActivityProxy.this.mAdTemplate, 106);
dialogInterface.dismiss();
}
});
}
com.kwad.sdk.core.report.a.c(this.mAdTemplate, 103, (JSONObject) null);
this.mKsExitInterceptDialogV2.show();
return;
} catch (Throwable th) {
b.printStackTraceOnly(th);
}
}
super.onBackPressed();
}
@Override // com.kwad.components.core.page.c.a
public void onCloseBtnClicked(View view) {
if (isFormAdExitInterceptEnable()) {
showDialog();
} else {
finish();
}
}
@Override // com.kwad.sdk.api.proxy.IActivityProxy, com.kwad.components.core.j.a
public void onCreate(Bundle bundle) {
try {
getIntent().removeExtra(AdWebViewVideoActivityProxy.KEY_TEMPLATE);
} catch (Throwable unused) {
}
super.onCreate(bundle);
getActivity().setTheme(R.style.Theme_AppCompat_Light_NoActionBar);
this.destroyed = false;
this.mContext = Wrapper.wrapContextIfNeed(getActivity());
String stringExtra = getIntent().getStringExtra("key_template_json");
String stringExtra2 = getIntent().getStringExtra(KEY_PAGE_TITLE);
String stringExtra3 = getIntent().getStringExtra(KEY_PAGE_URL);
int intExtra = getIntent().getIntExtra(KEY_LANDING_PAGE_TYPE, 0);
showingAdWebViewActivity = true;
try {
AdTemplate adTemplate = new AdTemplate();
adTemplate.parseJson(new JSONObject(stringExtra));
this.mAdTemplate = adTemplate;
} catch (Throwable th) {
b.printStackTrace(th);
}
if (TextUtils.isEmpty(stringExtra2) || TextUtils.isEmpty(stringExtra3)) {
AdTemplate adTemplate2 = this.mAdTemplate;
if (adTemplate2 != null) {
AdInfo cs = d.cs(adTemplate2);
c cVar = new c(this.mContext, this.mAdTemplate, intExtra, true);
this.landingPageViewHelper = cVar;
cVar.a(this);
this.landingPageViewHelper.a(new c.C0104c().at(com.kwad.sdk.core.response.a.b.bC(this.mAdTemplate) ? com.kwad.sdk.core.response.a.b.bB(this.mAdTemplate) : com.kwad.sdk.core.response.a.a.ax(cs)).nF());
} else {
finish();
return;
}
} else {
this.mNormalMode = true;
c.b nF = new c.C0104c().ar(true).as(false).as(stringExtra2).at(stringExtra3).nF();
c cVar2 = new c(this.mContext, this.mAdTemplate, 1, false);
this.landingPageViewHelper = cVar2;
cVar2.a(this);
this.landingPageViewHelper.a(nF);
}
setContentView(this.landingPageViewHelper.getRootView());
}
@Override // com.kwad.sdk.api.proxy.IActivityProxy, com.kwad.components.core.j.a
public void onDestroy() {
h hVar;
this.destroyed = true;
showingAdWebViewActivity = false;
c cVar = this.landingPageViewHelper;
if (cVar != null) {
cVar.destroy();
}
Dialog dialog = this.mKsExitInterceptDialog;
if (dialog != null && dialog.isShowing()) {
this.mKsExitInterceptDialog.dismiss();
}
Dialog dialog2 = this.mKsExitInterceptDialogV2;
if (dialog2 != null && dialog2.isShowing()) {
this.mKsExitInterceptDialogV2.dismiss();
}
super.onDestroy();
AdTemplate adTemplate = this.mAdTemplate;
if (adTemplate != null && adTemplate.interactLandingPageShowing) {
this.mAdTemplate.interactLandingPageShowing = false;
}
if (this.mIsVPlusShown && (hVar = (h) com.kwad.sdk.components.c.g(h.class)) != null) {
hVar.ao();
}
}
@Override // com.kwad.sdk.api.proxy.IActivityProxy
public void onPause() {
showingAdWebViewActivity = false;
c cVar = this.landingPageViewHelper;
if (cVar != null) {
cVar.hide();
}
overridePendingTransition(0, 0);
}
@Override // com.kwad.sdk.api.proxy.IActivityProxy, com.kwad.components.core.j.a
public void onResume() {
super.onResume();
showingAdWebViewActivity = true;
c cVar = this.landingPageViewHelper;
if (cVar != null) {
cVar.show();
}
if (!this.mIsVPlusShown) {
showMiniWindowIfNeeded();
this.mIsVPlusShown = true;
}
}
}