导航菜单

页面标题

页面副标题

Credmex v3.12.2 - WebViewActivity.java 源代码

正在查看: Credmex v3.12.2 应用的 WebViewActivity.java JAVA 源代码文件

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


package com.credmex.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import butterknife.BindView;
import butterknife.OnClick;
import com.credmex.ServerApiConfig;
import com.credmex.activity.WebViewActivity;
import com.credmex.authentication.helper.QuitAuthHelper;
import com.credmex.commom.BaseWebViewActivity;
import com.credmex.models.BluePayEvent;
import com.credmex.models.Credential;
import com.credmex.models.EventFinishLoginOrRegister;
import com.credmex.models.repository.RepayBankDialogHelper;
import com.credmex.utils.ActionUrlHelper;
import com.credmex.utils.AppUtil;
import com.credmex.utils.HeaderInfoHelper;
import com.credmex.widght.webViewPart.CookieManagerHelper;
import com.credmex.widght.webViewPart.CredMexJsBridgeHandler;
import com.github.lzyzsd.jsbridge.BridgeWebView;
import com.github.lzyzsd.jsbridge.CallBackFunction;
import com.open.mx.ui.views.RetryableWebViewContainer;
import com.open.mxbaselib.performance.WebReadyCallBack;
import com.sensorsdata.analytics.android.autotrack.aop.SensorsDataAutoTrackHelper;
import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented;
import com.veda.android.bananalibrary.infrastructure.BaseActivity;
import com.veda.supertoolkit.customtools.Logger;
import com.veda.supertoolkit.lifecycle.LifecycleEvent;
import com.yangqianguan.statistics.AutoTrackHelper;
import io.reactivex.disposables.Disposable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class WebViewActivity extends BaseWebViewActivity {
    public static final String FROM_PAGE = "fromPage";
    public static final String INTENT_KEY_ACTION_PURPOSE = "intentKeyActionPurpose";
    public static final String INTENT_KEY_IS_AUTH = "isAuth";
    public static final String INTENT_KEY_IS_IMMERSIVE_MODE = "INTENT_KEY_IS_IMMERSIVE_MODE";
    public static final String IS_COME_BACK_FROM_WEB = "IS_COME_BACK_FROM_WEB";
    public static final String IS_IMMERSIVE_MODE_BY_H5 = "reqSpeBar";
    public static final String TOOLBAR_LEFT_BTN_ICON_STYLE = "TOOLBAR_LEFT_BTN_ICON_STYLE";
    public static final String TOOLBAR_RIGHT_BTN_INTENT_GO_HELP = "TOOLBAR_RIGHT_BTN_INTENT_GO_HELP";
    public static final String USER_TOKEN = "userToken";
    protected String R;
    protected boolean S;
    protected boolean T = false;
    protected String U;
    protected int V;
    private ActivityResultLauncher<Intent> W;

    @Nullable
    BridgeWebView X;
    public CredMexJsBridgeHandler credMexJsBridgeHandler;

    @BindView(2131362477)
    LinearLayout llEmpty;

    @BindView(2131362888)
    RetryableWebViewContainer retryableWebViewContainer;

    @BindView(2131362910)
    Toolbar tbToolbar;

    class AnonymousClass1 implements ActivityResultCallback<ActivityResult> {
        AnonymousClass1() {
        }

        public void b(ActivityResult activityResult) {
            WebViewActivity.this.T0(activityResult);
        }

        public void onActivityResult(final ActivityResult activityResult) {
            WebViewActivity.this.retryableWebViewContainer.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    WebViewActivity.AnonymousClass1.this.b(activityResult);
                }
            }, 200L);
        }
    }

    @Retention(RetentionPolicy.SOURCE)
    public @interface ActionPurpose {
    }

    @Retention(RetentionPolicy.SOURCE)
    public @interface ToolbarLeftIconStyle {
    }

    @Retention(RetentionPolicy.SOURCE)
    public @interface ToolbarRightBtnIntent {
    }

    private void J0() {
        if (this.X == null) {
            return;
        }
        new CookieManagerHelper().a(this, this.E);
    }

    private void K0(BridgeWebView bridgeWebView) {
        CredMexJsBridgeHandler credMexJsBridgeHandler = new CredMexJsBridgeHandler();
        this.credMexJsBridgeHandler = credMexJsBridgeHandler;
        if (bridgeWebView == null) {
            return;
        }
        credMexJsBridgeHandler.N(bridgeWebView, this);
        this.credMexJsBridgeHandler.P(bridgeWebView, this, this.W);
        this.credMexJsBridgeHandler.O(bridgeWebView, new WebReadyCallBack() {
            public final void a(String str) {
                WebViewActivity.this.P0(str);
            }
        });
    }

    private void L0() {
        this.W = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new AnonymousClass1());
    }

    private void M0() {
        if (this.T) {
            this.tbToolbar.setVisibility(8);
            setWindowStatusBarColor(this, 2131099974);
            this.tbToolbar.setFitsSystemWindows(false);
            return;
        }
        if (TextUtils.equals("CLICK_BTN_GO_HELP", this.U)) {
            ((BaseActivity) this).a.setVisibility(0);
            ((BaseActivity) this).a.setImageResource(2131231041);
            ((BaseActivity) this).a.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    WebViewActivity.this.Q0(view);
                }
            });
        }
        if (1 == this.V) {
            this.tbToolbar.setNavigationIcon(2131230998);
        }
    }

    private boolean N0() {
        if (TextUtils.isEmpty(this.R)) {
            return false;
        }
        return this.R.equals("goMessageCenter");
    }

    private boolean O0() {
        BridgeWebView bridgeWebView = this.X;
        return (bridgeWebView == null || bridgeWebView.getUrl() == null || !this.X.canGoBack()) ? false : true;
    }

    public void P0(String str) {
        getFbPlugin().a(this.E, str);
    }

    @SensorsDataInstrumented
    public void Q0(View view) {
        B();
        SensorsDataAutoTrackHelper.trackViewOnClick(view);
        AutoTrackHelper.trackViewOnClick(view);
    }

    public void R0(CallBackFunction callBackFunction, Credential credential) {
        callBackFunction.onCallBack(((BaseActivity) this).gson.t(credential));
    }

    private void S0() {
        final CallBackFunction remove;
        CredMexJsBridgeHandler credMexJsBridgeHandler = this.credMexJsBridgeHandler;
        if (credMexJsBridgeHandler == null || (remove = credMexJsBridgeHandler.t().remove("selectCredential")) == null) {
            return;
        }
        new RepayBankDialogHelper().tryToShowSelectBankcardDialog(this, null, true, new RepayBankDialogHelper.CallBack() {
            @Override
            public final void onResult(Object obj) {
                WebViewActivity.this.R0(remove, (Credential) obj);
            }
        });
    }

    public void T0(ActivityResult activityResult) {
        CallBackFunction remove;
        CredMexJsBridgeHandler credMexJsBridgeHandler = this.credMexJsBridgeHandler;
        if (credMexJsBridgeHandler == null || (remove = credMexJsBridgeHandler.t().remove("withdrawalCheck")) == null || 2001 != activityResult.getResultCode()) {
            return;
        }
        HashMap hashMap = new HashMap();
        hashMap.put("code", 0);
        remove.onCallBack(((BaseActivity) this).gson.t(hashMap));
    }

    private void U0(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        Uri parse = Uri.parse(str);
        if (parse.getBooleanQueryParameter(IS_IMMERSIVE_MODE_BY_H5, false)) {
            this.E = parse.buildUpon().appendQueryParameter("isAppBarHid", String.valueOf(1)).build().toString();
        }
    }

    private void V0() {
        if (this.X == null) {
            return;
        }
        x0(this.E);
        showLoadingDialog();
    }

    public static void startECWebViewActivity(Context context, String str, ActivityResultLauncher<Intent> activityResultLauncher) {
        Intent intent = new Intent(context, (Class<?>) WebViewActivity.class);
        intent.putExtra("actionUrl", str);
        startECWebViewActivity(context, intent, activityResultLauncher);
    }

    @Override
    protected void C0(int i2) {
        this.llEmpty.setVisibility(i2);
    }

    @Override
    protected void D() {
        V0();
    }

    @Override
    protected void G(@NonNull Bundle bundle) {
        super.G(bundle);
        this.E = bundle.getString("actionUrl", "");
        this.R = bundle.getString(INTENT_KEY_ACTION_PURPOSE, "");
        this.S = bundle.getBoolean(INTENT_KEY_IS_AUTH, false);
        this.U = bundle.getString(TOOLBAR_RIGHT_BTN_INTENT_GO_HELP, "");
        this.V = bundle.getInt(TOOLBAR_LEFT_BTN_ICON_STYLE, 0);
        this.T = Uri.parse(this.E).getBooleanQueryParameter(IS_IMMERSIVE_MODE_BY_H5, false) || bundle.getBoolean(INTENT_KEY_IS_IMMERSIVE_MODE, false);
        U0(this.E);
        if (getWebView() != null) {
            getWebView().restoreState(bundle);
        }
        Logger.c().b("url: " + this.E);
    }

    @Override
    protected void K() {
        super.K();
        M0();
        K0(getWebView());
        J0();
        if (!N0() || Build.VERSION.SDK_INT < 33) {
            return;
        }
        this.permissionHelper.requestPermission(this, new String[]{"android.permission.POST_NOTIFICATIONS"});
    }

    @Override
    protected void X(@NonNull Bundle bundle) {
        super.X(bundle);
        if (getWebView() != null) {
            getWebView().saveState(bundle);
        }
        bundle.putString("actionUrl", this.E);
        bundle.putString(INTENT_KEY_ACTION_PURPOSE, this.R);
        bundle.putBoolean(INTENT_KEY_IS_AUTH, this.S);
        bundle.putBoolean(INTENT_KEY_IS_IMMERSIVE_MODE, this.T);
        bundle.putString(TOOLBAR_RIGHT_BTN_INTENT_GO_HELP, this.U);
        bundle.putInt(TOOLBAR_LEFT_BTN_ICON_STYLE, this.V);
    }

    public void finish() {
        setResult(2001, getIntent());
        super/*android.app.Activity*/.finish();
    }

    @Override
    public int getLayoutID() {
        return 2131558636;
    }

    @Override
    public BridgeWebView getWebView() {
        return this.X;
    }

    @Override
    protected void init() {
        super.init();
        L0();
        BridgeWebView bridgeWebView = (BridgeWebView) findViewById(2131363324);
        this.X = bridgeWebView;
        if (bridgeWebView == null) {
            C0(0);
        } else {
            C0(8);
        }
    }

    @Override
    protected void onActivityResult(int i2, int i3, Intent intent) {
        super.onActivityResult(i2, i3, intent);
        if (i2 == 1012 && i3 == 2001) {
            S0();
        }
    }

    public void onBackPressed() {
        BridgeWebView bridgeWebView;
        if (this.S) {
            QuitAuthHelper.n(this.authUtil, this.userSession.f().quitAuthDialogInfo, this);
            return;
        }
        CredMexJsBridgeHandler credMexJsBridgeHandler = this.credMexJsBridgeHandler;
        if (credMexJsBridgeHandler != null && credMexJsBridgeHandler.v() && (bridgeWebView = this.X) != null) {
            bridgeWebView.evaluateJavascript("window.YqgWebMessager.send('onGoBack');", null);
            return;
        }
        CredMexJsBridgeHandler credMexJsBridgeHandler2 = this.credMexJsBridgeHandler;
        if (credMexJsBridgeHandler2 != null && "JUMP_TO_HOME".equals(credMexJsBridgeHandler2.u())) {
            jumpToHomePage();
        } else if (O0()) {
            this.X.goBack();
        } else {
            super/*androidx.activity.ComponentActivity*/.onBackPressed();
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onBluePayResult(BluePayEvent bluePayEvent) {
        CallBackFunction remove;
        CredMexJsBridgeHandler credMexJsBridgeHandler = this.credMexJsBridgeHandler;
        if (credMexJsBridgeHandler == null || (remove = credMexJsBridgeHandler.t().remove("openBindCardPage")) == null) {
            return;
        }
        remove.onCallBack("");
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventLoginOrRegister(EventFinishLoginOrRegister eventFinishLoginOrRegister) {
        if (eventFinishLoginOrRegister.loginEnd) {
            J0();
        }
    }

    @OnClick({2131361967})
    public void onViewClicked(View view) {
        if (view.getId() != 2131361967) {
            return;
        }
        BridgeWebView bridgeWebView = this.X;
        if (bridgeWebView != null) {
            bridgeWebView.reload();
            C0(8);
            showLoadingDialog();
            this.D = false;
            return;
        }
        this.retryableWebViewContainer.b();
        BridgeWebView bridgeWebView2 = (BridgeWebView) findViewById(2131363324);
        this.X = bridgeWebView2;
        if (bridgeWebView2 != null) {
            C0(8);
            K();
            V0();
        }
    }

    @Override
    protected String r0() {
        return HeaderInfoHelper.f(this);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnCreated(@NonNull Runnable runnable) {
        return com.veda.supertoolkit.lifecycle.i.a(this, runnable);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnDestroy(@NonNull Runnable runnable) {
        return com.veda.supertoolkit.lifecycle.i.b(this, runnable);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnEvent(@NonNull LifecycleEvent lifecycleEvent, @Nullable Runnable runnable) {
        return com.veda.supertoolkit.lifecycle.i.c(this, lifecycleEvent, runnable);
    }

    @Override
    protected void y0(int i2, String str) {
        boolean z;
        try {
            z = ServerApiConfig.e().a().getHost().equalsIgnoreCase(new URL(str).getHost());
        } catch (MalformedURLException e) {
            e.printStackTrace();
            z = true;
        }
        if (z) {
            super.y0(i2, str);
        } else {
            dismissLoadingDialog();
        }
        setTitle("");
    }

    public static void startECWebViewActivity(Context context, String str) {
        startECWebViewActivity(context, str, "noPurpose", false, 0, "RIGHT_BTN_NO_INTENT");
    }

    public static void startECWebViewActivity(Context context, String str, boolean z) {
        startECWebViewActivity(context, str, "noPurpose", z, 0, "RIGHT_BTN_NO_INTENT");
    }

    public static void startECWebViewActivity(Context context, String str, String str2) {
        startECWebViewActivity(context, str, str2, false, 0, "RIGHT_BTN_NO_INTENT");
    }

    public static void startECWebViewActivity(Context context, String str, int i2, String str2) {
        startECWebViewActivity(context, str, "noPurpose", false, i2, str2);
    }

    public static void startECWebViewActivity(Context context, String str, String str2, boolean z, int i2, String str3) {
        Intent intent = new Intent(context, (Class<?>) WebViewActivity.class);
        intent.putExtra("actionUrl", str);
        intent.putExtra(INTENT_KEY_ACTION_PURPOSE, str2);
        intent.putExtra(INTENT_KEY_IS_AUTH, z);
        intent.putExtra(TOOLBAR_RIGHT_BTN_INTENT_GO_HELP, str3);
        intent.putExtra(TOOLBAR_LEFT_BTN_ICON_STYLE, i2);
        startECWebViewActivity(context, intent, (ActivityResultLauncher<Intent>) null);
    }

    public static void startECWebViewActivity(Context context, Intent intent, ActivityResultLauncher<Intent> activityResultLauncher) {
        String stringExtra = intent.getStringExtra("actionUrl");
        if (ActionUrlHelper.c(stringExtra)) {
            AppUtil.d(context, ActionUrlHelper.g(stringExtra));
        } else if (activityResultLauncher != null) {
            activityResultLauncher.launch(intent);
        } else {
            context.startActivity(intent);
        }
    }
}