MD5 校验值:8005b9444b02324a81f85f1ef7e26f28
AdWebView.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.adadapted.android.sdk.ui.view; import android.content.Context; import android.view.MotionEvent; import android.view.View; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import cc.i; import com.adadapted.android.sdk.core.ad.Ad; import java.util.HashMap; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public final class AdWebView extends WebView { private HashMap _$_findViewCache; private final Lock adLock; private Ad currentAd; private final Listener listener; private boolean loaded; public interface Listener { void onAdClicked(Ad ad2); void onAdLoadFailed(); void onAdLoaded(Ad ad2); void onBlankLoaded(); } public AdWebView(Context context, Listener listener) { super(context.getApplicationContext()); i.f(context, "context"); i.f(listener, "listener"); this.listener = listener; this.adLock = new ReentrantLock(); setLayerType(1, null); setBackgroundColor(0); setOnTouchListener(new View.OnTouchListener() { @Override public final boolean onTouch(View view, MotionEvent motionEvent) { i.e(motionEvent, "event"); int action = motionEvent.getAction(); boolean z10 = false; if (action != 1) { if (action != 2) { return false; } return true; } if (AdWebView.access$getCurrentAd$p(AdWebView.this).getId().length() > 0) { z10 = true; } if (z10) { AdWebView.this.notifyAdClicked(); } return true; } }); setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView webView, String str) { boolean z10; i.f(webView, "view"); i.f(str, "url"); super.onPageFinished(webView, str); AdWebView.this.adLock.lock(); try { if (AdWebView.access$getCurrentAd$p(AdWebView.this).getId().length() > 0) { z10 = true; } else { z10 = false; } if (z10 && !AdWebView.this.loaded) { AdWebView.this.loaded = true; AdWebView.this.notifyAdLoaded(); } } finally { AdWebView.this.adLock.unlock(); } } @Override public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) { boolean z10; i.f(webView, "view"); i.f(webResourceRequest, "request"); i.f(webResourceError, "error"); super.onReceivedError(webView, webResourceRequest, webResourceError); if (AdWebView.access$getCurrentAd$p(AdWebView.this).getId().length() > 0) { z10 = true; } else { z10 = false; } if (z10 && !AdWebView.this.loaded) { AdWebView.this.loaded = true; AdWebView.this.notifyAdLoadFailed(); } } @Override public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) { i.f(webView, "view"); i.f(webResourceRequest, "request"); return true; } }); WebSettings settings = getSettings(); i.e(settings, "settings"); settings.setJavaScriptEnabled(true); } public static final Ad access$getCurrentAd$p(AdWebView adWebView) { Ad ad2 = adWebView.currentAd; if (ad2 != null) { return ad2; } i.l("currentAd"); throw null; } public final void notifyAdClicked() { this.adLock.lock(); try { Listener listener = this.listener; Ad ad2 = this.currentAd; if (ad2 != null) { listener.onAdClicked(ad2); } else { i.l("currentAd"); throw null; } } finally { this.adLock.unlock(); } } public final void notifyAdLoadFailed() { this.adLock.lock(); try { this.listener.onAdLoadFailed(); } finally { this.adLock.unlock(); } } public final void notifyAdLoaded() { this.adLock.lock(); try { Listener listener = this.listener; Ad ad2 = this.currentAd; if (ad2 != null) { listener.onAdLoaded(ad2); } else { i.l("currentAd"); throw null; } } finally { this.adLock.unlock(); } } private final void notifyBlankLoaded() { this.adLock.lock(); try { this.listener.onBlankLoaded(); } finally { this.adLock.unlock(); } } public void _$_clearFindViewByIdCache() { HashMap hashMap = this._$_findViewCache; if (hashMap != null) { hashMap.clear(); } } public View _$_findCachedViewById(int i10) { if (this._$_findViewCache == null) { this._$_findViewCache = new HashMap(); } View view = (View) this._$_findViewCache.get(Integer.valueOf(i10)); if (view != null) { return view; } View findViewById = findViewById(i10); this._$_findViewCache.put(Integer.valueOf(i10), findViewById); return findViewById; } public final void loadAd(Ad ad2) { i.f(ad2, "ad"); this.adLock.lock(); try { this.currentAd = ad2; this.loaded = false; loadUrl(ad2.getUrl()); } finally { this.adLock.unlock(); } } public final void loadBlank() { this.adLock.lock(); try { this.currentAd = new Ad(null, null, null, null, null, null, 0L, 127, null); loadData("<html><head><meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" /></head><body></body></html>", "text/html", null); notifyBlankLoaded(); } finally { this.adLock.unlock(); } } }