package com.ym.library.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.ym.commen.module.VideoEntity;
import com.ym.library.Constant;
import com.ym.library.module.WithdrawCardEntity;
import com.ym.library.module.WithdrawEntity;
import com.ym.library.net.NovelInitEntity;
import com.ym.modulecommon.AppliContext;
import com.ym.modulecommon.module.UserInfoEntity;

import java.util.List;


/**
 * Created by gaoleichao on 2018/5/5.
 */

public class SettingPreference {
    private static final String USER_SETTING = "user_setting";
    private static final String INIT_SETTING = "init_setting";
    private static final String CHECKED_SETTING = "checked_setting";

    private static final String USER_TOKEN_KEY = "user_token_keys";
    private static final String USER_ID = "user_id";
    private static final String APP_WALL_APP_KEY = "appwall_app_key";
    private static final String APP_SECRET = "app_secret";
    private static final String IS_DEV_DEVICE = "is_dev_device";

    // 是否开启LOG打印
    private static final String IS_OPEN_LOG_PRINT = "is_open_log";
    // 是否开启LOG日志保存
    private static final String IS_OPEN_LOG_SAVE = "is_open_log_save";

    /*公共参数二级缓存*/
    private static final String USER_AGENT = "userAgent";
    private static final String MODEL = "model";
    private static final String ANDROID_ID = "android_id";
    private static final String CARRIER = "carrier";
    private static final String W = "w";
    private static final String H = "h";
    private static final String SOURCE = "sourch";
    private static final String IP = "ip";
    private static final String SVN = "svn";

    private static final String DEVICE = "device";
    private static final String WX_TOKEN = "wx_token";
    private static final String WX_OPENID = "wx_openid";

    private static final String IMEI = "imei";
    private static final String SSID = "ssid";
    private static final String MI_TOKEN = "miToken";
    private static final String IMSI = "imsi";
    private static final String MAC = "mac";
    private static final String ENV = "env";
    private static final String UA = "ua";
    private static final String VC = "vc";
    private static final String VN = "vn";
    private static final String NTT = "ntt";

    private static final String SEC_MD5 = "sec_md5";
    private static final String SEC_DESC = "sec_desc";
    private static final String USER_INFO_KEY = "user_info_keys";
    private static final String CANCEL_UPDATE_DATE = "cancel_update_date";
    private static final String GENDER_TYPE = "gender_type";
    private static final String INIT_INFO_KEY = "init_info_keys";
    private static final String MEMBER_DATA = "member_data";
    private static final String COINS_DATA = "coins_data";
    private static final String PAY_MONTHLY = "pay_monthly";
    private static final String PAY_COIN_MONTHLY = "pay_coin_monthly";
    private static final String HISTORY = "history";
    private static final String IS_FIRST = "is_first";
    private static final String IS_NIGHT = "is_night";
    private static final String VIDEO_DATA = "video_data";
    private static final String GIFT_AD_DATA = "GiftBoxAdData";
    private static final String READ_NEWS = "read_news";
    private static final String NEWS_READ_TIME = "news_read_time";
    private static final String USER_READ_PROGRESS = "user_read_progress";
    private static final String NEWS_SHARE_TIPS = "news_share_tips";
    private static final String COINS_DIALOG_VISIBILITY = "coins_dialog_visibility";
    private static final String ISREAD = "isread";

    private static final String WITHDRAW_TYPE_DATA = "withdraw_type";
    private static final String WITHDRAW_WECHAT_NUMBER = "withdraw_wechat_number";
    private static final String WITHDRAW_ALIPAY_NUMBER = "withdraw_alipay_number";
    private static final String USER_NOVEL_READ_PROGRESS = "user_novel_read_progress";
    private static final String COLLECT_HOME_TAB = "collect_home_tab";
    private static final String NEWS_AD_DETAILS = "news_ad_details";
    private static final String NEWS_ENTITY = "news_entity";
    private static final String REWARD_COMPLETED = "reward_comple";
    private static final String SAVE_VIDEO_PROGRESS = "save_video_progress";
    private static final String SIGNIN_DATE = "signin_date";
    private static final String LUCKY_AUTO = "lucky_auto_";
    private static final String NEXT_LOOK = "next_look";

    private static final String STEP_NUM = "step_num";

    private static final String SIGN_SESSIONID = "sign_sessionid";
    private static final String IS_FIRST_LOGIN_DIALOG = "is_first_login_dialog";
    private static final String LAT = "lat";
    private static final String LON = "lon";
    private static final String CITY = "city";
    private static final String LOCATION_TYPE = "location_type";
    private static final String SEARCH_DATA = "search_data";
    private static final String IS_FIRST_LOGIN = "is_first_login";
    private static final String SPLASH_INVREVAL = "splash_intreval";
    private static final String IS_SHOW_ACTIVITY = "is_show_activity";

    private static final String IS_FIRST_VIDEO_PAGE = "is_first_video_page";

    private static final String FIRST_PRIVACY_PROTOCOL_DIALOG = "first_privacy_protocol_dialog";
    private static final String FIRST_CHECKED_DIALOG = "first_checked_dialog";

    private static final String IS_FIRST_VIDEO = "is_first_video";
    private static final String IS_FIRST_SPLASH_GUIDE = "is_first_splash_guide";

    private static final String IS_FIRST_NEWS_PAGE = "is_first_news_page";

    private static final String TRACK_ID = "track_id";
    private static final String TERMINAL_ID = "terminalId";
    private static final String USER_INFRO_NAME = "user_infro_name";

    private static final String SHOW_PRIVACY_PROTOCOL = "show_privacy_protocol";//是否同意隐私协议
    private static final String SHOW_FIVE_WITHDRAW = "show_five_withdraw";//5首提现

    private static final String SHOW_NOTIFICATION = "show_notification";//通知栏

