导航菜单

页面标题

页面副标题

RummyCircle v11000.89 - OverlayMinMaxFragment.java 源代码

正在查看: RummyCircle v11000.89 应用的 OverlayMinMaxFragment.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.games24x7.pgwebview.ui;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import androidx.activity.o;
import androidx.appcompat.app.j;
import androidx.appcompat.widget.V;
import androidx.camera.camera2.internal.B;
import androidx.camera.camera2.internal.C;
import androidx.camera.camera2.internal.M0;
import androidx.camera.camera2.internal.R0;
import androidx.camera.camera2.internal.compat.p;
import androidx.camera.core.p0;
import com.games24x7.pgwebview.R;
import com.games24x7.pgwebview.communication.WebviewRequestEventHandler;
import com.games24x7.pgwebview.communication.external.eventbus.events.JsInterfaceHolder;
import com.games24x7.pgwebview.communication.internal.eventbus.event.MinMaxWebviewEvent;
import com.games24x7.pgwebview.communication.internal.eventbus.event.MinMaxWindowReqEvent;
import com.games24x7.pgwebview.custom.PGWebView;
import com.games24x7.pgwebview.enums.WebReqEventType;
import com.games24x7.pgwebview.enums.WebviewEventType;
import com.games24x7.pgwebview.models.WebViewConfiguration;
import com.google.android.gms.common.api.CommonStatusCodes;
import com.google.gson.reflect.a;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

@Metadata
public final class OverlayMinMaxFragment extends DialogFragment {

    @NotNull
    public static final String ARG_CUSTOM_WEB_VIEW_CONFIG = "custom_web_view_config";

    @NotNull
    public static final String ARG_HEIGHT_AS_PERCENTAGE = "height_percentage";

    @NotNull
    public static final String ARG_INITIAL_URL = "currentURL";

    @NotNull
    public static final String ARG_SHOULD_SHOW_CLOSE_BUTTON = "show_close";

    @NotNull
    public static final String ARG_SHOULD_SHOW_MINIMIZE_BUTTON = "show_minimize";

    @NotNull
    public static final String ARG_WEBVIEW_METADATA = "metadata";

    @NotNull
    public static final String ARG_WIDTH_AS_PERCENTAGE = "width_percentage";
    public static final float DIMENSION_MATCH_PARENT = -1.0f;
    public static final float DIMENSION_UNCHANGED = -2.0f;
    private static final int INVALID_DIMENSION = -1;

    @NotNull
    public static final String WEBVIEW_ID = "webviewid";
    private int calculatedDialogHeight;
    private int calculatedDialogWidth;
    private ImageView closeButton;
    private boolean isDialogHidden;
    private ImageView minimizeButton;
    private PGWebView webView;
    private WebViewConfiguration webViewConfiguration;

    @NotNull
    public static final Companion Companion = new Companion(null);
    private static final String TAG = "OverlayMinMaxFragment";

    @NotNull
    private String webviewId = "";

    @NotNull
    private String webviewMetaData = "";

    @NotNull
    private String currentURL = "";
    private boolean shouldShowMinimizeButton = true;
    private boolean shouldShowCloseButton = true;
    private float widthPercentageOfOriginal = 90.0f;
    private float heightPercentageOfOriginal = 90.0f;

