导航菜单

页面标题

页面副标题

AdaModal v1.4.0 - SplashActivity.java 源代码

正在查看: AdaModal v1.4.0 应用的 SplashActivity.java JAVA 源代码文件

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


package com.common.fine.activity;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.WebView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.alibaba.fastjson.JSON;
import com.blankj.utilcode.util.BarUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.blankj.utilcode.util.Utils;
import com.common.fine.R;
import com.common.fine.constant.RouterHub;
import com.common.fine.constant.SPConstant;
import com.common.fine.instance.LoginInstance;
import com.common.fine.instance.URLInstance;
import com.common.fine.model.NetUrl;
import com.common.fine.utils.ChannelUtils;
import com.common.fine.utils.okhttp.OkHttpUtils;
import com.common.fine.utils.okhttp.callback.StringCallback;
import com.common.fine.utils.okhttp.utils.HttpHelper;
import com.common.fine.utils.preference.ESPUtils;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;

public class SplashActivity extends Activity {
    private static final boolean ENABLE_REMOTE_ADDRESS = true;
    public static boolean SPLASH_SHOWN = false;
    private String mInitUrl;
    private WebView mWebPreloadView;
    private int mCurAddressUrlIndex = 0;
    private Boolean isFromNotification = false;
    private String clickAction = "";

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_splash);
        this.mWebPreloadView = (WebView) findViewById(R.id.web_preload);
        BarUtils.setStatusBarVisibility((Activity) this, false);
        LoginInstance.INSTANCE.tryLoad();
        this.isFromNotification = Boolean.valueOf(getIntent().getBooleanExtra("fromNotification", false));
        this.clickAction = getIntent().getStringExtra("pop_up_type");
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                SplashActivity.this.loadBaseAddressAndStartApp();
            }
        }, 2000L);
        doPreloadWebPage();
    }

    private void doPreloadWebPage() {
        this.mWebPreloadView.loadUrl(this.mInitUrl);
    }

    public void loadBaseAddressAndStartApp() {
        if (ChannelUtils.isTestEnv()) {
            initTestUrl();
            return;
        }
        String[] stringArray = getResources().getStringArray(R.array.PRO_URL_CONFIGS);
        int i = this.mCurAddressUrlIndex;
        if (i < stringArray.length) {
            OkHttpUtils.get().url(stringArray[i]).addParams("_t", String.valueOf(System.currentTimeMillis())).build().execute(new StringCallback() {
                @Override
                public void lambda$sendFailedMessage$0(int i2, String str, int i3) {
                    SplashActivity.this.mCurAddressUrlIndex++;
                    SplashActivity.this.loadBaseAddressAndStartApp();
                }

                @Override
                public void lambda$sendSucceedMessage$1(int i2, String str, int i3) {
                    if (StringUtils.isTrimEmpty(str)) {
                        return;
                    }
                    if (SplashActivity.this.intNetBaseUrl((NetUrl) JSON.parseObject(str, NetUrl.class))) {
                        SplashActivity.this.startMainPage();
                        return;
                    }
                    SplashActivity.this.mCurAddressUrlIndex++;
                    SplashActivity.this.loadBaseAddressAndStartApp();
                }
            });
            return;
        }
        String baseUrl = URLInstance.INSTANCE.getBaseUrl();
        String htmlDomain = URLInstance.INSTANCE.getHtmlDomain();
        if (!StringUtils.isTrimEmpty(htmlDomain)) {
            NetUrl netUrl = new NetUrl();
            netUrl.BASE_URL = baseUrl;
            netUrl.BASE_HTML_URL_PATH = htmlDomain;
            if (intNetBaseUrl(netUrl)) {
                startMainPage();
                return;
            }
            return;
        }
        ToastUtils.showLong("Network Error");
    }

    public boolean intNetBaseUrl(NetUrl netUrl) {
        if (StringUtils.isTrimEmpty(netUrl.BASE_URL) || StringUtils.isTrimEmpty(netUrl.BASE_HTML_URL_PATH)) {
            return false;
        }
        URLInstance.INSTANCE.SET_BASE_URL(netUrl.BASE_URL);
        URLInstance.INSTANCE.SET_BASE_HTML_URL_PATH(netUrl.BASE_HTML_URL_PATH);
        HashMap hashMap = new HashMap();
        hashMap.put("_t", String.valueOf(System.currentTimeMillis() / 1000));
        this.mInitUrl = HttpHelper.getUrlFromMap(URLInstance.INSTANCE.BASE_HTML_URL(), hashMap);
        return ENABLE_REMOTE_ADDRESS;
    }

    private void initTestUrl() {
        if (ChannelUtils.isTestEnv()) {
            URLInstance.INSTANCE.SET_BASE_URL(Utils.getApp().getString(R.string.APP_BASE_URL));
            URLInstance.INSTANCE.SET_BASE_HTML_URL_PATH(Utils.getApp().getString(R.string.APP_BASE_HTML_URL));
            HashMap hashMap = new HashMap();
            hashMap.put("_t", String.valueOf(System.currentTimeMillis() / 1000));
            this.mInitUrl = HttpHelper.getUrlFromMap(URLInstance.INSTANCE.BASE_HTML_URL(), hashMap);
            String string = ESPUtils.getInstance().getString(SPConstant.TEST_ENV_BASE_URL);
            if (!StringUtils.isTrimEmpty(string)) {
                this.mInitUrl = string;
            }
        }
        startMainPage();
    }

    public void startMainPage() {
        if (this.isFromNotification.booleanValue() || !TextUtils.isEmpty(this.clickAction)) {
            getSharedPreferences("notification", 0).edit().putString("pop_up_type", this.clickAction).commit();
        }
        ARouter.getInstance().build(RouterHub.BRIDGE_WEB_ACTIVITY).withString("url", this.mInitUrl).navigation(this);
        SPLASH_SHOWN = ENABLE_REMOTE_ADDRESS;
        finish();
    }
}