    /**
     * 是否第一次进入APP
     *
     * @param
     */
    public static boolean isFirst() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        return settings.getBoolean(FIRST_PRIVACY_PROTOCOL_DIALOG, true);
    }


    public static void setIsFirst(Boolean isFirst) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(FIRST_PRIVACY_PROTOCOL_DIALOG, isFirst);
        editor.commit();

    }

    /**
     * 是否第一次进入APP
     *
     * @param
     */
    public static boolean isFirstPPD() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        return settings.getBoolean(FIRST_PRIVACY_PROTOCOL_DIALOG, true);
    }

    public static boolean isFirstCheck() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(CHECKED_SETTING, 0);
        return settings.getBoolean(FIRST_CHECKED_DIALOG, false);
    }

    public static void setFirstCheck(boolean isFirstPPD) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(CHECKED_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(FIRST_CHECKED_DIALOG, isFirstPPD);
        editor.commit();
    }

    /**
     * 首次进入app修改状态
     *
     * @param isFirstPPD false
     * @return
     */
    public static void setFirstPPD(boolean isFirstPPD) {

        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(FIRST_PRIVACY_PROTOCOL_DIALOG, isFirstPPD);
        editor.commit();
    }

    /**
     * 是否第一次进入APP
     *
     * @param
     */
    public static boolean getIsShowGuide() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        return settings.getBoolean(IS_FIRST_SPLASH_GUIDE, true);
    }

    /**
     * 首次进入app修改状态
     *
     * @param isFirstPPD false
     * @return
     */
    public static void setIsShowGuide(boolean isFirstPPD) {

        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST_SPLASH_GUIDE, isFirstPPD);
        editor.commit();
    }

    /**
     * 设置开发设备
     *
     * @param context
     * @param isDevDevice
     */
    public static void setIsDevDevice(Context context, boolean isDevDevice) {
        SharedPreferences settings = context.getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_DEV_DEVICE, isDevDevice);
        editor.commit();
    }


    public static void setH5Data(String key, String value) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("h5_" + key, value);
        editor.commit();
    }

    public static String getH5Data(String key) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String ad = settings.getString("h5_" + key, "");
        return ad;
    }

    /**
     * SHOW_NOTIFICATION
     * 设置通知栏
     */
    public static void setNotice(Boolean value) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(SHOW_NOTIFICATION, value);
        editor.commit();
    }

    public static Boolean getNotice() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        Boolean ad = settings.getBoolean(SHOW_NOTIFICATION, true);
        return ad;
    }

//    /**
//     * 是否开发设备
//     *
//     * @param context
//     * @return
//     */
//    public static boolean isDevDevice(Context context) {
//        SharedPreferences settings = context.getSharedPreferences(USER_SETTING, 0);
//        return settings.getBoolean(IS_DEV_DEVICE, false);
//    }
//
//    public static String getUserAgent() {
//        String userAgent = Constant.Param.userAgent;
//        if (TextUtils.isEmpty(userAgent)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(USER_AGENT, "");
//        }
//        return userAgent;
//    }
//
//    public static void setUserAgent(String userAgent) {
//        Constant.Param.userAgent = TextUtils.isEmpty(userAgent) ? "" : userAgent;
//        if (!TextUtils.isEmpty(Constant.Param.userAgent)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(USER_AGENT, Constant.Param.userAgent);
//            editor.commit();
//        }
//    }
//
//    public static String getModel() {
//        String model = Constant.Param.model;
//        if (TextUtils.isEmpty(model)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(MODEL, PhoneUtils.INSTANCE.getModel());
//        }
//        return model;
//    }
//
//    public static void setModel(String model) {
//        Constant.Param.model = TextUtils.isEmpty(model) ? "" : model;
//        if (!TextUtils.isEmpty(Constant.Param.model)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(MODEL, Constant.Param.model);
//            editor.commit();
//        }
//    }
//
//    public static String getAndroidId() {
//        String androidId = Constant.Param.androidId;
//        if (TextUtils.isEmpty(androidId)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(ANDROID_ID, PhoneUtils.INSTANCE.getAndroidID(AppliContext.get()));
//        }
//        return androidId;
//    }
//
//    public static void setAndroidId(String androidId) {
//        Constant.Param.androidId = TextUtils.isEmpty(androidId) ? "" : androidId;
//        if (!TextUtils.isEmpty(Constant.Param.androidId)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(ANDROID_ID, Constant.Param.androidId);
//            editor.commit();
//        }
//    }
//
//    public static String getCarrier() {
//        String carrier = Constant.Param.carrier;
//        if (TextUtils.isEmpty(carrier)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(CARRIER, PhoneUtils.INSTANCE.getOperator(AppliContext.get()));
//        }
//        return carrier;
//    }
//
//    public static void setCarrier(String carrier) {
//        Constant.Param.carrier = TextUtils.isEmpty(carrier) ? "" : carrier;
//        if (!TextUtils.isEmpty(Constant.Param.carrier)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(CARRIER, Constant.Param.carrier);
//            editor.commit();
//        }
//    }
//
//    public static String getW() {
//        String w = Constant.Param.w;
//        if (TextUtils.isEmpty(w)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(W, PhoneUtils.INSTANCE.getScreenWidth(AppliContext.get()) + "");
//        }
//        return w;
//    }
//
//    public static void setW(String w) {
//        Constant.Param.w = TextUtils.isEmpty(w) ? "" : w;
//        if (!TextUtils.isEmpty(Constant.Param.w)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(W, Constant.Param.w);
//            editor.commit();
//        }
//    }
//
//    public static String getH() {
//        String h = Constant.Param.h;
//        if (TextUtils.isEmpty(h)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(H, PhoneUtils.INSTANCE.getScreenHeight(AppliContext.get()) + "");
//        }
//        return h;
//    }
//
//    public static void setH(String h) {
//        Constant.Param.h = TextUtils.isEmpty(h) ? "" : h;
//        if (!TextUtils.isEmpty(Constant.Param.h)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(H, Constant.Param.h);
//            editor.commit();
//        }
//    }
//
//    public static String getDevice() {
//        String device = Constant.Param.device;
//
//        try {
//
//            if (TextUtils.isEmpty(device)) {
//                SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//                return settings.getString(DEVICE, PhoneUtils.INSTANCE.getDeviceId(AppliContext.get()));
//            }
//        } catch (Exception e) {
//            return "";
//        }
//        return device;
//    }
//
//    public static void setDevice(String device) {
//        Constant.Param.device = TextUtils.isEmpty(device) ? "" : device;
//        if (!TextUtils.isEmpty(Constant.Param.device)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(DEVICE, Constant.Param.device);
//            editor.commit();
//        }
//    }


    //设置微信token
    public static void setWxToken(@Nullable String token) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(WX_TOKEN, token);
        editor.commit();
    }

    public static String getWxToken() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(WX_TOKEN, "");
    }

    //设置微信openid
    public static void setWxOpenId(@Nullable String openid) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(WX_OPENID, openid);
        editor.commit();
    }

    public static String getWxOpenId() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(WX_OPENID, "");
    }