    @Metadata
    public static final class Companion {
        private Companion() {
        }

        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }
    }

    @Metadata
    public class WhenMappings {
        public static final int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[WebReqEventType.values().length];
            iArr[WebReqEventType.CREATE.ordinal()] = 1;
            iArr[WebReqEventType.CLOSE.ordinal()] = 2;
            iArr[WebReqEventType.LOADURL.ordinal()] = 3;
            iArr[WebReqEventType.EXECUTESCRIPT.ordinal()] = 4;
            iArr[WebReqEventType.LOADDATA.ordinal()] = 5;
            iArr[WebReqEventType.LOADHTML.ordinal()] = 6;
            iArr[WebReqEventType.LOADFILE.ordinal()] = 7;
            iArr[WebReqEventType.STOPLOADING.ordinal()] = 8;
            iArr[WebReqEventType.RELOAD.ordinal()] = 9;
            iArr[WebReqEventType.CANGOBACK.ordinal()] = 10;
            iArr[WebReqEventType.CANGOFORWARD.ordinal()] = 11;
            iArr[WebReqEventType.GOFORWARD.ordinal()] = 12;
            iArr[WebReqEventType.GOBACK.ordinal()] = 13;
            iArr[WebReqEventType.MINIMIZE.ordinal()] = 14;
            iArr[WebReqEventType.MAXIMIZE.ordinal()] = 15;
            iArr[WebReqEventType.SETBACKGROUNDRESOURCE.ordinal()] = 16;
            $EnumSwitchMapping$0 = iArr;
        }
    }

    private final boolean canGoBack(java.lang.String r10) {
        throw new UnsupportedOperationException("Method not decompiled: com.games24x7.pgwebview.ui.OverlayMinMaxFragment.canGoBack(java.lang.String):boolean");
    }

    private final boolean canGoForward(java.lang.String r10) {
        throw new UnsupportedOperationException("Method not decompiled: com.games24x7.pgwebview.ui.OverlayMinMaxFragment.canGoForward(java.lang.String):boolean");
    }

    private final void configureCloseButton() {
        int i = this.shouldShowCloseButton ? 0 : 8;
        ImageView imageView = this.closeButton;
        if (imageView != null) {
            imageView.setVisibility(i);
        }
        ImageView imageView2 = this.closeButton;
        if (imageView2 != null) {
            imageView2.setOnClickListener(new com.cashfree.pg.ui.hidden.checkout.dialog.h(this, 2));
        }
    }

    public static final void m20configureCloseButton$lambda4(OverlayMinMaxFragment overlayMinMaxFragment, View view) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        overlayMinMaxFragment.onCloseButtonClicked();
    }

    private final void configureLayout() {
        Dialog dialog;
        Window window;
        setDialogDimenstions();
        if (this.isDialogHidden) {
            hideDialog();
        }
        if (getActivity() == null || (dialog = getDialog()) == null || (window = dialog.getWindow()) == null) {
            return;
        }
        window.setSoftInputMode(16);
    }

    private final void configureMinimizeButton() {
        int i = this.shouldShowMinimizeButton ? 0 : 8;
        ImageView imageView = this.minimizeButton;
        if (imageView != null) {
            imageView.setVisibility(i);
        }
        ImageView imageView2 = this.minimizeButton;
        if (imageView2 != null) {
            imageView2.setOnClickListener(new com.cashfree.pg.core.api.ui.c(this, 4));
        }
    }

    public static final void m21configureMinimizeButton$lambda3(OverlayMinMaxFragment overlayMinMaxFragment, View view) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        overlayMinMaxFragment.onMinimizeButtonClicked();
    }

    @SuppressLint({"SetJavaScriptEnabled"})
    private final void configureWebview() {
        List<JsInterfaceHolder> jsInterfaceList;
        PGWebView pGWebView = this.webView;
        WebSettings settings = pGWebView != null ? pGWebView.getSettings() : null;
        if (settings != null) {
            WebViewConfiguration webViewConfiguration = this.webViewConfiguration;
            if (webViewConfiguration == null) {
                Intrinsics.q("webViewConfiguration");
                throw null;
            }
            settings.setDomStorageEnabled(webViewConfiguration.getDomStorageEnabled());
        }
        if (settings != null) {
            WebViewConfiguration webViewConfiguration2 = this.webViewConfiguration;
            if (webViewConfiguration2 == null) {
                Intrinsics.q("webViewConfiguration");
                throw null;
            }
            settings.setJavaScriptEnabled(webViewConfiguration2.getJavaScriptEnabled());
        }
        if (settings != null) {
            WebViewConfiguration webViewConfiguration3 = this.webViewConfiguration;
            if (webViewConfiguration3 == null) {
                Intrinsics.q("webViewConfiguration");
                throw null;
            }
            settings.setUserAgentString(webViewConfiguration3.getCustomUserAgent());
        }
        if (settings != null) {
            settings.setLoadsImagesAutomatically(true);
        }
        if (settings != null) {
            settings.setMixedContentMode(0);
        }
        OverlayWebViewClient overlayWebViewClient = new OverlayWebViewClient(this) {
            {
                super();
            }

            @Override
            public void onPageFinished(@NotNull WebView webView, @NotNull String str) {
                Intrinsics.checkNotNullParameter(webView, "view");
                Intrinsics.checkNotNullParameter(str, "url");
                super.onPageFinished(webView, str);
                webView.scrollTo(0, 0);
            }
        };
        PGWebView pGWebView2 = this.webView;
        if (pGWebView2 != null) {
            pGWebView2.setWebViewClient(overlayWebViewClient);
        }
        if (getActivity() != null && (jsInterfaceList = WebviewRequestEventHandler.Companion.getJsInterfaceList(this.webviewId)) != null) {
            for (JsInterfaceHolder jsInterfaceHolder : jsInterfaceList) {
                PGWebView pGWebView3 = this.webView;
                if (pGWebView3 != null) {
                    pGWebView3.addJavascriptInterface(jsInterfaceHolder.getJsClass(), jsInterfaceHolder.getJsName());
                }
            }
        }
        sendWebviewEvent(new MinMaxWebviewEvent(this.webviewId, WebviewEventType.CREATED, null, this.webView, 4, null));
    }

    private final float deriveNewDimension(float f, float f2, float f3) {
        if (f3 == -1.0f) {
            return -1.0f;
        }
        return f3 == -2.0f ? f2 : (f * f3) / 100;
    }

    private final void evaluateJS(String str, String str2) {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new p0(this, str2, 6));
        }
    }

    public static final void m22evaluateJS$lambda12(OverlayMinMaxFragment overlayMinMaxFragment, String str) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        Intrinsics.checkNotNullParameter(str, "$js");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.evaluateJavascript(str, null);
        }
    }

    private final void goBack(String str) {
        goBackWebView();
    }

    private final void goBackWebView() {
        PGWebView pGWebView = this.webView;
        if (pGWebView == null || !pGWebView.canGoBack()) {
            Log.i(TAG, "BACK BUTTON : can not go back, Finish");
            onCloseButtonClicked();
            return;
        }
        Log.i(TAG, "BACK BUTTON : can go back");
        PGWebView pGWebView2 = this.webView;
        if (pGWebView2 != null) {
            pGWebView2.goBack();
        }
    }

    private final void goForward(String str) {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new V(this, 7));
        }
    }

    public static final void m23goForward$lambda11(OverlayMinMaxFragment overlayMinMaxFragment) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.goForward();
        }
    }

    private final void loadData(String str, final String str2, final String str3, final String str4, final String str5) {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    OverlayMinMaxFragment.m24loadData$lambda6(OverlayMinMaxFragment.this, str5, str2, str3, str4);
                }
            });
        }
    }

    public static final void m24loadData$lambda6(OverlayMinMaxFragment overlayMinMaxFragment, String str, String str2, String str3, String str4) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        Intrinsics.checkNotNullParameter(str, "$baseUrl");
        Intrinsics.checkNotNullParameter(str2, "$data");
        Intrinsics.checkNotNullParameter(str3, "$mimeType");
        Intrinsics.checkNotNullParameter(str4, "$encoding");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.loadDataWithBaseURL(str, str2, str3, str4, null);
        }
    }

    private final void loadFile(String str, String str2) {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new p(this, str2, 8));
        }
    }

    public static final void m25loadFile$lambda8(OverlayMinMaxFragment overlayMinMaxFragment, String str) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        Intrinsics.checkNotNullParameter(str, "$filePath");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.loadUrl(str);
        }
    }

    private final void loadHtml(String str, String str2, String str3) {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new B(3, this, str3, str2));
        }
    }

    public static final void m26loadHtml$lambda7(OverlayMinMaxFragment overlayMinMaxFragment, String str, String str2) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        Intrinsics.checkNotNullParameter(str, "$baseUrl");
        Intrinsics.checkNotNullParameter(str2, "$html");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.loadDataWithBaseURL(str, str2, null, null, null);
        }
    }

    private final void loadUrl(String str, String str2) {
        WebViewConfiguration webViewConfiguration = this.webViewConfiguration;
        if (webViewConfiguration == null) {
            Intrinsics.q("webViewConfiguration");
            throw null;
        }
        if (Intrinsics.a(webViewConfiguration.getEnableEvaluateJs(), Boolean.TRUE) && StringsKt.E(str2, "javascript:", false)) {
            evaluateJS(this.webviewId, str2);
            return;
        }
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new C(this, str2, 8));
        }
    }

    public static final void m27loadUrl$lambda13(OverlayMinMaxFragment overlayMinMaxFragment, String str) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        Intrinsics.checkNotNullParameter(str, "$url");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.loadUrl(str);
        }
    }

    public final void onCloseButtonClicked() {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new M0(this, 3));
        }
    }

    public static final void m28onCloseButtonClicked$lambda5(OverlayMinMaxFragment overlayMinMaxFragment) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        overlayMinMaxFragment.sendWebviewEvent(new MinMaxWebviewEvent(overlayMinMaxFragment.webviewId, WebviewEventType.CLOSED, null, null, 12, null));
        overlayMinMaxFragment.dismiss();
    }

    private final void onMinimizeButtonClicked() {
        hideDialog();
    }

    private final void refreshDialogDimension() {
        View decorView;
        Dialog dialog = getDialog();
        if (dialog == null) {
            return;
        }
        Window window = dialog.getWindow();
        if (window != null) {
            window.setLayout(this.calculatedDialogWidth, this.calculatedDialogHeight);
        }
        Window window2 = dialog.getWindow();
        if (window2 == null || (decorView = window2.getDecorView()) == null) {
            return;
        }
        decorView.requestLayout();
    }

    private final void reload(String str) {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new o(this, 11));
        }
    }

    public static final void m29reload$lambda10(OverlayMinMaxFragment overlayMinMaxFragment) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.reload();
        }
    }

    public final void sendWebviewEvent(Object obj) {
        org.greenrobot.eventbus.b.c().i(obj);
    }

    private final void setBackgroundResource(String str, JSONObject jSONObject) {
        try {
            Intrinsics.c(jSONObject);
            final int optInt = jSONObject.optInt("resId");
            Activity activity = getActivity();
            if (activity != null) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        OverlayMinMaxFragment.m30setBackgroundResource$lambda14(OverlayMinMaxFragment.this, optInt);
                    }
                });
            }
        } catch (Exception e) {
            Log.e(TAG, "setBackgroundResource :: Exception while parsing the Resource Id");
            e.printStackTrace();
        }
    }

    public static final void m30setBackgroundResource$lambda14(OverlayMinMaxFragment overlayMinMaxFragment, int i) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.setBackgroundResource(i);
        }
    }

    private final void setDialogDimenstions() {
        View decorView;
        View decorView2;
        Dialog dialog = getDialog();
        if (dialog == null) {
            return;
        }
        String str = com.games24x7.pgwebview.util.b.a;
        Activity activity = getActivity();
        if (activity == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.app.Activity");
        }
        int b = com.games24x7.pgwebview.util.b.b(activity);
        Activity activity2 = getActivity();
        if (activity2 == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.app.Activity");
        }
        int a = com.games24x7.pgwebview.util.b.a(activity2);
        Window window = dialog.getWindow();
        Integer num = null;
        Integer valueOf = (window == null || (decorView2 = window.getDecorView()) == null) ? null : Integer.valueOf(decorView2.getWidth());
        if (window != null && (decorView = window.getDecorView()) != null) {
            num = Integer.valueOf(decorView.getHeight());
        }
        if (valueOf != null) {
            this.calculatedDialogWidth = (int) deriveNewDimension(b, valueOf.intValue(), this.widthPercentageOfOriginal);
        }
        if (num != null) {
            this.calculatedDialogHeight = (int) deriveNewDimension(a, num.intValue(), this.heightPercentageOfOriginal);
        }
        refreshDialogDimension();
    }

    private final void stopLoading(String str) {
        Activity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new R0(this, 4));
        }
    }

    public static final void m31stopLoading$lambda9(OverlayMinMaxFragment overlayMinMaxFragment) {
        Intrinsics.checkNotNullParameter(overlayMinMaxFragment, "this$0");
        PGWebView pGWebView = overlayMinMaxFragment.webView;
        if (pGWebView != null) {
            pGWebView.stopLoading();
        }
    }

    public final void hideDialog() {
        this.isDialogHidden = true;
        Dialog dialog = getDialog();
        if (dialog != null) {
            dialog.hide();
        }
        sendWebviewEvent(new MinMaxWebviewEvent(this.webviewId, WebviewEventType.MINIMIZED, null, null, 12, null));
    }

    public final boolean isDialogHidden() {
        return this.isDialogHidden;
    }

    @Override
    public void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        configureLayout();
    }

    @Override
    public void onConfigurationChanged(@NotNull Configuration configuration) {
        Intrinsics.checkNotNullParameter(configuration, "newConfig");
        super.onConfigurationChanged(configuration);
        refreshDialogDimension();
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Bundle arguments = getArguments();
        if (arguments != null) {
            String string = arguments.getString(ARG_INITIAL_URL, this.currentURL);
            Intrinsics.checkNotNullExpressionValue(string, "args.getString(ARG_INITIAL_URL, currentURL)");
            this.currentURL = string;
            String string2 = arguments.getString(WEBVIEW_ID, string);
            Intrinsics.checkNotNullExpressionValue(string2, "args.getString(WEBVIEW_ID, currentURL)");
            this.webviewId = string2;
            String string3 = arguments.getString(ARG_WEBVIEW_METADATA, this.webviewMetaData);
            Intrinsics.checkNotNullExpressionValue(string3, "args.getString(ARG_WEBVI…ETADATA, webviewMetaData)");
            this.webviewMetaData = string3;
            this.shouldShowMinimizeButton = arguments.getBoolean(ARG_SHOULD_SHOW_MINIMIZE_BUTTON, this.shouldShowMinimizeButton);
            this.shouldShowCloseButton = arguments.getBoolean(ARG_SHOULD_SHOW_CLOSE_BUTTON, this.shouldShowCloseButton);
            this.widthPercentageOfOriginal = arguments.getFloat(ARG_WIDTH_AS_PERCENTAGE, this.widthPercentageOfOriginal);
            this.heightPercentageOfOriginal = arguments.getFloat(ARG_HEIGHT_AS_PERCENTAGE, this.heightPercentageOfOriginal);
            Object k = new com.google.gson.d().k(arguments.getString(ARG_CUSTOM_WEB_VIEW_CONFIG), new a<WebViewConfiguration>() {
            }.getType());
            Intrinsics.checkNotNullExpressionValue(k, "Gson().fromJson(\n       …>() {}.type\n            )");
            this.webViewConfiguration = (WebViewConfiguration) k;
        }
        setStyle(2, R.style.OverlayDialogTheme);
        String str = this.webviewId;
        WebviewEventType webviewEventType = WebviewEventType.ON_CREATE;
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("webviewId", this.webviewId);
        jSONObject.put("url", this.currentURL);
        Unit unit = Unit.a;
        sendWebviewEvent(new MinMaxWebviewEvent(str, webviewEventType, jSONObject, null, 8, null));
    }

    @Override
    public View onCreateView(@NotNull LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        Intrinsics.checkNotNullParameter(layoutInflater, "inflater");
        View inflate = layoutInflater.inflate(R.layout.fragment_overlay, viewGroup, false);
        PGWebView findViewById = inflate.findViewById(R.id.webview);
        if (findViewById == null) {
            throw new NullPointerException("null cannot be cast to non-null type com.games24x7.pgwebview.custom.PGWebView");
        }
        this.webView = findViewById;
        View findViewById2 = inflate.findViewById(R.id.minimize);
        if (findViewById2 == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.widget.ImageView");
        }
        this.minimizeButton = (ImageView) findViewById2;
        View findViewById3 = inflate.findViewById(R.id.close);
        if (findViewById3 == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.widget.ImageView");
        }
        this.closeButton = (ImageView) findViewById3;
        configureWebview();
        configureMinimizeButton();
        configureCloseButton();
        PGWebView pGWebView = this.webView;
        if (pGWebView != null) {
            pGWebView.loadUrl(this.currentURL);
        }
        return inflate;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

    @org.greenrobot.eventbus.i(threadMode = ThreadMode.MAIN_ORDERED)
    public final void onRequest(@NotNull MinMaxWindowReqEvent minMaxWindowReqEvent) {
        String string;
        Intrinsics.checkNotNullParameter(minMaxWindowReqEvent, "event");
        Log.e(TAG, "onRequested " + minMaxWindowReqEvent);
        switch (WhenMappings.$EnumSwitchMapping$0[minMaxWindowReqEvent.getWebReqEventType().ordinal()]) {
            case 2:
                ImageView imageView = this.closeButton;
                if (imageView != null) {
                    imageView.performClick();
                    break;
                }
                break;
            case 3:
                JSONObject payload = minMaxWindowReqEvent.getPayload();
                string = payload != null ? payload.getString("url") : null;
                loadUrl(minMaxWindowReqEvent.getId(), string != null ? string : "");
                break;
            case 4:
                JSONObject payload2 = minMaxWindowReqEvent.getPayload();
                string = payload2 != null ? payload2.getString("script") : null;
                evaluateJS(minMaxWindowReqEvent.getId(), string != null ? string : "");
                break;
            case 5:
                JSONObject payload3 = minMaxWindowReqEvent.getPayload();
                String string2 = payload3 != null ? payload3.getString("data") : null;
                String str = string2 == null ? "" : string2;
                JSONObject payload4 = minMaxWindowReqEvent.getPayload();
                String string3 = payload4 != null ? payload4.getString("mimeType") : null;
                String str2 = string3 == null ? "" : string3;
                JSONObject payload5 = minMaxWindowReqEvent.getPayload();
                String string4 = payload5 != null ? payload5.getString("encoding") : null;
                String str3 = string4 == null ? "" : string4;
                JSONObject payload6 = minMaxWindowReqEvent.getPayload();
                string = payload6 != null ? payload6.getString("baseUrl") : null;
                loadData(minMaxWindowReqEvent.getId(), str, str2, str3, string == null ? "" : string);
                break;
            case 6:
                JSONObject payload7 = minMaxWindowReqEvent.getPayload();
                String string5 = payload7 != null ? payload7.getString("html") : null;
                if (string5 == null) {
                    string5 = "";
                }
                JSONObject payload8 = minMaxWindowReqEvent.getPayload();
                string = payload8 != null ? payload8.getString("baseUrl") : null;
                loadHtml(minMaxWindowReqEvent.getId(), string5, string != null ? string : "");
                break;
            case 7:
                JSONObject payload9 = minMaxWindowReqEvent.getPayload();
                string = payload9 != null ? payload9.getString("filePath") : null;
                loadFile(minMaxWindowReqEvent.getId(), string != null ? string : "");
                break;
            case 8:
                stopLoading(minMaxWindowReqEvent.getId());
                break;
            case 9:
                reload(minMaxWindowReqEvent.getId());
                break;
            case CommonStatusCodes.DEVELOPER_ERROR:
                canGoBack(minMaxWindowReqEvent.getId());
                break;
            case 11:
                canGoForward(minMaxWindowReqEvent.getId());
                break;
            case 12:
                goForward(minMaxWindowReqEvent.getId());
                break;
            case CommonStatusCodes.ERROR:
                goBack(minMaxWindowReqEvent.getId());
                break;
            case CommonStatusCodes.INTERRUPTED:
                hideDialog();
                break;
            case CommonStatusCodes.TIMEOUT:
                unhideDialog();
                break;
            case CommonStatusCodes.CANCELED:
                setBackgroundResource(minMaxWindowReqEvent.getId(), minMaxWindowReqEvent.getPayload());
                break;
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if (this.isDialogHidden) {
            hideDialog();
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        org.greenrobot.eventbus.b.c().m(this);
        if (this.isDialogHidden) {
            hideDialog();
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        org.greenrobot.eventbus.b.c().o(this);
    }

    public final void setDialogHidden(boolean z) {
        this.isDialogHidden = z;
    }

    public final void setDimensionAsPercentage(float f, float f2) {
        this.widthPercentageOfOriginal = f;
        this.heightPercentageOfOriginal = f2;
        setDialogDimenstions();
    }

    public final void unhideDialog() {
        this.isDialogHidden = false;
        Dialog dialog = getDialog();
        if (dialog != null) {
            dialog.show();
        }
        sendWebviewEvent(new MinMaxWebviewEvent(this.webviewId, WebviewEventType.MAXIMIZED, null, null, 12, null));
    }

    @Metadata
    public class OverlayWebViewClient extends WebViewClient {
        private String hideAccessoriesScript;
        private final boolean interceptReq;
        private final String overlayBafHeader;
        private final String overlayFooter;
        private final String overlayHeader;
        private final boolean shouldRemoveAccessories;
        private final String TAG = OverlayWebViewClient.class.getSimpleName();
        private final long PAGE_LOAD_TIMEOUT = 30000;

        @NotNull
        private final Handler handler = new Handler();

        public OverlayWebViewClient() {
            configure();
        }

        private final void configure() {
            StringBuilder a = com.games24x7.pgwebview.a.a("javascript:document.addEventListener(\"DOMContentLoaded\", function(event) {document.getElementsByClassName('");
            a.append(this.overlayHeader);
            a.append("')[0].style.display = 'none';document.getElementsByClassName('");
            a.append(this.overlayFooter);
            a.append("')[0].style.display = 'none';var temp = document.getElementsByClassName('");
            this.hideAccessoriesScript = android.support.v4.media.a.j(a, this.overlayBafHeader, "');temp[0].innerHTML='';});");
        }

        public static final void m33shouldInterceptRequest$lambda1(WebView webView, OverlayWebViewClient overlayWebViewClient) {
            Intrinsics.checkNotNullParameter(webView, "$view");
            Intrinsics.checkNotNullParameter(overlayWebViewClient, "this$0");
            String str = overlayWebViewClient.hideAccessoriesScript;
            Intrinsics.c(str);
            webView.loadUrl(str);
        }

        @Override
        public void onPageFinished(@NotNull WebView webView, @NotNull String str) {
            Intrinsics.checkNotNullParameter(webView, "view");
            Intrinsics.checkNotNullParameter(str, "url");
            super.onPageFinished(webView, str);
            this.handler.removeCallbacksAndMessages(null);
            OverlayMinMaxFragment overlayMinMaxFragment = OverlayMinMaxFragment.this;
            String str2 = overlayMinMaxFragment.webviewId;
            WebviewEventType webviewEventType = WebviewEventType.LOADED;
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("webviewId", OverlayMinMaxFragment.this.webviewId);
            jSONObject.put("url", str);
            Unit unit = Unit.a;
            overlayMinMaxFragment.sendWebviewEvent(new MinMaxWebviewEvent(str2, webviewEventType, jSONObject, null, 8, null));
        }

        @Override
        public void onPageStarted(@NotNull WebView webView, @NotNull String str, Bitmap bitmap) {
            Intrinsics.checkNotNullParameter(webView, "view");
            Intrinsics.checkNotNullParameter(str, "url");
            super.onPageStarted(webView, str, bitmap);
            if (this.shouldRemoveAccessories) {
                String str2 = this.hideAccessoriesScript;
                Intrinsics.c(str2);
                webView.loadUrl(str2);
            }
            this.handler.postDelayed(new e(), this.PAGE_LOAD_TIMEOUT);
        }

        @Override
        public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
            super.onReceivedError(webView, webResourceRequest, webResourceError);
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("errorCode", webResourceError != null ? Integer.valueOf(webResourceError.getErrorCode()) : null);
            jSONObject.put("description", webResourceError != null ? webResourceError.getDescription() : null);
            jSONObject.put("failingUrl", webResourceRequest != null ? webResourceRequest.getUrl() : null);
            OverlayMinMaxFragment overlayMinMaxFragment = OverlayMinMaxFragment.this;
            overlayMinMaxFragment.sendWebviewEvent(new MinMaxWebviewEvent(overlayMinMaxFragment.webviewId, WebviewEventType.LOADERROR, jSONObject, null, 8, null));
        }

        @Override
        public boolean onRenderProcessGone(WebView webView, @NotNull RenderProcessGoneDetail renderProcessGoneDetail) {
            ViewParent parent;
            Intrinsics.checkNotNullParameter(renderProcessGoneDetail, "detail");
            String str = OverlayMinMaxFragment.TAG;
            StringBuilder a = com.games24x7.pgwebview.a.a("onRenderProcessGone ::  Stopping WebView crash :: Webview Id is :: ");
            a.append(OverlayMinMaxFragment.this.webviewId);
            a.append(" :: Crash Details are :: ");
            a.append(j.c(renderProcessGoneDetail));
            Log.e(str, a.toString());
            OverlayMinMaxFragment overlayMinMaxFragment = OverlayMinMaxFragment.this;
            String str2 = overlayMinMaxFragment.webviewId;
            WebviewEventType webviewEventType = WebviewEventType.WEBVIEW_CRASH;
            JSONObject jSONObject = new JSONObject();
            OverlayMinMaxFragment overlayMinMaxFragment2 = OverlayMinMaxFragment.this;
            jSONObject.put("webviewId", overlayMinMaxFragment2.webviewId);
            jSONObject.put("url", overlayMinMaxFragment2.currentURL);
            Unit unit = Unit.a;
            overlayMinMaxFragment.sendWebviewEvent(new MinMaxWebviewEvent(str2, webviewEventType, jSONObject, null, 8, null));
            if (webView != null && (parent = webView.getParent()) != null && (parent instanceof ViewGroup)) {
                ((ViewGroup) parent).removeView(webView);
            }
            OverlayMinMaxFragment.this.onCloseButtonClicked();
            return true;
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(@NotNull WebView webView, @NotNull String str) {
            Activity activity;
            Intrinsics.checkNotNullParameter(webView, "view");
            Intrinsics.checkNotNullParameter(str, "url");
            if (!this.interceptReq) {
                return super.shouldInterceptRequest(webView, str);
            }
            if (this.shouldRemoveAccessories && (activity = OverlayMinMaxFragment.this.getActivity()) != null) {
                activity.runOnUiThread(new f(webView, this, 0));
            }
            return super.shouldInterceptRequest(webView, str);
        }

        @Override
        public boolean shouldOverrideUrlLoading(@NotNull WebView webView, String str) {
            Intrinsics.checkNotNullParameter(webView, "view");
            if (str != null) {
                try {
                    OverlayMinMaxFragment overlayMinMaxFragment = OverlayMinMaxFragment.this;
                    if (StringsKt.E(str, "mailto:", false)) {
                        Uri parse = Uri.parse(str);
                        Intent intent = new Intent("android.intent.action.SENDTO");
                        intent.setData(parse);
                        webView.stopLoading();
                        overlayMinMaxFragment.startActivity(Intent.createChooser(intent, "Send email"));
                        return super.shouldOverrideUrlLoading(webView, str);
                    }
                    if (StringsKt.E(str, "tel:", false)) {
                        new Intent("android.intent.action.DIAL").setData(Uri.parse(str));
                        webView.stopLoading();
                        overlayMinMaxFragment.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
                        return super.shouldOverrideUrlLoading(webView, str);
                    }
                } catch (Exception e) {
                    Log.e(this.TAG, "shouldOverrideUrlLoading :: Got crash :: Crash");
                    e.printStackTrace();
                }
            }
            return super.shouldOverrideUrlLoading(webView, str);
        }

        public static final void m32onPageStarted$lambda0() {
        }

        private final void closeWebview(WebView webView) {
        }
    }
}