package com.iBookStar.views; import android.animation.Animator; import android.animation.ValueAnimator; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.iBookStar.activityComm.CoinWebView; import com.iBookStar.activityComm.SurveyWebView; import com.iBookStar.utils.k; import com.iBookStar.views.CommonWebView; import com.kwai.video.player.PlayerProps; import org.json.JSONObject; public class PopupWebView extends RelativeLayout implements CommonWebView.g2, View.OnClickListener { private CommonWebView a; private CommonWebView b; private int c = 0; private boolean d = false; private boolean e = false; private String f; private com.iBookStar.a.f g; private ValueAnimator h; /* access modifiers changed from: package-private */ public class a extends CommonWebView.f2 { a() { } @Override // com.iBookStar.views.CommonWebView.f2 public boolean b(CommonWebView commonWebView, String str) { Activity activity; Intent intent; String taskParams; if (PopupWebView.this.b == null || !PopupWebView.this.a.isTouchByUser()) { return super.b(commonWebView, str); } PopupWebView.this.a.resetTouchState(); try { PopupWebView.this.a.report2Web(); if (PopupWebView.this.b.getWebViewEnvironment() == 4) { activity = (Activity) ((View) PopupWebView.this.b.getParent()).getContext(); intent = new Intent(activity, CoinWebView.class); intent.putExtra("url", str); intent.putExtra("back", true); intent.putExtra("h5AdLandingPage", true); taskParams = PopupWebView.this.b.getTaskParams(); } else { activity = (Activity) ((View) PopupWebView.this.b.getParent()).getContext(); intent = new Intent(activity, SurveyWebView.class); intent.putExtra("url", str); intent.putExtra("back", true); intent.putExtra("h5AdLandingPage", true); taskParams = PopupWebView.this.b.getTaskParams(); } intent.putExtra("taskParams", taskParams); activity.startActivityForResult(intent, PlayerProps.FFP_PROP_INT64_SELECTED_VIDEO_STREAM); } catch (Throwable th) { th.printStackTrace(); } return true; } } /* access modifiers changed from: package-private */ public class b implements ValueAnimator.AnimatorUpdateListener { final /* synthetic */ RelativeLayout.LayoutParams a; b(RelativeLayout.LayoutParams layoutParams) { this.a = layoutParams; } public void onAnimationUpdate(ValueAnimator valueAnimator) { this.a.bottomMargin = ((Integer) valueAnimator.getAnimatedValue()).intValue(); PopupWebView.this.a.setLayoutParams(this.a); } } /* access modifiers changed from: package-private */ public class c implements Animator.AnimatorListener { c() { } public void onAnimationCancel(Animator animator) { } public void onAnimationEnd(Animator animator) { PopupWebView.this.h = null; PopupWebView.this.f(); } public void onAnimationRepeat(Animator animator) { } public void onAnimationStart(Animator animator) { } } /* access modifiers changed from: package-private */ public class d implements ValueAnimator.AnimatorUpdateListener { final /* synthetic */ RelativeLayout.LayoutParams a; d(RelativeLayout.LayoutParams layoutParams) { this.a = layoutParams; } public void onAnimationUpdate(ValueAnimator valueAnimator) { this.a.bottomMargin = ((Integer) valueAnimator.getAnimatedValue()).intValue(); PopupWebView.this.a.setLayoutParams(this.a); } } /* access modifiers changed from: package-private */ public class e implements Animator.AnimatorListener { e() { } public void onAnimationCancel(Animator animator) { } public void onAnimationEnd(Animator animator) { PopupWebView.this.h = null; PopupWebView.this.a(); } public void onAnimationRepeat(Animator animator) { } public void onAnimationStart(Animator animator) { } } /* access modifiers changed from: package-private */ public class f implements ValueAnimator.AnimatorUpdateListener { final /* synthetic */ RelativeLayout.LayoutParams a; f(RelativeLayout.LayoutParams layoutParams) { this.a = layoutParams; } public void onAnimationUpdate(ValueAnimator valueAnimator) { this.a.bottomMargin = ((Integer) valueAnimator.getAnimatedValue()).intValue(); PopupWebView.this.a.setLayoutParams(this.a); } } /* access modifiers changed from: package-private */ public class g implements Animator.AnimatorListener { g() { } public void onAnimationCancel(Animator animator) { } public void onAnimationEnd(Animator animator) { PopupWebView.this.h = null; } public void onAnimationRepeat(Animator animator) { } public void onAnimationStart(Animator animator) { } } public PopupWebView(Context context) { super(context); d(); } public PopupWebView(Context context, AttributeSet attributeSet) { super(context, attributeSet); d(); } public PopupWebView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); d(); } public PopupWebView(Context context, AttributeSet attributeSet, int i, int i2) { super(context, attributeSet, i, i2); d(); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a() { if (!this.e && this.b != null) { if (getParent() != null) { ((ViewGroup) getParent()).removeView(this); } ((ViewGroup) this.b.getParent()).addView(this, 0, new RelativeLayout.LayoutParams(-1, -1)); CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.loadUrl("javascript:if(window.afterPopupAdHide){window.afterPopupAdHide()}"); } } } private void a(String str, String str2) { if (this.b != null) { try { JSONObject jSONObject = new JSONObject(str2); String optString = jSONObject.optString("url"); this.d = jSONObject.optBoolean("canceledOnTouchOutside", true); boolean optBoolean = jSONObject.optBoolean("showMask", false); ((ViewGroup) this.b.getParent()).addView(this, 0, new RelativeLayout.LayoutParams(-1, -1)); if (optBoolean) { setClickable(true); setBackgroundColor(838860800); } else { setClickable(false); setBackgroundColor(0); } this.a.loadUrl(optString); this.a.registerEventBus(); this.f = str; this.e = false; } catch (Throwable th) { th.printStackTrace(); this.b = null; this.f = null; } } } private void b() { if (this.b != null) { this.a.unregisterEventBus(); this.a.destoryAds(); if (getParent() != null) { ((ViewGroup) getParent()).removeView(this); } this.b.loadUrl("javascript:if(window.afterPopupAdClose){window.afterPopupAdClose()}"); this.b = null; this.f = null; this.e = false; this.h = null; this.c = 0; } } private void c() { if (this.b != null && this.e) { ValueAnimator valueAnimator = this.h; if (valueAnimator != null) { valueAnimator.cancel(); } RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.a.getLayoutParams(); ValueAnimator ofInt = ValueAnimator.ofInt(layoutParams.bottomMargin, -k.c(getContext())); this.h = ofInt; ofInt.addUpdateListener(new d(layoutParams)); this.h.addListener(new e()); this.h.setDuration(500L); this.h.start(); this.e = false; } } private void d() { CommonWebView commonWebView = new CommonWebView(getContext()); this.a = commonWebView; commonWebView.initWebView(false); this.a.setCommonWebViewClient(new a()); this.a.setCommonWebChromeClient(new CommonWebView.d2()); this.a.setCommonWebViewListener(this); int c2 = k.c(getContext()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, c2); layoutParams.addRule(12); layoutParams.bottomMargin = -c2; addView(this.a, layoutParams); setOnClickListener(this); } private void e() { if (this.b != null && !this.e) { if (getParent() != null) { ((ViewGroup) getParent()).removeView(this); } ((ViewGroup) this.b.getParent()).addView(this, new RelativeLayout.LayoutParams(-1, -1)); int c2 = k.c(getContext()); ValueAnimator ofInt = ValueAnimator.ofInt(-c2, this.c - c2); this.h = ofInt; ofInt.setDuration(500L); this.h.addUpdateListener(new b((RelativeLayout.LayoutParams) this.a.getLayoutParams())); this.h.addListener(new c()); this.h.start(); this.e = true; } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void f() { if (this.e) { ValueAnimator valueAnimator = this.h; if (valueAnimator != null) { valueAnimator.cancel(); } RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.a.getLayoutParams(); ValueAnimator ofInt = ValueAnimator.ofInt(layoutParams.bottomMargin, this.c - k.c(getContext())); this.h = ofInt; ofInt.addUpdateListener(new f(layoutParams)); this.h.addListener(new g()); this.h.setDuration(500L); this.h.start(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void aSetUserBindRelation(String str) { } public boolean canceledOnTouchOutside() { return this.d; } @Override // com.iBookStar.views.CommonWebView.g2 public void clickToPushSetting() { } @Override // com.iBookStar.views.CommonWebView.g2 public void createPopupWindow(String str, String str2) { a(str, str2); } @Override // com.iBookStar.views.CommonWebView.g2 public void dealPics(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void destroyPopupWindow(String str) { b(); } @Override // com.iBookStar.views.CommonWebView.g2 public void fetchAd(String str) { } public com.iBookStar.a.f getAdItem() { return this.g; } @Override // com.iBookStar.views.CommonWebView.g2 public String getCoinTaskProgress() { CommonWebView commonWebView = this.b; if (commonWebView != null) { return commonWebView.getCoinTaskProgress(); } return null; } @Override // com.iBookStar.views.CommonWebView.g2 public String getCurrentCoinTask() { CommonWebView commonWebView = this.b; if (commonWebView != null) { return commonWebView.getCurrentCoinTask(); } return null; } @Override // com.iBookStar.views.CommonWebView.g2 public long getCurrentTaskId() { CommonWebView commonWebView = this.b; if (commonWebView != null) { return commonWebView.getCurrentTaskId(); } return 0; } @Override // com.iBookStar.views.CommonWebView.g2 public void getMonitorTime(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public String getTaskParams() { CommonWebView commonWebView = this.b; if (commonWebView != null) { return commonWebView.getTaskParams(); } return null; } @Override // com.iBookStar.views.CommonWebView.g2 public float getTopSafeAreaInset() { return 0.0f; } public String getUniqueId() { return this.f; } @Override // com.iBookStar.views.CommonWebView.g2 public String getUserBindRelation() { return null; } @Override // com.iBookStar.views.CommonWebView.g2 public String getUserSpecialId() { return null; } @Override // com.iBookStar.views.CommonWebView.g2 public String getUtdid() { return null; } @Override // com.iBookStar.views.CommonWebView.g2 public int getWebViewEnvironment() { CommonWebView commonWebView = this.b; if (commonWebView != null) { return commonWebView.getWebViewEnvironment(); } return 0; } @Override // com.iBookStar.views.CommonWebView.g2 public String getYPProductData() { return null; } @Override // com.iBookStar.views.CommonWebView.g2 public void gotoTab(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void hidePopupWindow(String str) { c(); } @Override // com.iBookStar.views.CommonWebView.g2 public void hrefNumOnPage(int i) { } public boolean isDestroyed() { return this.b == null; } @Override // com.iBookStar.views.CommonWebView.g2 public String isEnterReaderFromTask() { CommonWebView commonWebView = this.b; return commonWebView != null ? commonWebView.isEnterReaderFromTask() : "0"; } public boolean isShown() { return this.e; } @Override // com.iBookStar.views.CommonWebView.g2 public String isTaskFail() { CommonWebView commonWebView = this.b; return commonWebView != null ? commonWebView.isTaskFail() : "0"; } @Override // com.iBookStar.views.CommonWebView.g2 public void needPost() { } @Override // com.iBookStar.views.CommonWebView.g2 public void onBackAdReceived(String str) { } public void onClick(View view) { if (this.d) { c(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void onClickTasksCenter() { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.onClickTasksCenter(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void onClose() { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.onClickClose(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void onContentLoaded(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void onContinueAd() { } @Override // com.iBookStar.views.CommonWebView.g2 public void onFloatAdShow() { } @Override // com.iBookStar.views.CommonWebView.g2 public void onMonitorPhase(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void onMonitorTips(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void onPayCancel() { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.onPayCancel(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void onPayFinish() { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.onPayFinish(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void onPayStart() { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.onPayStart(); } } public void onReceiveMessage(String str) { this.a.loadUrl(String.format("javascript:if(window.onReceiveMessage){window.onReceiveMessage('%s')}", str)); } @Override // com.iBookStar.views.CommonWebView.g2 public void onRefresh() { } @Override // com.iBookStar.views.CommonWebView.g2 public void onSkipAd() { } @Override // com.iBookStar.views.CommonWebView.g2 public void openCouponPage(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void openItemDetailWithParams(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void openNextCoinTask() { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.openNextCoinTask(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void openURLWithNewWindow(String str) { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.openURLWithNewWindow(str); } } @Override // com.iBookStar.views.CommonWebView.g2 public void postPopupWindowHeight(String str, int i) { int scale = (int) (((float) i) * this.a.getScale()); if (this.c != scale) { this.c = scale; f(); } } @Override // com.iBookStar.views.CommonWebView.g2 public void postRightBtn(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void postTaskCenterCloseMsg(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void postTaskCondition(String str) { } public void preparePopupWindow(CommonWebView commonWebView) { b(); this.b = commonWebView; } public boolean reloadAd() { return this.a.reloadNativeAd(this.g); } @Override // com.iBookStar.views.CommonWebView.g2 public void sendMessage(String str, String str2) { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.loadUrl(String.format("javascript:if(window.onReceiveMessage){window.onReceiveMessage('%s')}", str2)); } } @Override // com.iBookStar.views.CommonWebView.g2 public void setAdItem(com.iBookStar.a.f fVar) { this.g = fVar; CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.setAdItem(fVar); } } @Override // com.iBookStar.views.CommonWebView.g2 public void setStatusBarMode(int i) { } @Override // com.iBookStar.views.CommonWebView.g2 public void shareGoodsDetails(String str) { } public boolean shouldOverrideUrlByYdx(CommonWebView commonWebView, String str) { return false; } @Override // com.iBookStar.views.CommonWebView.g2 public void showPopupWindow(String str) { e(); } @Override // com.iBookStar.views.CommonWebView.g2 public void timeMonitorComplete() { } @Override // com.iBookStar.views.CommonWebView.g2 public void userToLoginAndAuthorized(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void webPageChanged(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void webviewTitleChangeToString(String str) { } @Override // com.iBookStar.views.CommonWebView.g2 public void withdraw() { CommonWebView commonWebView = this.b; if (commonWebView != null) { commonWebView.withdraw(); } } }