//    public static String getImei() {
//        String imei = Constant.Param.imei;
//        if (TextUtils.isEmpty(imei)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(IMEI, PhoneUtils.INSTANCE.getImei(AppliContext.get()));
//        }
//        return imei;
//    }
//
//    public static void setImei(String imei) {
//        Constant.Param.imei = TextUtils.isEmpty(imei) ? "" : imei;
//        if (!TextUtils.isEmpty(Constant.Param.imei)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(IMEI, Constant.Param.imei);
//            editor.commit();
//        }
//    }
//
//    public static String getSsid() {
//        String ssid = Constant.Param.ssid;
//        if (TextUtils.isEmpty(ssid)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(SSID, PhoneUtils.INSTANCE.getBSSID(AppliContext.get()));
//        }
//        return ssid;
//    }
//
//    public static void setSsid(String ssid) {
//        Constant.Param.ssid = TextUtils.isEmpty(ssid) ? "" : ssid;
//        if (!TextUtils.isEmpty(Constant.Param.ssid)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            Constant.Param.ssid.replace(":", "");
//            editor.putString(SSID, Constant.Param.ssid);
//            editor.commit();
//        }
//    }
//
//
//    public static String getImsi() {
//        String imsi = Constant.Param.imsi;
//        if (TextUtils.isEmpty(imsi)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(IMSI, PhoneUtils.INSTANCE.getIMSI(AppliContext.get()));
//        }
//        return imsi;
//    }
//
//    public static void setImsi(String imsi) {
//        Constant.Param.imsi = TextUtils.isEmpty(imsi) ? "" : imsi;
//        if (!TextUtils.isEmpty(Constant.Param.imsi)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(IMSI, Constant.Param.imsi);
//            editor.commit();
//        }
//    }
//
//    public static String getMac() {
//        String mac = Constant.Param.mac;
//        if (TextUtils.isEmpty(mac)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
////            return settings.getString(MAC, PhoneUtils.INSTANCE.getMac(AppliContext.get()));
//            return "";
//        }
//        return mac;
//    }
//
//    public static void setMac(String mac) {
//        Constant.Param.mac = TextUtils.isEmpty(mac) ? "" : mac;
//        if (!TextUtils.isEmpty(Constant.Param.mac)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(MAC, Constant.Param.mac);
//            editor.commit();
//        }
//    }
//
//    public static String getIp() {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        return settings.getString(IP, "");
//    }
//
//    public static void setIp(String ip) {
//        SharedPreferences sharedPre = AppliContext.get().getSharedPreferences(
//                USER_SETTING, AppliContext.get().MODE_PRIVATE);
//        SharedPreferences.Editor editor = sharedPre.edit();
//        editor.putString(IP, ip);
//        editor.commit();
//    }
//
//    public static String getUA() {
//        String ua = Constant.Param.ua;
//        if (TextUtils.isEmpty(ua)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(UA, System.getProperty("http.agent"));
//        }
//        return ua;
//    }
//
//    public static void setUA(String ua) {
//        Constant.Param.ua = TextUtils.isEmpty(ua) ? "" : ua;
//        if (!TextUtils.isEmpty(Constant.Param.ua)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(UA, Constant.Param.ua);
//            editor.commit();
//        }
//    }
//
//    public static String getVC() {
//        String vc = Constant.Param.vc;
//        if (TextUtils.isEmpty(vc)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(VC, PhoneUtils.INSTANCE.getAppVersionCode(AppliContext.get()) + "");
//        }
//        return vc;
//    }
//
//    public static void setVC(String vc) {
//        Constant.Param.vc = TextUtils.isEmpty(vc) ? "" : vc;
//        if (!TextUtils.isEmpty(Constant.Param.vc)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(VC, Constant.Param.vc);
//            editor.commit();
//        }
//    }
//
//    public static String getVN() {
//        String vn = Constant.Param.vn;
//        if (TextUtils.isEmpty(vn)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(VN, PhoneUtils.INSTANCE.getAppVersionName(AppliContext.get()));
//        }
//        return vn;
//    }
//
//    public static void setVN(String vn) {
//        Constant.Param.vn = TextUtils.isEmpty(vn) ? "" : vn;
//        if (!TextUtils.isEmpty(Constant.Param.vn)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(VN, Constant.Param.vn);
//            editor.commit();
//        }
//    }
//
//    public static String getSource() {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//
//        String source = settings.getString(SOURCE, "");
//        if (TextUtils.isEmpty(source)) {
//            source = Utils.getChannel(AppliContext.get());
//            if (!TextUtils.isEmpty(source)) {
//                setSource(source);
//            }
//        }
//
//        return source;
//    }
//
//    public static void setSource(String source) {
//        SharedPreferences sharedPre = AppliContext.get().getSharedPreferences(
//                USER_SETTING, AppliContext.get().MODE_PRIVATE);
//        SharedPreferences.Editor editor = sharedPre.edit();
//        editor.putString(SOURCE, source);
//        editor.commit();
//    }
//
//    public static String getSVN() {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        return settings.getString(SVN, "");
//    }
//
//    public static void setSVN(String svn) {
//        SharedPreferences sharedPre = AppliContext.get().getSharedPreferences(
//                USER_SETTING, AppliContext.get().MODE_PRIVATE);
//        SharedPreferences.Editor editor = sharedPre.edit();
//        editor.putString(SVN, svn);
//        editor.commit();
//    }
//
//    public static String getNTT() {
//        String ntt = Constant.Param.ntt;
//        if (TextUtils.isEmpty(ntt)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(NTT, PhoneUtils.INSTANCE.getNetworkType(AppliContext.get()).toString());
//        }
//        return ntt;
//    }
//
//    public static void setNTT(String ntt) {
//        Constant.Param.ntt = TextUtils.isEmpty(ntt) ? "" : ntt;
//        if (!TextUtils.isEmpty(Constant.Param.ntt)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(NTT, Constant.Param.ntt);
//            editor.commit();
//        }
//    }
//
//    public static String getUid() {
//        String uid = Constant.Param.uid;
//        if (TextUtils.isEmpty(uid)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(USER_ID, "");
//        }
//        return uid;
//    }
//
//    public static void setUid(String uid) {
//        Constant.Param.uid = TextUtils.isEmpty(uid) ? "" : uid;
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putString(USER_ID, Constant.Param.uid);
//        editor.commit();
//    }

    public static String getAppWallAppKey() {
        String appKey = Constant.Param.appWallAppKey;
        if (TextUtils.isEmpty(appKey)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            return settings.getString(APP_WALL_APP_KEY, "");
        }
        return appKey;
    }

    public static void setAppWallAppKey(String appKey) {
        Constant.Param.appWallAppKey = TextUtils.isEmpty(appKey) ? "" : appKey;
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(APP_WALL_APP_KEY, Constant.Param.appWallAppKey);
        editor.commit();
    }

    public static String getAppSecret() {
        String secret = Constant.b;
        if (TextUtils.isEmpty(secret)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            return settings.getString(APP_SECRET, "");
        }
        return secret;
    }

    public static void setAppSecret(String secret) {
        Constant.b = TextUtils.isEmpty(secret) ? "" : secret;
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(APP_SECRET, Constant.b);
        editor.commit();
    }

    public static String getSlotId() {
        String slotId = Constant.Param.slotId;
        if (TextUtils.isEmpty(slotId)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            return settings.getString(Constant.slotId, "");
        }
        return slotId;
    }

    /**
     * 书城推荐页广告位
     *
     * @param slotId
     */
    public static void setSlotId(String slotId) {
        Constant.Param.slotId = TextUtils.isEmpty(slotId) ? "" : slotId;
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(Constant.slotId, Constant.Param.slotId);
        editor.commit();
    }
