Wolves Themes v1.0版本的 MD5 值为:cddc92b47f6b7c4a195c9625507eb51c

以下内容为反编译后的 VPAIDView.java 源代码,内容仅作参考


package com.appodeal.ads.networks.vpaid;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.appodeal.ads.Appodeal;
import com.appodeal.ads.networks.vpaid.c;
import com.appodeal.ads.utils.Log;
import com.facebook.ads.AudienceNetworkActivity;
import com.ironsource.sdk.constants.LocationConst;
import com.tapjoy.TJAdUnitConstants;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.nexage.sourcekit.util.HttpTools;
import org.nexage.sourcekit.vast.model.TRACKING_EVENTS_TYPE;
import org.nexage.sourcekit.vast.model.VASTModel;
@SuppressLint({"ViewConstructor"})
public class VPAIDView extends RelativeLayout {
    private Context a;
    private com.appodeal.ads.networks.vpaid.a b;
    private boolean c;
    private String d;
    private String e;
    private String f;
    private WebView g;
    private boolean h;
    private int i;
    private int j;
    private Timer k;
    private TextView l;
    private float m;
    private float n;
    private a o;
    private int p;
    private boolean q;
    private VASTModel r;
    private HashMap<TRACKING_EVENTS_TYPE, List<String>> s;
    private boolean t;

    public interface a {
        void a();
    }

    public VPAIDView(Context context, com.appodeal.ads.networks.vpaid.a aVar, boolean z, String str, VASTModel vASTModel) {
        super(context);
        this.h = false;
        this.i = 5;
        this.m = 0.0f;
        this.n = 0.0f;
        this.q = true;
        this.t = false;
        c.a(Appodeal.getLogLevel() == Log.LogLevel.verbose ? c.a.verbose : c.a.error);
        this.a = context;
        this.b = aVar;
        this.c = z;
        this.d = str;
        this.r = vASTModel;
        this.s = this.r.getTrackingUrls();
        this.e = vASTModel.getPickedMediaFileURL();
        this.f = vASTModel.getAdParameterms();
        a(new RelativeLayout.LayoutParams(-1, -1));
        k();
        this.j = this.i;
        g();
        this.p = 0;
    }

    private void a(WebView webView) {
        try {
            webView.onPause();
        } catch (Exception e) {
            Appodeal.a(e);
        }
    }

