大漢易經書院.apk(点击下载) / b.java


package com;

import android.content.Context;
import android.os.Build;
import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.print.PrintManager;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.c.e;
import com.c.g;
import java.lang.reflect.Constructor;

/* compiled from: Unitiy */
public class b {

    /* renamed from: ʻ  reason: contains not printable characters */
    static int f4504 = -1;

    /* renamed from: ʼ  reason: contains not printable characters */
    private static boolean f4505 = false;

    /* renamed from: ʽ  reason: contains not printable characters */
    private static Constructor f4506;

    /* renamed from: ʻ  reason: contains not printable characters */
    public static e m6372(Context context, boolean z) {
        if (z && f4505) {
            if (f4506 == null) {
                try {
                    f4506 = Class.forName("com.TWebView").getDeclaredConstructor(Context.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            Constructor constructor = f4506;
            if (constructor != null) {
                try {
                    return (e) constructor.newInstance(context);
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        }
        return new a(context);
    }

    /* renamed from: ʻ  reason: contains not printable characters */
    static synchronized boolean m6375(Context context) {
        synchronized (b.class) {
            if (f4504 == -1) {
                try {
                    Class.forName("com.lt.plugin.agreement.Agreement");
                    f4504 = 1;
                } catch (Exception unused) {
                    f4504 = 0;
                }
            }
            if (context == null || f4504 == 0) {
                return true;
            }
            return context.getSharedPreferences("LT-APP", 0).getBoolean("agree", false);
        }
    }

    /* renamed from: ʻ  reason: contains not printable characters */
    public static synchronized boolean m6376(Context context, g.a aVar) {
        synchronized (b.class) {
            if (f4505) {
                return false;
            }
            try {
                Class.forName("com.TWebView").getMethod("initX5Environment", Context.class, g.a.class).invoke(null, context, aVar);
                f4505 = true;
                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
    }

    /* renamed from: ʻ  reason: contains not printable characters */
    public static void m6373(Context context, final String str, String str2) {
        final a aVar = new a(context);
        aVar.setWebViewClient(new WebViewClient() {
            /* class com.b.AnonymousClass1 */

            @Override // android.webkit.WebViewClient
            public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
                return false;
            }

            @Override // android.webkit.WebViewClient
            public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                return false;
            }

            public void onPageFinished(WebView webView, String str) {
                Log.i("YM", "page finished loading " + str);
                b.m6374(str, aVar);
            }
        });
        aVar.loadDataWithBaseURL(null, str2, "text/html", "UTF-8", null);
    }

    /* renamed from: ʻ  reason: contains not printable characters */
    public static void m6374(String str, WebView webView) {
        PrintDocumentAdapter printDocumentAdapter;
        Context context = webView.getContext();
        PrintManager printManager = (PrintManager) context.getSystemService("print");
        if (printManager == null) {
            Toast.makeText(context, "设备没有打印服务", 1).show();
            return;
        }
        if (TextUtils.isEmpty(str)) {
            str = "Print " + System.currentTimeMillis();
        }
        if (Build.VERSION.SDK_INT >= 21) {
            printDocumentAdapter = webView.createPrintDocumentAdapter(str);
        } else {
            printDocumentAdapter = webView.createPrintDocumentAdapter();
        }
        printManager.print(str, printDocumentAdapter, new PrintAttributes.Builder().build());
    }
}