//
//    public static long getTime() {
//        long time = Constant.Param.time;
//        if (time > 0) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getLong(Constant.time, 0);
//        }
//        return time;
//    }
//
//    public static void setTime(long time) {
//        Constant.Param.time = time;
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putLong(Constant.time, Constant.Param.time);
//        editor.commit();
//    }
//
//    public static String getExplainUrl() {
//        String explainUrl = Constant.Param.explainUrl;
//        if (TextUtils.isEmpty(explainUrl)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(Constant.explainUrl, "");
//        }
//        return explainUrl;
//    }
//
//    public static void setExplainUrl(String time) {
//        Constant.Param.explainUrl = time;
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putString(Constant.explainUrl, Constant.Param.explainUrl);
//        editor.commit();
//    }
//
//
//    public static void setIsShowAd(boolean isShowAd) {
//        Constant.Param.isShowAd = isShowAd;
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putBoolean(IS_DEV_DEVICE, isShowAd);
//        editor.commit();
//    }
//
//
//    public static boolean isShowAd() {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        return settings.getBoolean(Constant.isShowAd, false);
//    }
//
//    public static int getNovelDuration() {
//        int novelDuration = Constant.Param.novelDuration;
//        if (novelDuration == 0) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getInt(Constant.novelDuration, 0);
//        }
//        return novelDuration;
//    }
//
//    public static void setNovelDuration(int count) {
//        Constant.Param.novelDuration = count;
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putInt(Constant.novelDuration, Constant.Param.novelDuration);
//        editor.commit();
//    }
//
//    public static int getAdDuration() {
//        int adDuration = Constant.Param.adDuration;
//        if (adDuration == 0) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getInt(Constant.adDuration, 0);
//        }
//        return adDuration;
//    }
//
//    public static void setAdDuration(int count) {
//        Constant.Param.adDuration = count;
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putInt(Constant.adDuration, Constant.Param.adDuration);
//        editor.commit();
//    }
//
//    public static String getMd5() {
//        String md5 = Constant.Param.md5;
//        if (TextUtils.isEmpty(md5)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(SEC_MD5, "");
//        }
//        return md5;
//    }
//
//    public static void saveMd5(String md5) {
//        Constant.Param.md5 = TextUtils.isEmpty(md5) ? "" : md5;
//        if (!TextUtils.isEmpty(Constant.Param.md5)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(SEC_MD5, Constant.Param.md5);
//            editor.commit();
//        }
//    }
//
//    public static String getSecDesc() {
//        String sec_desc = Constant.Param.sec_desc;
//        if (TextUtils.isEmpty(sec_desc)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(SEC_DESC, "");
//        }
//        return sec_desc;
//    }
//
//    public static void saveSecDesc(String sec_desc) {
//        Constant.Param.sec_desc = TextUtils.isEmpty(sec_desc) ? "" : sec_desc;
//        if (!TextUtils.isEmpty(Constant.Param.sec_desc)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(SEC_DESC, Constant.Param.sec_desc);
//            editor.commit();
//        }
//    }
//
//    public static String getToken() {
//        String token = Constant.Param.token;
//        if (TextUtils.isEmpty(token)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(USER_TOKEN_KEY, "");
//        }
//        return token;
//    }
//
//    public static void setToken(String token) {
//        Constant.Param.token = TextUtils.isEmpty(token) ? "" : token;
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putString(USER_TOKEN_KEY, Constant.Param.token);
//        editor.commit();
//    }
//
//    // 保存登陆用户信息。
//    public static void saveUserInfo(UserInfoEntity userInfoData) {
//        if (userInfoData == null) {
//            setUid("");
//        } else {
//            setUid(userInfoData.getUid());
//
//            setAgeDate(userInfoData.getAge());
//            String gender;
//            if (TextUtils.equals(userInfoData.getSex(), "1"))
//                gender = "男";
//            else {
//                gender = "女";
//            }
//            setGenderDate(gender);
//            setWeightDate(userInfoData.getWeight() + "kg");
//            setHeightDate(userInfoData.getHeight() + "cm");
//            setStepSettingType(userInfoData);
//        }
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putString(USER_INFO_KEY, null == userInfoData ? "" : Utils.obj2Str(userInfoData)).commit();
//    }

    private static void setStepSettingType(UserInfoEntity userInfoData) {
        String type = "1";
        if (TextUtils.equals("0", userInfoData.getAge())) {
            type = "0";
        }
        if (TextUtils.equals("0", userInfoData.getWeight())) {
            type = "0";
        }
        if (TextUtils.equals("0", userInfoData.getHeight())) {
            type = "0";
        }
        if (TextUtils.equals("0", userInfoData.getSex())) {
            type = "0";
        }
        SharedPreferences sharedPre = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = sharedPre.edit();
        editor.putString("StepSettingType", type);
        editor.commit();
    }

    public static String getStepSettingType() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String StepSettingType = settings.getString("StepSettingType", "0");
        return StepSettingType;
    }

    // 获取登陆用户信息。
    public static UserInfoEntity getUserInfoData() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String user = settings.getString(USER_INFO_KEY, "");
        if (TextUtils.isEmpty(user)) {
            return null;
        }
        return (UserInfoEntity) Utils.str2Obj(user, UserInfoEntity.class);
    }


    /**
     * 获取签到日期
     */
    public static String getCancelUpdateDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(CANCEL_UPDATE_DATE, "");
    }

    public static void setCancelUpdateDate(Context context, String date) {
        SharedPreferences sharedPre = context.getSharedPreferences(
                USER_SETTING, context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPre.edit();
        editor.putString(CANCEL_UPDATE_DATE, date);
        editor.commit();
    }


    public static int getGender() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getInt(Constant.gender, 1);
    }

    public static void setGender(int gender) {
        setGenderType(1);//
        Constant.Param.gender = gender;
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(Constant.gender, Constant.Param.gender);
        editor.commit();
    }


    public static int getGenderType() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getInt(GENDER_TYPE, 0);
    }

    /**
     * 当前是否存储性别标识
     */
    public static void setGenderType(int date) {
        SharedPreferences sharedPre = AppliContext.get().getSharedPreferences(
                USER_SETTING, AppliContext.get().MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPre.edit();
        editor.putInt(GENDER_TYPE, date);
        editor.commit();
    }

    // 保存初始化信息。
    public static void saveInitInfo(NovelInitEntity userInfoData) {
        if (userInfoData == null) {
            setSlotId("");
        } else {
            setSlotId(userInfoData.getBannerSlotId());
        }
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(INIT_INFO_KEY, null == userInfoData ? "" : Utils.obj2Str(userInfoData)).commit();
    }


    // 获取初始化信息。
    public static NovelInitEntity getInitInfoData() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        String user = settings.getString(INIT_INFO_KEY, "");
        if (TextUtils.isEmpty(user)) {
            return null;
        }
        return (NovelInitEntity) Utils.str2Obj(user, NovelInitEntity.class);
    }

    // 保存广点通配置信息
    public static void saveSlotGDT(String gdtStr) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("gdtStr", gdtStr).commit();
    }

    public static String getSlotGDT() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        String gdtStr = settings.getString("gdtStr", "");
        return gdtStr;
    }


    // 保存穿山甲配置信息
    public static void saveSlotJrtt(String jrttStr) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("jrttStr", jrttStr).commit();
    }

    public static String getSlotJrtt() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(INIT_SETTING, 0);
        String gdtStr = settings.getString("jrttStr", "");
        return gdtStr;
    }

    public static String getManSlotId() {
        String manSlotId = Constant.Param.manSlotId;
        if (TextUtils.isEmpty(manSlotId)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null && entity.getSlotIds() != null) {
                manSlotId = entity.getSlotIds().getManSlotId();
            }
        }
        return manSlotId;
    }

    public static String getWomanSlotId() {
        String womanSlotId = Constant.Param.womanSlotId;
        if (TextUtils.isEmpty(womanSlotId)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null && entity.getSlotIds() != null) {
                womanSlotId = entity.getSlotIds().getWomanSlotId();
            }
        }
        return womanSlotId;
    }

    public static String getBaoPingSlotId() {
        String baoPingSlotId = Constant.Param.baoPingSlotId;
        if (TextUtils.isEmpty(baoPingSlotId)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null && entity.getSlotIds() != null) {
                baoPingSlotId = entity.getSlotIds().getBaoPingSlotId();
            }
        }
        return baoPingSlotId;
    }

    public static String getCollectSlotId() {
        String collectSlotId = Constant.Param.collectSlotId;
        if (TextUtils.isEmpty(collectSlotId)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null && entity.getSlotIds() != null) {
                collectSlotId = entity.getSlotIds().getCollectSlotId();
            }
        }
        return collectSlotId;
    }

    public static void setWelfareCenterUrl(String welfareCenterUrl) {
        Constant.Param.welfareCenterUrl = TextUtils.isEmpty(welfareCenterUrl) ? "" : welfareCenterUrl;
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(Constant.welfareCenterUrl, Constant.Param.welfareCenterUrl);
        editor.commit();
    }

    public static String getWelfareCenterUrl() {
        String welfareCenterUrl = Constant.Param.welfareCenterUrl;
        if (TextUtils.isEmpty(welfareCenterUrl)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            return settings.getString(Constant.welfareCenterUrl, "");
        }
        return welfareCenterUrl;
    }

    /**
     * 获取金币兑换url
     *
     * @return
     */
    public static String getCoinUrl() {
        String coinUrl = Constant.Param.coinUrl;
        if (TextUtils.isEmpty(coinUrl)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null) {
                coinUrl = entity.getCoinUrl();
            }
        }
        return coinUrl;
    }

    /**
     * 帮助中心url
     *
     * @return
     */
    public static String getHelpUrl() {
        String helpUrl = Constant.Param.helpUrl;
        if (TextUtils.isEmpty(helpUrl)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null) {
                helpUrl = entity.getHelp();
            }
        }
        return helpUrl;
    }

    public static String getNewHelpUS() {
        String newHelpUS = Constant.Param.newHelpUS;
        if (TextUtils.isEmpty(newHelpUS)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null) {
                newHelpUS = entity.getNewHelpUS();
            }
        }
        return newHelpUS;
    }

    public static String getMemberData() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(MEMBER_DATA, "");

    }

    public static void setMemberData(String data) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(MEMBER_DATA, data);
        editor.commit();
    }

    public static String getCoinsData() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(COINS_DATA, "");

    }

    public static void setCoinsData(String data) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(COINS_DATA, data);
        editor.commit();
    }

    public static void setPayCoinMonthly(String data) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(PAY_COIN_MONTHLY, data);
        editor.commit();
    }

    public static String getPayCoinMonthly() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(PAY_COIN_MONTHLY, "");

    }

    public static void setPayMonthly(String data) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(PAY_MONTHLY, data);
        editor.commit();
    }

    public static String getPayMonthly() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(PAY_MONTHLY, "");

    }

    public static String getDetailSlotId() {
        String detailSlotId = Constant.Param.detailSlotId;
        if (TextUtils.isEmpty(detailSlotId)) {
            NovelInitEntity entity = getInitInfoData();
            if (entity != null && entity.getSlotIds() != null) {
                detailSlotId = entity.getSlotIds().getDetailSlotId();
            }
        }
        return detailSlotId;
    }


    public static void setIsfirstRead(boolean isfirstRead) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST, isfirstRead);
        editor.commit();
    }

    public static boolean getIsfirstRead() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getBoolean(IS_FIRST, true);
    }

    public static void setNight(boolean isfirstRead) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_NIGHT, isfirstRead);
        editor.commit();
    }

    public static boolean getIsNight() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getBoolean(IS_NIGHT, false);
    }

    public static void saveVideoData(String data) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(VIDEO_DATA, data);
        editor.commit();
    }

    public static String getVideoData() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(VIDEO_DATA, "");
    }
