工作空间 v3.6.5.2版本的 MD5 值为:58e65af156c65a63bf64ed2e64960853

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


package com.uusafe.login.ui.fragment.login.helper;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentTransaction;
import com.uusafe.base.modulesdk.module.MainProcessModule;
import com.uusafe.base.modulesdk.module.activity.ActivityLifeController;
import com.uusafe.base.modulesdk.module.bean.BaseBundleInfo;
import com.uusafe.base.modulesdk.module.bean.GetLicenseAgreementRspBean;
import com.uusafe.base.modulesdk.module.global.CommGlobal;
import com.uusafe.base.modulesdk.module.listener.GetLicenseAgreementListener;
import com.uusafe.base.modulesdk.module.manager.BaseModuleManager;
import com.uusafe.base.modulesdk.module.netapi.BaseApis;
import com.uusafe.base.modulesdk.module.router.ARouterConfig;
import com.uusafe.commbase.global.BaseGlobal;
import com.uusafe.h5app.library.api.IConstants;
import com.uusafe.h5app.library.browser.fragment.ZlaWebFragment;
import com.uusafe.login.ui.fragment.login.LoginFragment;
import com.uusafe.mbs.mbslogin.R;
import com.uusafe.permission.util.PermissionsUtils;
import com.uusafe.uibase.fragment.BaseFragment;
import com.uusafe.uibase.manager.OpenWinManager;
import com.uusafe.uibase.view.LicenseItemLayout;
import com.uusafe.utils.common.Base64Utils;
import com.uusafe.utils.common.FastDoubleClickUtil;
import com.uusafe.utils.common.FileUtils;
import com.uusafe.utils.common.JsonUtil;
import com.uusafe.utils.common.MyUtils;
import com.uusafe.utils.common.PreferenceUtils;
import com.uusafe.utils.common.UiUtils;
import com.uusafe.utils.common.ZZLog;
import org.json.JSONObject;
public class MbsLoginBottomHelper {
    private static final String TAG = "MbsLoginBottomHelper";
    static MbsLoginBottomHelper mInstance;
    private long latestLicenseTimestamp;
    private LicenseItemLayout licenseItemLayout;
    private View loginBottomLoginTypeView;
    private View loginBottomVersionView;
    private Button loginButton;
    RelativeLayout login_type_layout;
    private TextView mTvLoginForgetPwd;
    private TextView mTvLoginType;
    RelativeLayout scanLayout;
    private TextView scanLogin;
    private TextView tvVersion;
    private Button userNameLogin;

    public static void a(LoginFragment loginFragment, View view) {
        if (!FastDoubleClickUtil.isFastDoubleClick(R.id.uu_mbs_scan_login_layout, 1000L) && PermissionsUtils.requestPermission(loginFragment, 123, PermissionsUtils.CAMERA)) {
            loginFragment.goScan();
        }
    }

    public static synchronized MbsLoginBottomHelper getInstance() {
        MbsLoginBottomHelper mbsLoginBottomHelper;
        synchronized (MbsLoginBottomHelper.class) {
            if (mInstance == null) {
                mInstance = new MbsLoginBottomHelper();
            }
            mbsLoginBottomHelper = mInstance;
        }
        return mbsLoginBottomHelper;
    }

    public void hideLoginType() {
        TextView textView = this.mTvLoginType;
        if (textView != null) {
            textView.setVisibility(4);
        }
    }

    public void initData() {
        this.tvVersion.setText(MyUtils.getAppVersionName("3.6.5.2"));
    }

