盛康基办.apk(点击下载) / HttpUtils.java


package com.bjz.comm.net.utils;

import android.text.TextUtils;
import android.webkit.URLUtil;
import com.bjz.comm.net.BuildVars;
import com.bjz.comm.net.UrlConstant;

public class HttpUtils {
    private static String remoteGameUrl = "";
    private static String remoteMPUrl = "";
    private static String remoteUrl = "";
    private static String requestToken = "";

    public String getDownloadFileUrl() {
        return "https://impyq.gz.bcebos.com/";
    }

    public String getDownloadVideoFileUrl() {
        return "https://impyq.gz.bcebos.com/";
    }

    public static HttpUtils getInstance() {
        return Holder.INSTANCE;
    }

    private static class Holder {
        private static final HttpUtils INSTANCE = new HttpUtils();

        private Holder() {
        }
    }

    public String getUserAgentMP() {
        return !BuildVars.DEBUG_VERSION ? UrlConstant.USER_AGENT_MINI_PROGRAM : UrlConstant.USER_AGENT_GRAY_TEST;
    }

    public String getUserAgentFC() {
        return !BuildVars.DEBUG_VERSION ? UrlConstant.USER_AGENT_FC : UrlConstant.USER_AGENT_GRAY_TEST;
    }

    public String getUserAgentGame() {
        return !BuildVars.DEBUG_VERSION ? UrlConstant.USER_AGENT_GAME : UrlConstant.USER_AGENT_GRAY_TEST;
    }

    public String getAuthorization() {
        if (TextUtils.isEmpty(requestToken)) {
            requestToken = AppPreferenceUtil.getString("authorization", "");
        }
        return requestToken;
    }

    public void setAuthorization(String str) {
        AppPreferenceUtil.putString("authorization", str);
        requestToken = str;
    }

    public void clearCache() {
        setAuthorization("");
    }

    public String getFcBaseUrl() {
        return BuildVars.DEBUG_VERSION ? UrlConstant.BASE_FC_LOCAL_TEST_URL : getFcRemoteUrl();
    }

    public String getFcBaseVideoUrl() {
        return BuildVars.DEBUG_VERSION ? UrlConstant.BASE_FC_LOCAL_TEST_URL : "https://impyq.gz.bcebos.com/";
    }

    public String getBaseFileUrl() {
        return getFcBaseUrl() + UrlConstant.PICTURE_FILE_URI_PATH;
    }

    private String getFcRemoteUrl() {
        if (TextUtils.isEmpty(remoteUrl)) {
            String string = AppPreferenceUtil.getString("LocalFcUrl", "");
            if (!TextUtils.isEmpty(string) && !URLUtil.isNetworkUrl(string)) {
                string = "https://" + string;
                setFcRemoteUrl(string);
            }
            if (!TextUtils.isEmpty(string)) {
                remoteUrl = string;
            } else {
                remoteUrl = UrlConstant.BASE_FC_URL;
            }
        }
        return remoteUrl;
    }

    public void setFcRemoteUrl(String str) {
        AppPreferenceUtil.putString("LocalFcUrl", str);
        remoteUrl = str;
    }

    public String getMPBaseUrl() {
        return BuildVars.DEBUG_VERSION ? UrlConstant.BASE_MINI_PROGRAM_TEST_URL : getMPRemoteUrl();
    }

    private String getMPRemoteUrl() {
        if (TextUtils.isEmpty(remoteMPUrl)) {
            String string = AppPreferenceUtil.getString("LocalMPUrl", "");
            if (!TextUtils.isEmpty(string) && !URLUtil.isNetworkUrl(string)) {
                string = "https://" + string;
                setFcRemoteUrl(string);
            }
            if (!TextUtils.isEmpty(string)) {
                remoteMPUrl = string;
            } else {
                remoteMPUrl = UrlConstant.BASE_MINI_PROGRAM_URL;
            }
        }
        return remoteMPUrl;
    }

    public void setMPRemoteUrl(String str) {
        AppPreferenceUtil.putString("LocalMPUrl", str);
        remoteMPUrl = str;
    }

    public String getGameBaseUrl() {
        return BuildVars.DEBUG_VERSION ? UrlConstant.BASE_MINI_GAME_TEST_URL : getGameRemoteUrl();
    }

    private String getGameRemoteUrl() {
        if (TextUtils.isEmpty(remoteGameUrl)) {
            String string = AppPreferenceUtil.getString("LocalGameUrl", "");
            if (!TextUtils.isEmpty(string) && !URLUtil.isNetworkUrl(string)) {
                string = "https://" + string;
                setFcRemoteUrl(string);
            }
            if (!TextUtils.isEmpty(string)) {
                remoteGameUrl = string;
            } else {
                remoteGameUrl = UrlConstant.BASE_MINI_GAME_URL;
            }
        }
        return remoteGameUrl;
    }

    public void setGameRemoteUrl(String str) {
        AppPreferenceUtil.putString("LocalGameUrl", str);
        remoteGameUrl = str;
    }
}