//    public static void saveGiftBoxAdData(List<NovelEntity> data) {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putString(GIFT_AD_DATA, null == data ? "" : Utils.obj2Str(data)).commit();
//    }
//
//    public static String getGiftBoxAdData() {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        String user = settings.getString(GIFT_AD_DATA, "");
//        if (TextUtils.isEmpty(user)) {
//            return null;
//        }
//        return (List<NovelEntity>) Utils.str2Obj(user, List<NovelEntity.class);
//    }

    public static String getNewsReadData() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(READ_NEWS, "");
    }

    public static void saveReadNews(String id) {
        String ids = getNewsReadData();
        if (TextUtils.isEmpty(ids)) {
            ids = id;
        } else {
            if (!isReaded(id)) {
                ids = ids + "," + id;
            } else {
                return;
            }
        }
        SharedPreferences sharedPre = AppliContext.get().getSharedPreferences(
                USER_SETTING, AppliContext.get().MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPre.edit();
        editor.putString(READ_NEWS, ids);
        editor.commit();
    }


    /**
     * 是否阅读过该条新闻
     *
     * @param
     */
    public static boolean isReaded(String currentId) {
        String idsStr = getNewsReadData();
        if (TextUtils.isEmpty(idsStr)) {
            return false;
        } else {
            String[] ids = idsStr.split(",");
            for (String id : ids) {
                if (TextUtils.equals(currentId, id)) {
                    return true;
                }
            }
            return false;
        }
    }


    /**
     * 保存新闻阅读时间
     */

    public static void setNewReadTime() {
        long nowTime = System.currentTimeMillis();
        long lastTime = getNewReadTime();
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        if (Utils.isYesterday(lastTime)) {
            editor.putLong(NEWS_READ_TIME, nowTime);
            editor.commit();
        }
    }

    /**
     * 获取阅读时间
     */
    public static Long getNewReadTime() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getLong(NEWS_READ_TIME, 0);
    }

    public static void setUpdateApkTime(final Context context) {
        SharedPreferences sharedPre = context.getSharedPreferences(
                USER_SETTING, context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPre.edit();
        editor.putLong("time", System.currentTimeMillis());
        editor.commit();
    }


    // 保存用户阅读进度
    public static void saveUserReadProgress(int value) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(USER_READ_PROGRESS, value);
        editor.commit();
    }
    // 获取用户阅读进度

    public static int getUserReadProgress() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getInt(USER_READ_PROGRESS, 0);
    }


    /**
     * 获取新闻分享展示时间
     */
    public static String getNewsShareTipsDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(NEWS_SHARE_TIPS, "");
    }

    public static void setNewsShareTipsDate(Context context, String date) {
        SharedPreferences sharedPre = context.getSharedPreferences(
                USER_SETTING, context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPre.edit();
        editor.putString(NEWS_SHARE_TIPS, date);
        editor.commit();
    }

    public static void setCoinsDialogVisibility(boolean value) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(COINS_DIALOG_VISIBILITY, value);
        editor.commit();
    }

    public static boolean getCoinsDialogVisibility() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getBoolean(COINS_DIALOG_VISIBILITY, true);
    }

    /**
     * 是否获取过阅读奖励
     */
    public static Boolean isReadCoins() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getBoolean(ISREAD, false);
    }

    public static void setReadCoins(Context context, boolean isCom) {
        SharedPreferences sharedPre = context.getSharedPreferences(
                USER_SETTING, context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPre.edit();
        editor.putBoolean(ISREAD, isCom);
        editor.commit();
    }

    // 保存用户阅读进度
    public static void saveUserNovelReadProgress(int value) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(USER_NOVEL_READ_PROGRESS, value);
        editor.commit();
    }
    // 获取用户阅读进度

    public static int getUserNovelReadProgress() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getInt(USER_NOVEL_READ_PROGRESS, 0);
    }


    public static void saveNewsAdDetailsDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(NEWS_AD_DETAILS, Utils.getNowDate());
        editor.commit();
    }

    public static String getNewsAdDetailsDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString(NEWS_AD_DETAILS, "");
        return json;
    }

