导航菜单

页面标题

页面副标题

TruCred v1.1.3 - MemberFragment.java 源代码

正在查看: TruCred v1.1.3 应用的 MemberFragment.java JAVA 源代码文件

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


package com.veloz.app.ui.home.fragment;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.location.Address;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.lifecycle.Observer;
import com.adjust.sdk.webbridge.AdjustBridge;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.BarUtils;
import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.DeviceUtils;
import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.PhoneUtils;
import com.blankj.utilcode.util.SDCardUtils;
import com.blankj.utilcode.util.StringUtils;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.jeremyliao.liveeventbus.LiveEventBus;
import com.lzy.okgo.model.Progress;
import com.veloz.app.R$layout;
import com.veloz.app.VelozApplication;
import com.veloz.app.cache.LocationCache;
import com.veloz.app.cache.LoginInfoCache;
import com.veloz.app.constant.Constant;
import com.veloz.app.databinding.MemberFragmentLayoutBinding;
import com.veloz.app.entity.CreateWebViewParamsEntity;
import com.veloz.app.entity.LocationEntity;
import com.veloz.app.entity.LoginBean;
import com.veloz.app.my.MyFragment;
import com.veloz.app.ui.home.fragment.MemberFragment;
import com.veloz.app.ui.login.LoginActivity;
import com.veloz.app.ui.web.CommonWebViewActivity;
import com.veloz.app.ui.web.CustomWebChromeClient;
import com.veloz.app.utils.Constants;
import com.veloz.app.utils.CpuInfoUtil;
import com.veloz.app.utils.GeoCoderHelper;
import com.veloz.app.utils.MyDeviceInfoUtils;
import com.veloz.app.utils.StaticC;
import com.veloz.app.utils.WebviewUtils;
import com.veloz.app.utils.WifiInfoUtil;
import com.veloz.app.utils.XToastUtils;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.functions.Consumer;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import k0.f;

public class MemberFragment extends MyFragment<MemberFragmentLayoutBinding, MemberViewModel> {
    private static MemberFragment fragment;
    private final Handler handler = new Handler(Looper.getMainLooper());
    private boolean isReLoad = false;
    private boolean isRefreshWebOnResume;
    private WifiInfoUtil wifiInfoUtil;

    private Single<String> getDeviceInfo() {
        return Single.fromCallable(new Callable() {
            @Override
            public final Object call() {
                String lambda$getDeviceInfo$3;
                lambda$getDeviceInfo$3 = MemberFragment.this.lambda$getDeviceInfo$3();
                return lambda$getDeviceInfo$3;
            }
        });
    }

    public static MemberFragment getInstance() {
        if (fragment == null) {
            fragment = new MemberFragment();
        }
        return fragment;
    }

    private Single<String> getLongitudeLatitude() {
        return Single.fromCallable(new Callable() {
            @Override
            public final Object call() {
                String lambda$getLongitudeLatitude$4;
                lambda$getLongitudeLatitude$4 = MemberFragment.this.lambda$getLongitudeLatitude$4();
                return lambda$getLongitudeLatitude$4;
            }
        });
    }

    private String getResultJson(int i, Map<String, Object> map) {
        HashMap hashMap = new HashMap();
        hashMap.put(Progress.STATUS, Integer.valueOf(i));
        hashMap.put("data", map);
        return GsonUtils.toJson(hashMap);
    }