    @SuppressLint({"SetJavaScriptEnabled"})
    private void a(RelativeLayout.LayoutParams layoutParams) {
        this.g = new WebView(this.a) {
            @Override
            protected void onWindowVisibilityChanged(int i) {
                super.onWindowVisibilityChanged(i);
                if (i != 0) {
                    VPAIDView.this.b();
                    VPAIDView.this.o();
                    return;
                }
                VPAIDView.this.a();
                VPAIDView.this.d();
            }
        };
        this.g.setLayoutParams(layoutParams);
        this.g.getSettings().setLoadsImagesAutomatically(true);
        this.g.getSettings().setPluginState(WebSettings.PluginState.ON);
        this.g.getSettings().setJavaScriptEnabled(true);
        this.g.getSettings().setAppCacheEnabled(true);
        this.g.getSettings().setDomStorageEnabled(true);
        if (Build.VERSION.SDK_INT >= 17) {
            this.g.getSettings().setMediaPlaybackRequiresUserGesture(false);
        }
        if (Build.VERSION.SDK_INT >= 19) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
        this.g.setWebChromeClient(new WebChromeClient() {
            private boolean a(JsResult jsResult) {
                jsResult.cancel();
                return true;
            }

            @Override
            public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                String str = consoleMessage.message() + " in " + consoleMessage.sourceId() + " (Line: " + consoleMessage.lineNumber() + ")";
                c.a("VPAIDView", str);
                if (consoleMessage.messageLevel() != ConsoleMessage.MessageLevel.ERROR || consoleMessage.sourceId() == null || consoleMessage.lineNumber() == 0) {
                    return true;
                }
                if (VPAIDView.this.b != null && VPAIDView.this.p == 0) {
                    VPAIDView.this.c(str);
                }
                VPAIDView.this.j();
                return true;
            }

            @Override
            public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
                c.a("JS alert", str2);
                return a(jsResult);
            }

            @Override
            public boolean onJsConfirm(WebView webView, String str, String str2, JsResult jsResult) {
                c.a("JS confirm", str2);
                return a(jsResult);
            }

            @Override
            public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
                c.a("JS prompt", str2);
                return a(jsPromptResult);
            }
        });
        this.g.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView webView, String str) {
                if (VPAIDView.this.p == 0) {
                    c.a("VPAIDView", "onPageFinished: " + str);
                    VPAIDView.this.h();
                }
            }

            @Override
            @TargetApi(24)
            public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
                if (webResourceRequest.hasGesture()) {
                    VPAIDView.this.t = true;
                }
                return shouldOverrideUrlLoading(webView, webResourceRequest.getUrl().toString());
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                if (str.startsWith("vpaid://")) {
                    VPAIDView.this.b(str);
                    return true;
                }
                if (VPAIDView.this.t) {
                    VPAIDView.this.a.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                }
                return true;
            }
        });
        this.g.setOnTouchListener(new View.OnTouchListener() {
            @Override
            @SuppressLint({"ClickableViewAccessibility"})
            public boolean onTouch(View view, MotionEvent motionEvent) {
                switch (motionEvent.getAction()) {
                    case 0:
                    case 1:
                        VPAIDView.this.t = true;
                        if (view.hasFocus()) {
                            return false;
                        }
                        view.requestFocus();
                        return false;
                    default:
                        return false;
                }
            }
        });
        addView(this.g);
    }

    private void a(List<String> list) {
        c.a("VPAIDView", "entered fireUrls");
        if (list == null) {
            c.a("VPAIDView", "\turl list is null");
            return;
        }
        for (String str : list) {
            c.b("VPAIDView", "\tfiring url:" + str);
            HttpTools.httpGetURL(str);
        }
    }

    public void b(String str) {
        String str2;
        Map<String, String> a2 = new d().a(str);
        String str3 = a2.get(TJAdUnitConstants.String.COMMAND);
        String[] strArr = {"AdSkippableStateChange", "AdDurationChange", "AdVolumeChange", "AdClickThru", "AdError", "AdLog", "AdRemainingTime", "useCustomClose"};
        try {
            if (Arrays.asList("AdStarted", "AdStopped", "AdSkipped", "AdLoaded", "AdLinearChange", "AdSizeChange", "AdExpandedChange", "AdImpression", "AdInteraction", "AdVideoStart", "AdVideoFirstQuartile", "AdVideoMidpoint", "AdVideoThirdQuartile", "AdVideoComplete", "AdUserAcceptInvitation", "AdUserMinimize", "AdUserClose", "AdPaused", "AdPlaying").contains(str3)) {
                getClass().getDeclaredMethod(str3, new Class[0]).invoke(this, new Object[0]);
            } else if (Arrays.asList(strArr).contains(str3)) {
                Method declaredMethod = getClass().getDeclaredMethod(str3, String.class);
                if (!str3.equals("AdSkippableStateChange") && !str3.equals("AdDurationChange") && !str3.equals("AdVolumeChange")) {
                    if (!str3.equals("AdError") && !str3.equals("AdLog")) {
                        if (!str3.equals("AdClickThru")) {
                            if (str3.equals("AdRemainingTime")) {
                                str2 = LocationConst.TIME;
                            } else if (str3.equals("useCustomClose")) {
                                str2 = "useCustomClose";
                            }
                            declaredMethod.invoke(this, a2.get(str2));
                        }
                        str2 = "url";
                        declaredMethod.invoke(this, a2.get(str2));
                    }
                    str2 = NotificationCompat.CATEGORY_MESSAGE;
                    declaredMethod.invoke(this, a2.get(str2));
                }
                str2 = "state";
                declaredMethod.invoke(this, a2.get(str2));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void c(String str) {
        VASTModel vASTModel;
        int i;
        if (this.p == 0) {
            if (this.b == null) {
                return;
            }
            this.b.a(str);
            if (this.r == null) {
                return;
            }
            vASTModel = this.r;
            i = 900;
        } else if (this.p != 1) {
            return;
        } else {
            j();
            if (this.r == null) {
                return;
            }
            vASTModel = this.r;
            i = 405;
        }
        vASTModel.sendError(i);
    }

    private void g() {
        this.g.loadDataWithBaseURL("http://localhost", this.d.replace("{VPAID_JS_URL}", this.e), "text/html", AudienceNetworkActivity.WEBVIEW_ENCODING, null);
    }

    public void h() {
        if (this.f != null) {
            a("vpaid.setCreativeData(" + this.f + ")");
        }
        i();
    }

    private void i() {
        a("vpaid.loadAd()");
    }

    public void j() {
        c.a("VPAIDView", "closeView");
        if (this.p != 2) {
            this.p = 2;
            this.g.loadUrl("about:blank");
            a(this.g);
            e();
            if (this.o != null) {
                this.o.a();
            }
        }
    }

    private void k() {
        TextView textView;
        int i;
        this.l = new TextView(this.a);
        if (this.q) {
            textView = this.l;
            i = 4;
        } else {
            textView = this.l;
            i = 8;
        }
        textView.setVisibility(i);
        this.l.setTextColor(-1);
        this.l.setPadding(5, 5, 5, 5);
        this.l.setBackgroundColor(Color.parseColor("#6b000000"));
        addView(this.l);
    }

    static int l(VPAIDView vPAIDView) {
        int i = vPAIDView.j;
        vPAIDView.j = i - 1;
        return i;
    }

    private void l() {
        if (this.j == 0 || this.c || this.h || !this.q) {
            return;
        }
        this.k = new Timer();
        this.k.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                ((Activity) VPAIDView.this.a).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        VPAIDView.this.a("vpaid.getAdRemainingTime()");
                    }
                });
                if (VPAIDView.this.m <= 0.0f || VPAIDView.this.n <= 0.0f || VPAIDView.this.n - VPAIDView.this.m <= 0.0f || VPAIDView.this.j <= VPAIDView.this.i - (VPAIDView.this.n - VPAIDView.this.m)) {
                    VPAIDView.l(VPAIDView.this);
                } else {
                    VPAIDView.this.j = Math.round(VPAIDView.this.i - (VPAIDView.this.n - VPAIDView.this.m));
                }
                if (VPAIDView.this.j > 0) {
                    ((Activity) VPAIDView.this.a).runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            VPAIDView.this.l.setVisibility(0);
                            VPAIDView.this.l.setText("You can skip this video in " + String.valueOf(VPAIDView.this.j) + " seconds");
                        }
                    });
                    return;
                }
                ((Activity) VPAIDView.this.a).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        VPAIDView.this.n();
                    }
                });
                cancel();
            }
        }, 0L, 500L);
    }

    private void m() {
        if (this.k != null) {
            this.k.cancel();
            this.k = null;
        }
    }

    public void n() {
        if (this.h) {
            return;
        }
        this.l.setText("Skip video");
        this.h = true;
        this.l.setVisibility(0);
        this.l.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (VPAIDView.this.b != null) {
                    VPAIDView.this.b.a();
                }
                VPAIDView.this.j();
            }
        });
    }

    public void o() {
        if (this.p == 1) {
            a("vpaid.fireAdPauseEvent()");
        }
    }

    public void a() {
        if (this.p == 1) {
            l();
        }
    }

    @SuppressLint({"NewApi"})
    public void a(String str) {
        c.a("VPAIDView", "injecting js: " + str);
        if (TextUtils.isEmpty(str) || this.g == null) {
            return;
        }
        if (Build.VERSION.SDK_INT >= 19) {
            this.g.evaluateJavascript(str, new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String str2) {
                }
            });
            return;
        }
        WebView webView = this.g;
        webView.loadUrl("javascript:" + str);
    }

    public void b() {
        if (this.p == 1) {
            m();
        }
    }

    public boolean c() {
        return this.h;
    }

    public void d() {
        String str;
        if (this.p == 0) {
            this.p = 1;
            str = "vpaid.fireStartAdEvent()";
        } else {
            str = "vpaid.fireAdResumeEvent()";
        }
        a(str);
    }

    public void e() {
        if (this.b != null) {
            this.b.a();
        }
        if (this.r != null) {
            a(this.s.get(TRACKING_EVENTS_TYPE.close));
        }
    }

    public void f() {
        this.a = null;
        this.l = null;
        if (this.g != null) {
            try {
                this.g.setWebChromeClient(null);
                this.g.setWebViewClient(null);
                this.g = null;
            } catch (Exception e) {
                Appodeal.a(e);
            }
        }
    }

    public com.appodeal.ads.networks.vpaid.a getListener() {
        return this.b;
    }

    public void setListener(a aVar) {
        this.o = aVar;
    }
}