//        if (data == null || data.getType() == 3)
//            return;
//        data.setNewsDetailsType(0);
//        List<NewsEntity> list = new ArrayList<>();
//        List<NewsEntity> datas = getNovelEntityListData();
//        if (datas != null) {
//            for (NewsEntity string : datas) {
//                if (!TextUtils.equals(data.getRowKey(), string.getRowKey())) {
//                    list.add(string);
//                }
//            }
//            list.add(0, data);
//        } else {
//            list.add(data);
//        }
//        if (list.size() >= 20) {
//            list.remove(list.size() - 1);
//        }
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putString(NEWS_ENTITY, Utils.list2String(list));
//        editor.commit();


    public static void clearRewardCompleted() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(REWARD_COMPLETED, "");
        editor.commit();
    }


    /**
     *
     */
    public static void saveVideoProgress(int entity) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(SAVE_VIDEO_PROGRESS, entity);
        editor.commit();
    }

    public static int getVideoProgress() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        int json = settings.getInt(SAVE_VIDEO_PROGRESS, 0);
        return json;
    }

    public static void setSigninDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(SIGNIN_DATE, Utils.getNowDate());
        editor.commit();
    }

    public static String getSignDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString(SIGNIN_DATE, "");
        return json;
    }

    public static void setLuckyAuto(int isAuto) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(LUCKY_AUTO, isAuto);
        editor.commit();
    }

    public static int getLuckyAuto() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        int json = settings.getInt(LUCKY_AUTO, 2);
        return json;
    }

    public static void setNextLook(int isNext) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(NEXT_LOOK, isNext);
        editor.commit();
    }

    public static int getNextLook() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        int json = settings.getInt(NEXT_LOOK, 0);
        return json;
    }


    // 保存用户阅读进度
    public static void setStepNum(int value) {
        String data = getStepNum();
        if (TextUtils.isEmpty(data)) {
            data = Utils.getNowDate() + "," + value;
        } else {
            String[] list = data.split(",");
            if (list.length == 2) {
                String date = list[0];
                if (TextUtils.equals(date, Utils.getNowDate())) {
                    data = Utils.getNowDate() + "," + (value + Integer.valueOf(list[1]));
                } else {
                    data = Utils.getNowDate() + "," + value;
                }
            } else {
                data = Utils.getNowDate() + "," + value;
            }
        }
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(STEP_NUM, data);
        editor.commit();
    }
    // 获取用户阅读进度

    public static String getStepNum() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(STEP_NUM, "");
    }

    public static void setAgeDate(String text) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("Age_s", text);
        editor.commit();
    }

    public static String getAgeDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString("Age_s", "");
        return json;
    }

    public static void setGenderDate(String text) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("gender_s", text);
        editor.commit();
    }

    public static String getGenderDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString("gender_s", "");
        return json;
    }

    public static void setWeightDate(String text) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("Weight_s", text);
        editor.commit();
    }

    public static String getWeightDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString("Weight_s", "");
        return json;
    }

    public static void setHeightDate(String text) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("Height_s", text);
        editor.commit();
    }

    public static String getHeightDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString("Height_s", "");
        return json;
    }

    public static void setBMIDDate(String text) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("bmi_s", text);
        editor.commit();
    }

    public static String getBMIDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString("bmi_s", "");
        return json;
    }

    public static void setRandom(String text) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("Random", text);
        editor.commit();
    }

    public static String getRandom() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString("Random", "");
        return json;
    }

    public static void setSignSesstionId(String str) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(SIGN_SESSIONID, str);
        editor.commit();
    }

    public static String getSignSessionId() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String str = settings.getString(SIGN_SESSIONID, "");
        return str;
    }

    public static void setFirstLoginDIalog(boolean str) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST_LOGIN_DIALOG, str);
        editor.commit();
    }

    public static boolean getIsFirstLoginDialog() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean str = settings.getBoolean(IS_FIRST_LOGIN_DIALOG, false);
        return str;
    }