    public void handleJsInterface(String str) {
        if (StringUtils.isTrimEmpty(LoginInfoCache.e())) {
            return;
        }
        LogUtils.e(new Object[]{"url=" + str});
        String[] split = str.split("callback=");
        final String str2 = split[1].split("&params=")[0];
        String str3 = split[1].split("&params=")[1];
        LogUtils.e(new Object[]{"callbackMethod=" + str2});
        LogUtils.e(new Object[]{"callbackParams=" + str3});
        if (str.contains("closeWebView")) {
            String resultJson = getResultJson(1, null);
            ((MemberFragmentLayoutBinding) this.bind).a.loadUrl("javascript:" + str2 + "('" + resultJson + "')");
            getActivity().finish();
            return;
        }
        if (str.contains("getDeviceInfo")) {
            getDeviceInfo().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer() {
                @Override
                public final void accept(Object obj) {
                    MemberFragment.this.lambda$handleJsInterface$1(str2, (String) obj);
                }
            }, new f());
            return;
        }
        if (str.contains("goLogin")) {
            getActivity().startActivity(LoginActivity.class).go();
            return;
        }
        if (str.contains("createWebView")) {
            CreateWebViewParamsEntity createWebViewParamsEntity = (CreateWebViewParamsEntity) GsonUtils.fromJson(str3, CreateWebViewParamsEntity.class);
            if (createWebViewParamsEntity == null) {
                XToastUtils.a("createWebView params is null");
                return;
            } else {
                this.isRefreshWebOnResume = createWebViewParamsEntity.isRefreshOnResume();
                getActivity().startActivity(CommonWebViewActivity.class).with(Progress.URL, createWebViewParamsEntity.getUrl()).with("needToken", Boolean.valueOf(createWebViewParamsEntity.isNeedToken())).with("callbackName", createWebViewParamsEntity.getCallbackName()).go();
                return;
            }
        }
        if (str.contains("getLongitudeLatitude")) {
            getLongitudeLatitude().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer() {
                @Override
                public final void accept(Object obj) {
                    MemberFragment.this.lambda$handleJsInterface$2(str2, (String) obj);
                }
            }, new f());
            return;
        }
        if (str.contains("setAppHeadBar")) {
            String resultJson2 = getResultJson(1, null);
            ((MemberFragmentLayoutBinding) this.bind).a.loadUrl("javascript:" + str2 + "('" + resultJson2 + "')");
            ((MemberFragmentLayoutBinding) this.bind).a.setVisibility(0);
            dismissLoading();
            return;
        }
        if (str.contains("getStatusBarHeight")) {
            int px2dp = ConvertUtils.px2dp(BarUtils.getStatusBarHeight());
            HashMap hashMap = new HashMap();
            hashMap.put("statusBarHeight", Integer.valueOf(px2dp));
            String resultJson3 = getResultJson(1, hashMap);
            ((MemberFragmentLayoutBinding) this.bind).a.loadUrl("javascript:" + str2 + "('" + resultJson3 + "')");
            return;
        }
        if (!str.contains("toGooglePlay")) {
            if (str.contains("openMineEditor")) {
                LiveEventBus.get("openMineEditor").post(null);
                return;
            }
            return;
        }
        openGooglePlay(str3);
        String resultJson4 = getResultJson(1, null);
        ((MemberFragmentLayoutBinding) this.bind).a.loadUrl("javascript:" + str2 + "('" + resultJson4 + "')");
    }

    private void initEvent() {
        LiveEventBus.get(FirebaseAnalytics.Event.LOGIN, LoginBean.class).observe(this, new Observer() {
            public final void onChanged(Object obj) {
                MemberFragment.this.lambda$initEvent$0((LoginBean) obj);
            }
        });
    }

    private void initSetting() {
        WebSettings settings = ((MemberFragmentLayoutBinding) this.bind).a.getSettings();
        settings.setDefaultTextEncodingName("UTF-8");
        settings.setUserAgentString(settings.getUserAgentString() + " /" + Constants.a + "/" + AppUtils.getAppVersionName());
        settings.setJavaScriptEnabled(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setCacheMode(2);
        settings.setDomStorageEnabled(true);
        settings.setDatabaseEnabled(true);
        settings.setAllowFileAccess(true);
        settings.setAllowContentAccess(true);
        settings.setAllowFileAccessFromFileURLs(false);
        settings.setAllowUniversalAccessFromFileURLs(false);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        settings.setSupportZoom(true);
        settings.setBuiltInZoomControls(true);
        settings.setDisplayZoomControls(false);
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
    }

    private void initWebView() {
        ((MemberFragmentLayoutBinding) this.bind).a.setWebChromeClient(new CustomWebChromeClient(getActivity()));
        ((MemberFragmentLayoutBinding) this.bind).a.setWebViewClient(new MyWebViewClient());
        AdjustBridge.registerAndGetInstance(VelozApplication.getInstance(), ((MemberFragmentLayoutBinding) this.bind).a);
        ((MemberFragmentLayoutBinding) this.bind).a((MemberViewModel) this.vm);
    }

    public String lambda$getDeviceInfo$3() {
        try {
            LocationEntity a = LocationCache.a();
            HashMap hashMap = new HashMap();
            hashMap.put("TO-GO-LANG", Constants.f912m);
            hashMap.put("TO-GO-LNG-LAT", a.getLongitude() + "," + a.getLatitude());
            hashMap.put("TO-GO-TIMEZONE", Constants.f913n);
            hashMap.put("TO-GO-ACCESS-TOKEN", LoginInfoCache.e());
            hashMap.put("TO-GO-VER", AppUtils.getAppVersionName() + "/" + AppUtils.getAppVersionCode());
            hashMap.put("deviceld", DeviceUtils.getUniqueDeviceId());
            hashMap.put("gaid", VelozApplication.getInstance().getGaid());
            if (LoginInfoCache.c() != null) {
                hashMap.put("appUserNo", LoginInfoCache.c().appUserNo);
            }
            if (LoginInfoCache.d() != null) {
                hashMap.put("customerNo", LoginInfoCache.d().customerNo);
                hashMap.put("dcCustomerNo", LoginInfoCache.d().dcCustomerNo);
                hashMap.put("productMode", Integer.valueOf(LoginInfoCache.d().productMode));
            }
            hashMap.put("accessIp", NetworkUtils.getIPAddress(true));
            hashMap.put("appCode", Constants.a);
            hashMap.put("appName", AppUtils.getAppName());
            hashMap.put("appVersion", AppUtils.getAppVersionName());
            hashMap.put("versionCode", Integer.valueOf(AppUtils.getAppVersionCode()));
            hashMap.put("appMac", MyDeviceInfoUtils.b());
            hashMap.put("authentication", LoginInfoCache.e());
            hashMap.put("channelPackageSource", "release");
            String str = Build.BRAND;
            hashMap.put("deviceBrand", str);
            hashMap.put("deviceCpuArchitecture", CpuInfoUtil.a());
            hashMap.put("deviceModel", DeviceUtils.getModel());
            hashMap.put("deviceNo", DeviceUtils.getUniqueDeviceId());
            hashMap.put("deviceOs", "android");
            hashMap.put("deviceOsImage", StaticC.c + "*" + StaticC.d);
            hashMap.put("deviceProvidersName", PhoneUtils.getSimOperatorName());
            hashMap.put("deviceStorageSpace", Long.valueOf(SDCardUtils.getExternalTotalSize()));
            hashMap.put("deviceSystemLanguage", "es");
            hashMap.put("deviceWifiSsid", this.wifiInfoUtil.a());
            hashMap.put("mobileOsVersion", DeviceUtils.getSDKVersionName());
            hashMap.put("mobilePhoneBrand", str);
            hashMap.put("loginPlatform", "Android");
            hashMap.put("adid", Constant.c);
            if (getActivity() != null) {
                Address b = GeoCoderHelper.b();
                if (b != null) {
                    hashMap.put("gpsAddressCity", b.getLocality());
                    hashMap.put("gpsAddressProvince", b.getAdminArea());
                    hashMap.put("gpsAddressStreet", b.getSubAdminArea());
                    hashMap.put("gpsLatitude", Double.valueOf(a.getLatitude()));
                    hashMap.put("lbsAddressCity", b.getLocality());
                    hashMap.put("lbsAddressProvince", b.getAdminArea());
                    hashMap.put("lbsAddressStreet", b.getSubAdminArea());
                    hashMap.put("lbsLatitude", Double.valueOf(a.getLatitude()));
                    hashMap.put("lbsLongitude", Double.valueOf(a.getLongitude()));
                } else {
                    hashMap.put("gpsAddressCity", "");
                    hashMap.put("gpsAddressProvince", "");
                    hashMap.put("gpsAddressStreet", "");
                    hashMap.put("gpsLatitude", "");
                    hashMap.put("lbsAddressCity", "");
                    hashMap.put("lbsAddressProvince", "");
                    hashMap.put("lbsAddressStreet", "");
                    hashMap.put("lbsLatitude", "");
                    hashMap.put("lbsLongitude", "");
                }
            }
            return getResultJson(1, hashMap);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public String lambda$getLongitudeLatitude$4() {
        String str = ",";
        try {
            LocationEntity a = LocationCache.a();
            Map<String, Object> hashMap = new HashMap<>();
            if (getActivity() != null) {
                Address b = GeoCoderHelper.b();
                hashMap.put("longitude", Double.valueOf(a.getLongitude()));
                hashMap.put("latitude", Double.valueOf(a.getLatitude()));
                hashMap.put("create_time", Long.valueOf(System.currentTimeMillis()));
                try {
                    if (b != null) {
                        try {
                            hashMap.put("gps_address_country", b.getCountryName());
                            hashMap.put("gps_address_country_code", b.getCountryCode());
                            hashMap.put("gps_address_province", b.getAdminArea());
                            hashMap.put("gps_address_city", b.getLocality());
                            hashMap.put("gps_address_street", b.getThoroughfare());
                            hashMap.put("gps_address_sub_locality", b.getSubLocality());
                            hashMap.put("gps_address_sub_admin_area", b.getSubAdminArea());
                            hashMap.put("lbs_address_province", b.getAdminArea());
                            hashMap.put("lbs_address_city", b.getLocality());
                            hashMap.put("lbs_address_street", b.getThoroughfare());
                            hashMap.put("lbs_address_country_code", b.getCountryCode());
                            hashMap.put("lbs_address_country", b.getCountryName());
                            StringBuilder sb = new StringBuilder();
                            for (int i = 0; i < b.getMaxAddressLineIndex(); i++) {
                                try {
                                    sb.append(b.getAddressLine(i));
                                    sb.append("\n");
                                } catch (Exception e) {
                                    e = e;
                                    str = "";
                                    e.printStackTrace();
                                    return str;
                                }
                            }
                            sb.append(b.getFeatureName());
                            sb.append(",");
                            sb.append(b.getThoroughfare());
                            sb.append(",");
                            sb.append(b.getSubLocality());
                            sb.append(",");
                            sb.append(b.getSubAdminArea());
                            sb.append(",");
                            sb.append(b.getLocality());
                            sb.append(",");
                            sb.append(b.getPostalCode());
                            sb.append(" ");
                            sb.append(b.getAdminArea());
                            sb.append(",");
                            sb.append(b.getCountryCode());
                            sb.append(" ");
                            sb.append(b.getCountryName());
                            str = "";
                            sb.append(str);
                            hashMap.put("provider", sb.toString());
                        } catch (Exception e2) {
                            e = e2;
                            str = "";
                            e.printStackTrace();
                            return str;
                        }
                    } else {
                        str = "";
                        hashMap.put("gps_address_country", str);
                        hashMap.put("gps_address_country_code", str);
                        hashMap.put("gps_address_province", str);
                        hashMap.put("gps_address_city", str);
                        hashMap.put("gps_address_street", str);
                        hashMap.put("gps_address_sub_locality", str);
                        hashMap.put("gps_address_sub_admin_area", str);
                        hashMap.put("lbs_address_province", str);
                        hashMap.put("lbs_address_city", str);
                        hashMap.put("lbs_address_street", str);
                        hashMap.put("lbs_address_country_code", str);
                        hashMap.put("lbs_address_country", str);
                        hashMap.put("provider", str);
                    }
                } catch (Exception e3) {
                    e = e3;
                }
            } else {
                str = "";
            }
            try {
                return getResultJson(1, hashMap);
            } catch (Exception e4) {
                e = e4;
                e.printStackTrace();
                return str;
            }
        } catch (Exception e5) {
            e = e5;
            str = "";
        }
    }

    public void lambda$handleJsInterface$1(String str, String str2) {
        ((MemberFragmentLayoutBinding) this.bind).a.evaluateJavascript("javascript:" + str + "('" + str2 + "')", null);
    }

    public void lambda$handleJsInterface$2(String str, String str2) {
        ((MemberFragmentLayoutBinding) this.bind).a.evaluateJavascript("javascript:" + str + "('" + str2 + "')", null);
    }

    public void lambda$initEvent$0(LoginBean loginBean) {
        this.isReLoad = false;
    }

    private void loadWeb() {
        String str;
        if (StringUtils.isTrimEmpty(LoginInfoCache.e())) {
            str = Constants.e + "person/member/nav";
        } else {
            str = Constants.e + "person/member/nav?token=" + LoginInfoCache.e();
        }
        LogUtils.d(new Object[]{"loadWeb url = " + str});
        WebviewUtils.g(((MemberFragmentLayoutBinding) this.bind).a);
        ((MemberFragmentLayoutBinding) this.bind).a.loadUrl(str);
    }

    private void openGooglePlay(String str) {
        try {
            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
            intent.addFlags(268435456);
            getActivity().startActivity(intent);
        } catch (ActivityNotFoundException unused) {
            getActivity().startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=")));
        }
    }

    private void refreshWeb() {
        loadWeb();
    }

    @Override
    public void lazyLoad() {
        super.lazyLoad();
        refreshWeb();
    }

    @Override
    public int myView() {
        return R$layout.member_fragment_layout;
    }

    @Override
    public void onInvisible() {
        super.onInvisible();
        Binding binding = this.bind;
        if (binding != 0) {
            ((MemberFragmentLayoutBinding) binding).a.loadUrl("about:blank");
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if (!this.isRefreshWebOnResume) {
            refreshWeb();
        } else {
            this.isRefreshWebOnResume = false;
            ((MemberFragmentLayoutBinding) this.bind).a.loadUrl("javascript:location.reload()");
        }
    }

    @Override
    public void myCreate(MemberFragmentLayoutBinding memberFragmentLayoutBinding, MemberViewModel memberViewModel) {
        this.wifiInfoUtil = new WifiInfoUtil(getActivity());
        initSetting();
        initWebView();
        lazyLoad();
        initEvent();
    }

    public class MyWebViewClient extends WebViewClient {
        public MyWebViewClient() {
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            super.onPageFinished(webView, str);
            WebviewUtils.c(webView);
        }

        @Override
        public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
            super.onReceivedError(webView, webResourceRequest, webResourceError);
            WebviewUtils.c(webView);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
            String uri = webResourceRequest.getUrl().toString();
            LogUtils.e(new Object[]{"shouldOverrideUrlLoading url=" + uri});
            try {
                String decode = URLDecoder.decode(uri, "UTF-8");
                LogUtils.e(new Object[]{"shouldOverrideUrlLoading decode url=" + decode});
                if (!decode.contains("callfunction://")) {
                    return super.shouldOverrideUrlLoading(webView, webResourceRequest);
                }
                MemberFragment.this.handleJsInterface(decode);
                return true;
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            try {
                LogUtils.e(new Object[]{"shouldOverrideUrlLoading url=" + str});
                String decode = URLDecoder.decode(str, "UTF-8");
                LogUtils.e(new Object[]{"shouldOverrideUrlLoading decode url=" + decode});
                if (decode.contains("callfunction://")) {
                    MemberFragment.this.handleJsInterface(decode);
                    return true;
                }
                return super.shouldOverrideUrlLoading(webView, decode);
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
        }
    }
}