    public void initView(View view, LayoutInflater layoutInflater, RelativeLayout relativeLayout, BaseFragment baseFragment, int i, boolean z) {
        if (z) {
            this.loginBottomLoginTypeView = layoutInflater.inflate(R.layout.feature_login_select_login_type, (ViewGroup) null);
        } else {
            this.loginBottomLoginTypeView = layoutInflater.inflate(R.layout.feature_login_type, (ViewGroup) null);
        }
        this.loginBottomVersionView = layoutInflater.inflate(R.layout.feature_login_login_bottom_version, (ViewGroup) null);
        this.tvVersion = (TextView) this.loginBottomVersionView.findViewById(R.id.uu_mos_tv_version);
        if (FileUtils.isAssetsFileExist("index.html", baseFragment.getContext())) {
            Bundle bundle = new Bundle();
            JSONObject jSONObject = new JSONObject();
            JsonUtil.putString(jSONObject, "url", "file:///android_asset/index.html");
            JsonUtil.putInt(jSONObject, "hiddentitlebutton", 1);
            JsonUtil.putInt(jSONObject, "hiddenbackbutton", 1);
            JsonUtil.putInt(jSONObject, "hiddenclosebutton", 1);
            JsonUtil.putInt(jSONObject, "hiddenstatusbutton", 1);
            JsonUtil.putBoolean(jSONObject, "hideProgress", true);
            bundle.putString(IConstants.KEY_EXTRA_APP_PARAM, jSONObject.toString());
            ZlaWebFragment newInstance = ZlaWebFragment.newInstance(bundle);
            FrameLayout frameLayout = (FrameLayout) relativeLayout.findViewById(R.id.uu_mos_login_first_layout);
            FragmentTransaction beginTransaction = baseFragment.getActivity().getSupportFragmentManager().beginTransaction();
            beginTransaction.replace(R.id.uu_mos_login_first_layout, newInstance);
            beginTransaction.commit();
        } else {
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
            layoutParams.addRule(12);
            relativeLayout.addView(this.loginBottomVersionView, layoutParams);
        }
        RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -2);
        layoutParams2.addRule(3, i);
        relativeLayout.addView(this.loginBottomLoginTypeView, layoutParams2);
        this.scanLayout = (RelativeLayout) this.loginBottomLoginTypeView.findViewById(R.id.uu_mbs_scan_login_layout);
        this.loginButton = (Button) this.loginBottomLoginTypeView.findViewById(R.id.uu_mos_id_bt_login);
        this.userNameLogin = (Button) this.loginBottomLoginTypeView.findViewById(R.id.uu_mbs_username_login);
        this.scanLogin = (TextView) this.loginBottomLoginTypeView.findViewById(R.id.uu_mbs_scan_login);
        this.mTvLoginType = (TextView) this.loginBottomLoginTypeView.findViewById(R.id.uu_mos_tv_login_type);
        this.mTvLoginForgetPwd = (TextView) this.loginBottomLoginTypeView.findViewById(R.id.uu_mos_tv_login_forget_pwd);
        this.login_type_layout = (RelativeLayout) this.loginBottomLoginTypeView.findViewById(R.id.uu_mos_tv_login_type_layout);
        if (CommGlobal.hideScanLogin) {
            this.scanLayout.setVisibility(8);
        } else {
            this.scanLayout.setVisibility(0);
        }
        this.licenseItemLayout = (LicenseItemLayout) this.loginBottomLoginTypeView.findViewById(R.id.uu_mbs_license_item_layout);
        if (CommGlobal.userLicenseType == CommGlobal.UserLicenseType.TYPE_LOGIN) {
            this.licenseItemLayout.setVisibility(0);
        } else {
            this.licenseItemLayout.setVisibility(8);
        }
        this.licenseItemLayout.setLicenseLinkText(CommGlobal.userAgreementPopupTitle);
        this.licenseItemLayout.setLicenseLinkClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view2) {
                BaseBundleInfo baseBundleInfo = new BaseBundleInfo();
                JSONObject jSONObject2 = new JSONObject();
                if ("licenseagreement_static".equals(CommGlobal.userAgreementType)) {
                    JsonUtil.putString(jSONObject2, "url", "file:///android_asset/license");
                } else {
                    JsonUtil.putString(jSONObject2, "url", BaseApis.getBaseUrl() + BaseApis.BASE_GETLICENSEAGREEMENTCONTENTDETAIL + "?orgCode=" + PreferenceUtils.getCompanyCode(view2.getContext(), CommGlobal.getMosKey()) + "&addr=" + Base64Utils.encode(BaseApis.getBaseUrl().getBytes()));
                }
                baseBundleInfo.param = jSONObject2.toString();
                OpenWinManager.startActivityRouterPath(view2.getContext(), ARouterConfig.RouterPath.UUSAFE_BIZ_H5_WEB_ACTIVITY, baseBundleInfo, ARouterConfig.OpenTarget._BLANK, -1);
            }
        });
    }

    public void requestDynamicUserAgreement() {
        ZZLog.f(TAG, "requestDynamicUserAgreement", new Object[0]);
        final Activity currentActivity = ActivityLifeController.currentActivity();
        long lastLicenseTimestamp = PreferenceUtils.getLastLicenseTimestamp(currentActivity);
        if (lastLicenseTimestamp <= 0) {
            lastLicenseTimestamp = System.currentTimeMillis();
        }
        if (BaseModuleManager.getInstance().getMainProcessModule() != null) {
            MainProcessModule mainProcessModule = BaseModuleManager.getInstance().getMainProcessModule();
            mainProcessModule.getLicenseAgreement(lastLicenseTimestamp + "", true, new GetLicenseAgreementListener() {
                @Override
                public Context getCurrentContext() {
                    return currentActivity;
                }

                @Override
                public void onGetLicenseAgreementError(String str) {
                    final String str2;
                    ZZLog.f(MbsLoginBottomHelper.TAG, "onGetLicenseAgreementError: " + str, new Object[0]);
                    final Activity currentActivity2 = ActivityLifeController.currentActivity();
                    String baseUrl = BaseApis.getBaseUrl();
                    if (currentActivity2 != null) {
                        if (TextUtils.isEmpty(baseUrl)) {
                            str2 = "没有预制URL,动态用户许可协议失败";
                        } else if (!TextUtils.isEmpty(PreferenceUtils.getCompanyCode(currentActivity2, BaseGlobal.getMosKey()))) {
                            ZZLog.f(MbsLoginBottomHelper.TAG, "getLicenseAgreement fails, but go to next window", new Object[0]);
                            return;
                        } else {
                            str2 = "没有预制机构码,动态用户许可协议失败";
                        }
                        currentActivity2.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                UiUtils.showToast(currentActivity2, str2);
                            }
                        });
                    }
                }

                @Override
                public void onGetLicenseAgreementSuccess(GetLicenseAgreementRspBean getLicenseAgreementRspBean) {
                    ZZLog.f(MbsLoginBottomHelper.TAG, "onGetLicenseAgreementSuccess", new Object[0]);
                    if (getLicenseAgreementRspBean != null) {
                        ZZLog.f(MbsLoginBottomHelper.TAG, "onGetLicenseAgreementSuccess getLicenseAgreement not null", new Object[0]);
                        try {
                            MbsLoginBottomHelper.this.latestLicenseTimestamp = Long.parseLong(getLicenseAgreementRspBean.getTimestamp());
                            ZZLog.f(MbsLoginBottomHelper.TAG, "onGetLicenseAgreementSuccess latestLicenseTimestamp=" + MbsLoginBottomHelper.this.latestLicenseTimestamp, new Object[0]);
                        } catch (Exception e2) {
                            ZZLog.f(MbsLoginBottomHelper.TAG, e2.getMessage(), new Object[0]);
                        }
                        if (MbsLoginBottomHelper.this.latestLicenseTimestamp > PreferenceUtils.getLastLicenseTimestamp(currentActivity)) {
                            ZZLog.f(MbsLoginBottomHelper.TAG, "onGetLicenseAgreementSuccess latestLicenseTimestamp larger than pastTimestamp", new Object[0]);
                            CommGlobal.userAgreementPopupTitle = getLicenseAgreementRspBean.getAbstractTitle();
                            currentActivity.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    MbsLoginBottomHelper.this.licenseItemLayout.setLicenseLinkText(CommGlobal.userAgreementPopupTitle);
                                }
                            });
                            return;
                        }
                        return;
                    }
                    ZZLog.f(MbsLoginBottomHelper.TAG, "onGetLicenseAgreementSuccess getLicenseAgreement is null", new Object[0]);
                }
            });
        }
    }

    public void requestFocus() {
        Button button = this.loginButton;
        if (button != null) {
            button.requestFocus();
        }
    }

    public void reset() {
        this.licenseItemLayout.setChecked(false);
    }

    public void restoreView(String str) {
    }

    public void setListener(final LoginFragment loginFragment) {
        Button button = this.loginButton;
        if (button != null) {
            button.setOnClickListener(loginFragment);
        }
        TextView textView = this.mTvLoginForgetPwd;
        if (textView != null) {
            textView.setOnClickListener(loginFragment);
        }
        TextView textView2 = this.mTvLoginType;
        if (textView2 != null) {
            textView2.setOnClickListener(loginFragment);
        }
        Button button2 = this.userNameLogin;
        if (button2 != null) {
            button2.setOnClickListener(loginFragment);
        }
        this.scanLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                MbsLoginBottomHelper.a(LoginFragment.this, view);
            }
        });
    }

    public void setLoginButtonEnable(LoginFragment loginFragment) {
        boolean isChecked = CommGlobal.userLicenseType == CommGlobal.UserLicenseType.TYPE_LOGIN ? this.licenseItemLayout.isChecked() : true;
        if (loginFragment.checkInput() && isChecked) {
            this.loginButton.setBackgroundResource(R.drawable.uu_base_login_btn_bg_selector);
            this.loginButton.setEnabled(true);
            this.loginButton.setTextColor(ContextCompat.getColor(loginFragment.mActivity, R.color.uu_ic_login_btn_normal_text_color));
            return;
        }
        this.loginButton.setBackgroundResource(R.drawable.uu_base_login_btn_disabled_bg_shape);
        this.loginButton.setEnabled(false);
        this.loginButton.setTextColor(ContextCompat.getColor(loginFragment.mActivity, R.color.uu_ic_login_btn_disable_text_color));
    }

    public void setLoginType(int i, BaseFragment baseFragment) {
        RelativeLayout relativeLayout;
        if (i == 0) {
            this.mTvLoginType.setText(R.string.uu_login_login_by_phone);
        } else if (i == 1) {
            this.mTvLoginType.setText(R.string.uu_login_login_by_username);
        }
        if (i == 2 || CommGlobal.hideSmsLogin || CommGlobal.hideAccountLogin) {
            this.mTvLoginType.setVisibility(4);
        }
        if (CommGlobal.passwordOption == CommGlobal.PasswordOption.MODEL_DISABLE) {
            this.mTvLoginForgetPwd.setVisibility(4);
        }
        if (CommGlobal.hideSmsLogin && CommGlobal.passwordOption == CommGlobal.PasswordOption.MODEL_DISABLE && (relativeLayout = this.login_type_layout) != null) {
            relativeLayout.setVisibility(8);
        }
    }

    public void setOnCheckedChangeListener(LicenseItemLayout.OnCheckedChangeListener onCheckedChangeListener) {
        this.licenseItemLayout.setOnCheckedChangeListener(onCheckedChangeListener);
    }
}