//    public static String getUUid() {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        String str = settings.getString("UUID", UUID.randomUUID().toString());
//        setUUid(str);
//        return str;
//    }
//
//    public static void setUUid(String str) {
//        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//        SharedPreferences.Editor editor = settings.edit();
//        editor.putString("UUID", str);
//        editor.commit();
//    }


    public static void saveSettingFlag(int flage) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt("saveSettingFlag", flage);
        editor.commit();
    }

    public static int getSettingFlag() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        int str = settings.getInt("saveSettingFlag", 16);
        return str;
    }


//    public static String getLat() {
//        String lat = Constant.Param.lat;
//        if (TextUtils.isEmpty(lat)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(LAT, "");
//        }
//        return lat;
//    }
//
//    public static void setLat(String lat) {
//        Constant.Param.lat = TextUtils.isEmpty(lat) ? "" : lat;
//        if (!TextUtils.isEmpty(Constant.Param.lat)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(LAT, Constant.Param.lat);
//            editor.commit();
//        }
//    }
//
//    public static String getLon() {
//        String lon = Constant.Param.lon;
//        if (TextUtils.isEmpty(lon)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(LON, "");
//        }
//        return lon;
//    }
//
//    public static void setLon(String lon) {
//        Constant.Param.lon = TextUtils.isEmpty(lon) ? "" : lon;
//        if (!TextUtils.isEmpty(Constant.Param.lon)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(LON, Constant.Param.lon);
//            editor.commit();
//        }
//    }
//
//    public static String getCity() {
//        String city = Constant.Param.city;
//        if (TextUtils.isEmpty(city)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(CITY, "");
//        }
//        return city;
//    }
//
//    public static void setCity(String city) {
//        Constant.Param.city = TextUtils.isEmpty(city) ? "" : city;
//        if (!TextUtils.isEmpty(Constant.Param.city)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(CITY, Constant.Param.city);
//            editor.commit();
//        }
//    }
//
//    public static String getLocationType() {
//        String locationType = Constant.Param.locationType;
//        if (TextUtils.isEmpty(locationType)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            return settings.getString(LOCATION_TYPE, "");
//        }
//        return locationType;
//    }
//
//    public static void setLocationType(String locationType) {
//        Constant.Param.locationType = TextUtils.isEmpty(locationType) ? "" : locationType;
//        if (!TextUtils.isEmpty(Constant.Param.locationType)) {
//            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
//            SharedPreferences.Editor editor = settings.edit();
//            editor.putString(LOCATION_TYPE, Constant.Param.locationType);
//            editor.commit();
//        }
//    }

    public static String getDistrict() {
        String locationType = Constant.Param.district;
        if (TextUtils.isEmpty(locationType)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            return settings.getString("District", "");
        }
        return locationType;
    }

    public static void setDistrict(String locationType) {
        Constant.Param.district = TextUtils.isEmpty(locationType) ? "" : locationType;
        if (!TextUtils.isEmpty(Constant.Param.district)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putString("District", Constant.Param.district);
            editor.commit();
        }
    }

    public static String getStreet() {
        String locationType = Constant.Param.street;
        if (TextUtils.isEmpty(locationType)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            return settings.getString("street", "");
        }
        return locationType;
    }

    public static void setStreet(String locationType) {
        Constant.Param.street = TextUtils.isEmpty(locationType) ? "" : locationType;
        if (!TextUtils.isEmpty(Constant.Param.street)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putString("street", Constant.Param.street);
            editor.commit();
        }
    }

    public static void saveDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("today_date", Utils.getNowDate());
        editor.commit();
    }

    public static String getDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String json = settings.getString("today_date", "");
        return json;
    }

    public static void setIsLogin() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST_LOGIN, false);
        editor.commit();
    }

    public static boolean getIsLogin() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean ad = settings.getBoolean(IS_FIRST_LOGIN, true);

        return ad;
    }

    public static void setSplashInvreval(long value) {
        if (value == 0) {
            value = 10;
        }
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putLong(SPLASH_INVREVAL, value);
        editor.commit();
    }

    public static long getSplashInvreval() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        long ad = settings.getLong(SPLASH_INVREVAL, 10);
        return ad;
    }


    public static void setIsActivity() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_SHOW_ACTIVITY, false);
        editor.commit();
    }

    public static boolean getIsActivity() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean ad = settings.getBoolean(IS_SHOW_ACTIVITY, true);

        return ad;
    }


    public static void setIsFirstNewsPageDetails() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean("is_first_news_page_details", false);
        editor.commit();
    }

    public static boolean getIsFirstNewsPageDetails() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean ad = settings.getBoolean("is_first_news_page_details", true);

        return ad;
    }

    public static void setIsFirstVideoPage() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST_VIDEO_PAGE, false);
        editor.commit();
    }

    public static boolean getIsFirstVideoPage() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean ad = settings.getBoolean(IS_FIRST_VIDEO_PAGE, true);

        return ad;
    }

    public static void setIsFirstVideo() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST_VIDEO, false);
        editor.commit();
    }

    public static boolean getIsFirstVideo() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean ad = settings.getBoolean(IS_FIRST_VIDEO, true);

        return ad;
    }

    public static void setIsFirstNewsPage() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST_NEWS_PAGE, false);
        editor.commit();
    }

    public static boolean getIsFirstNewsPage() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean ad = settings.getBoolean(IS_FIRST_NEWS_PAGE, true);

        return ad;
    }

    public static void setTrackId(Long id) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putLong(TRACK_ID, id);
        editor.commit();
    }

    public static long getTrackId() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        long ad = settings.getLong(TRACK_ID, 0);

        return ad;
    }

    public static void setTerminalId(Long id) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putLong(TERMINAL_ID, id);
        editor.commit();
    }

    public static long getTerminalId() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        long ad = settings.getLong(TERMINAL_ID, 0);

        return ad;
    }

    // 保存登陆用户昵称
    public static void saveUserInfoName(String name) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(USER_INFRO_NAME, null == name ? "" : name).commit();

    }

    // 获取登陆用户昵称
    public static String getUserInfoDataName() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(USER_INFRO_NAME, "");
    }

    // 保存任务页签到日期
    public static void saveSignInDate() {
        String currentDD = DateUtils.getStringByFormat(System.currentTimeMillis(), "dd");
        String signInIsDate = getSignInIsDate();
        if (!signInIsDate.equals(currentDD)) {
            SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putString(SIGN_IN_ISTODAY, currentDD).apply();
        }

    }

    private static final String SIGN_IN_ISTODAY = "sign_in_istoDay";

    // 获取任务页签到日期
    public static String getSignInIsDate() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        return settings.getString(SIGN_IN_ISTODAY, "");
    }


    // 保存来电秀
    public static void saveUserCallFuny(VideoEntity videoEntity) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(USER_CALL_FUNY_KEY, null == videoEntity ? "" : Utils.obj2Str(videoEntity)).commit();
    }

    private static final String USER_CALL_FUNY_KEY = "user_call_funy_key";

    // 保存来电秀
    public static VideoEntity getUserCallFuny() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String user = settings.getString(USER_CALL_FUNY_KEY, "");
        if (TextUtils.isEmpty(user)) {
            return null;
        }
        return (VideoEntity) Utils.str2Obj(user, VideoEntity.class);
    }


    public static void setWithdrawType(List<WithdrawEntity> data) {
        String str = Utils.obj2Str(data);
        if (TextUtils.isEmpty(str)) {
            return;
        }
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(WITHDRAW_TYPE_DATA, str);
        editor.commit();
    }

    public static List<WithdrawEntity> getWithdrawType() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String str = settings.getString(WITHDRAW_TYPE_DATA, "");
        if (TextUtils.isEmpty(str)) {
            return null;
        } else {
            return Utils.str2listObj(str, WithdrawEntity.class);
        }
    }

    /**
     * @param type 1支付宝 2微信
     * @return
     */
    public static List<WithdrawEntity> getWithdrawNumEntity(int type) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        String str = settings.getString(type == 1 ? WITHDRAW_ALIPAY_NUMBER : WITHDRAW_WECHAT_NUMBER, "");
        if (TextUtils.isEmpty(str)) {
            return null;
        } else {
            return Utils.str2listObj(str, WithdrawCardEntity.class);
        }
    }

    /**
     * @param data
     * @param type 1支付宝 2微信
     */
    public static void setWithdrawNumEntity(List<WithdrawEntity> data, int type) {
        String str = Utils.obj2Str(data);
        if (TextUtils.isEmpty(str)) {
            return;
        }
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(type == 1 ? WITHDRAW_ALIPAY_NUMBER : WITHDRAW_WECHAT_NUMBER, str);
        editor.commit();
    }

    public static void setWithdrawNormalEntity(List<WithdrawEntity> data, int type) {
        String str = Utils.obj2Str(data);
        if (TextUtils.isEmpty(str)) {
            return;
        }
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(type == 1 ? WITHDRAW_ALIPAY_NUMBER : WITHDRAW_WECHAT_NUMBER, str);
        editor.commit();
    }

    //隐私协议弹窗
    public static void setPrivacyProtocol(boolean isShow) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(SHOW_PRIVACY_PROTOCOL, isShow);
        editor.commit();
    }

    //隐私协议弹窗
    public static boolean getPrivacyProtocol() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean isShow = settings.getBoolean(SHOW_PRIVACY_PROTOCOL, true);
        return isShow;
    }

    //5首提现
    public static void setFiveWithdraw(boolean isShow) {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(SHOW_FIVE_WITHDRAW, isShow);
        editor.commit();
    }

    //5首提现
    public static boolean getFiveWithdraw() {
        SharedPreferences settings = AppliContext.get().getSharedPreferences(USER_SETTING, 0);
        boolean isShow = settings.getBoolean(SHOW_FIVE_WITHDRAW, true);
        return isShow;
    }
}
