张波

更新代码,更新版本

@@ -4,6 +4,12 @@ plugins { @@ -4,6 +4,12 @@ plugins {
4 id 'maven' 4 id 'maven'
5 } 5 }
6 6
  7 +private static String getBuildTime() {
  8 + Date date = new Date()
  9 + String dateStr = date.format("yyyyMMddHHmm")
  10 + return "\"${dateStr}\""
  11 +}
  12 +
7 android { 13 android {
8 compileSdkVersion var.compileSdkVersion 14 compileSdkVersion var.compileSdkVersion
9 15
@@ -17,6 +23,8 @@ android { @@ -17,6 +23,8 @@ android {
17 consumerProguardFiles "consumer-rules.pro" 23 consumerProguardFiles "consumer-rules.pro"
18 24
19 buildConfigField "String", "API_VERSION", "\"${requestVersion}\"" 25 buildConfigField "String", "API_VERSION", "\"${requestVersion}\""
  26 + //添加build 时间
  27 + buildConfigField "String", "build_version", getBuildTime()
20 } 28 }
21 29
22 buildTypes { 30 buildTypes {
@@ -44,6 +52,8 @@ android { @@ -44,6 +52,8 @@ android {
44 dependencies { 52 dependencies {
45 implementation 'androidx.appcompat:appcompat:1.2.0' 53 implementation 'androidx.appcompat:appcompat:1.2.0'
46 implementation 'com.wd:log:1.0.0' 54 implementation 'com.wd:log:1.0.0'
  55 + implementation 'com.alibaba:fastjson:1.2.62'
  56 + api 'com.alibaba:arouter-api:1.5.2'
47 } 57 }
48 58
49 uploadArchives { 59 uploadArchives {
@@ -54,7 +64,7 @@ uploadArchives { @@ -54,7 +64,7 @@ uploadArchives {
54 } 64 }
55 pom.project { 65 pom.project {
56 artifactId 'wdkitcore' 66 artifactId 'wdkitcore'
57 - version '1.0.0' 67 + version '1.0.5'
58 groupId 'com.wd' 68 groupId 'com.wd'
59 packaging 'aar' 69 packaging 'aar'
60 } 70 }
  1 +
  2 +package com.wd.foundation.wdkitcore.livedata;
  3 +
  4 +import java.lang.reflect.Field;
  5 +import java.lang.reflect.Method;
  6 +import java.util.HashMap;
  7 +import java.util.Map;
  8 +
  9 +import androidx.annotation.NonNull;
  10 +import androidx.lifecycle.LifecycleOwner;
  11 +import androidx.lifecycle.LiveData;
  12 +import androidx.lifecycle.MutableLiveData;
  13 +import androidx.lifecycle.Observer;
  14 +
  15 +/**
  16 + * @author : ouyang
  17 + * @description :BusMutableLiveData
  18 + * @since : 2022/7/4
  19 + */
  20 +public class BusMutableLiveData<T> extends MutableLiveData<T> {
  21 +
  22 + private Map<Observer, Observer> observerMap = new HashMap<>();
  23 +
  24 + @Override
  25 + public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) {
  26 + super.observe(owner, observer);
  27 + try {
  28 + hook(observer);
  29 + } catch (Exception e) {
  30 + e.printStackTrace();
  31 + }
  32 + }
  33 +
  34 + @Override
  35 + public void observeForever(@NonNull Observer<? super T> observer) {
  36 + if (!observerMap.containsKey(observer)) {
  37 + observerMap.put(observer, new ObserverWrapper(observer));
  38 + }
  39 + super.observeForever(observerMap.get(observer));
  40 + }
  41 +
  42 + @Override
  43 + public void removeObserver(@NonNull final Observer<? super T> observer) {
  44 + Observer realObserver = null;
  45 + if (observerMap.containsKey(observer)) {
  46 + realObserver = observerMap.remove(observer);
  47 + } else {
  48 + realObserver = observer;
  49 + }
  50 + super.removeObserver(realObserver);
  51 + }
  52 +
  53 + private void hook(@NonNull Observer<? super T> observer) throws Exception {
  54 + // get wrapper's version
  55 + Class<LiveData> classLiveData = LiveData.class;
  56 + Field fieldObservers = classLiveData.getDeclaredField("mObservers");
  57 + fieldObservers.setAccessible(true);
  58 + Object objectObservers = fieldObservers.get(this);
  59 + Class<?> classObservers = objectObservers.getClass();
  60 + Method methodGet = classObservers.getDeclaredMethod("get", Object.class);
  61 + methodGet.setAccessible(true);
  62 + Object objectWrapperEntry = methodGet.invoke(objectObservers, observer);
  63 + Object objectWrapper = null;
  64 + if (objectWrapperEntry instanceof Map.Entry) {
  65 + objectWrapper = ((Map.Entry) objectWrapperEntry).getValue();
  66 + }
  67 + if (objectWrapper == null) {
  68 + // throw new NullPointerException("Wrapper can not be bull!");
  69 + return;
  70 + }
  71 + Class<?> classObserverWrapper = objectWrapper.getClass().getSuperclass();
  72 + Field fieldLastVersion = classObserverWrapper.getDeclaredField("mLastVersion");
  73 + fieldLastVersion.setAccessible(true);
  74 + // get livedata's version
  75 + Field fieldVersion = classLiveData.getDeclaredField("mVersion");
  76 + fieldVersion.setAccessible(true);
  77 + Object objectVersion = fieldVersion.get(this);
  78 + // set wrapper's version
  79 + fieldLastVersion.set(objectWrapper, objectVersion);
  80 + }
  81 +}
  1 +
  2 +package com.wd.foundation.wdkitcore.livedata;
  3 +
  4 +import java.util.HashMap;
  5 +import java.util.Map;
  6 +
  7 +import androidx.lifecycle.MutableLiveData;
  8 +
  9 +/**
  10 + * @author : ouyang
  11 + * @description :LiveDataBus
  12 + * @since : 2022/7/4
  13 + */
  14 +public final class LiveDataBus {
  15 + private static class SingletonHolder {
  16 + private static final LiveDataBus DEFAULT_BUS = new LiveDataBus();
  17 + }
  18 +
  19 + private final Map<String, BusMutableLiveData<Object>> bus;
  20 +
  21 + private LiveDataBus() {
  22 + bus = new HashMap<>();
  23 + }
  24 +
  25 + public static LiveDataBus getInstance() {
  26 + return SingletonHolder.DEFAULT_BUS;
  27 + }
  28 +
  29 + public <T> MutableLiveData<T> with(String key, Class<T> type) {
  30 + if (!bus.containsKey(key)) {
  31 + bus.put(key, new BusMutableLiveData<>());
  32 + }
  33 + return (MutableLiveData<T>) bus.get(key);
  34 + }
  35 +
  36 + public MutableLiveData<Object> with(String key) {
  37 + return with(key, Object.class);
  38 + }
  39 +
  40 +}
  1 +
  2 +package com.wd.foundation.wdkitcore.livedata;
  3 +
  4 +import androidx.annotation.Nullable;
  5 +import androidx.lifecycle.Observer;
  6 +
  7 +/**
  8 + * @author : ouyang
  9 + * @description :ObserverWrapper
  10 + * @since : 2022/7/4
  11 + */
  12 +public class ObserverWrapper<T> implements Observer<T> {
  13 +
  14 + private Observer<T> observer;
  15 +
  16 + public ObserverWrapper(Observer<T> observer) {
  17 + this.observer = observer;
  18 + }
  19 +
  20 + @Override
  21 + public void onChanged(@Nullable T t) {
  22 + if (observer != null) {
  23 + if (isCallOnObserve()) {
  24 + return;
  25 + }
  26 + observer.onChanged(t);
  27 + }
  28 + }
  29 +
  30 + private boolean isCallOnObserve() {
  31 + StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
  32 + if (stackTrace != null && stackTrace.length > 0) {
  33 + for (StackTraceElement element : stackTrace) {
  34 + if ("android.arch.lifecycle.LiveData".equals(element.getClassName())
  35 + && "observeForever".equals(element.getMethodName())) {
  36 + return true;
  37 + }
  38 + }
  39 + }
  40 + return false;
  41 + }
  42 +}
  1 +
  2 +package com.wd.foundation.wdkitcore.livedata;
  3 +
  4 +import java.util.concurrent.atomic.AtomicBoolean;
  5 +
  6 +import android.util.Log;
  7 +
  8 +import androidx.annotation.MainThread;
  9 +import androidx.annotation.Nullable;
  10 +import androidx.lifecycle.LifecycleOwner;
  11 +import androidx.lifecycle.MutableLiveData;
  12 +import androidx.lifecycle.Observer;
  13 +
  14 +//1.一部分原因是LiveData的机制,就是向所有前台Fragment或者Activity发送数据。只要注册的观察者在前台就必定会收到这个数据。
  15 +//2.另一部分的原因是对ViewModel理解不深刻,理论上只有在Activity保存的ViewModel它没被销毁过就会一直给新的前台Fragment观察者发送数据。
  16 +// 我们需要管理好ViewModel的使用范围。 比如只需要在Fragment里使用的ViewModel就不要给Activity保管。
  17 +// 而根Activity的ViewModel只需要做一下数据共享与看情况使用LiveData。
  18 +public class SingleLiveData<T> extends MutableLiveData<T> {
  19 +
  20 + private static final String TAG = SingleLiveData.class.getSimpleName();
  21 +
  22 + private final AtomicBoolean mPending = new AtomicBoolean(false);
  23 +
  24 + @Override
  25 + @MainThread
  26 + public void observe(LifecycleOwner owner, final Observer<? super T> observer) {
  27 +
  28 + if (hasActiveObservers()) {
  29 + Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
  30 + }
  31 +
  32 + // Observe the internal MutableLiveData
  33 + super.observe(owner, new Observer<T>() {
  34 + @Override
  35 + public void onChanged(@Nullable T t) {
  36 + if (mPending.compareAndSet(true, false)) {
  37 + observer.onChanged(t);
  38 + }
  39 + }
  40 + });
  41 + }
  42 +
  43 + @Override
  44 + @MainThread
  45 + public void setValue(@Nullable T t) {
  46 + mPending.set(true);
  47 + super.setValue(t);
  48 + }
  49 +
  50 + /**
  51 + * Used for cases where T is Void, to make calls cleaner.
  52 + */
  53 + @MainThread
  54 + public void call() {
  55 + setValue(null);
  56 + }
  57 +}
  1 +
  2 +package com.wd.foundation.wdkitcore.router;
  3 +
  4 +import android.os.Looper;
  5 +import android.util.Log;
  6 +import android.widget.Toast;
  7 +
  8 +import androidx.annotation.Nullable;
  9 +
  10 +import com.alibaba.android.arouter.facade.template.IProvider;
  11 +import com.alibaba.android.arouter.launcher.ARouter;
  12 +import com.alibaba.android.arouter.utils.TextUtils;
  13 +import com.wd.foundation.wdkitcore.tools.AppContext;
  14 +
  15 +/**
  16 + * @ProjectName: 路由
  17 + * @Description: 服务提供类
  18 + */
  19 +public class ArouterServiceManager {
  20 +
  21 + public static final String TAG = "ArouterServiceManager";
  22 +
  23 + @Nullable
  24 + public static <T extends IProvider> T provide(Class<T> clz, String path) {
  25 + if (TextUtils.isEmpty(path)) {
  26 + return null;
  27 + }
  28 + IProvider provider = null;
  29 + try {
  30 + provider = (IProvider) ARouter.getInstance().build(path).navigation();
  31 + } catch (Exception e) {
  32 + Log.e(TAG, "没有获取到需要的服务,请检查");
  33 + }
  34 + return (T) provider;
  35 + }
  36 +
  37 + @Nullable
  38 + public static <T extends IProvider> T provide(Class<T> clz) {
  39 + IProvider provider = null;
  40 + try {
  41 + provider = ARouter.getInstance().navigation(clz);
  42 + } catch (Exception e) {
  43 + Log.i(TAG, "没有获取到需要的服务,请检查");
  44 + }
  45 +
  46 + if (AppContext.DEBUG && null == provider) {
  47 + if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
  48 + Toast.makeText(AppContext.getContext(), "没有获取到需要的服务,请检查--->" + clz.getSimpleName(), Toast.LENGTH_LONG)
  49 + .show();
  50 + }
  51 + Log.e(TAG, "没有获取到需要的服务,请检查-->" + clz.getSimpleName());
  52 +
  53 + }
  54 + return (T) provider;
  55 + }
  56 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.storage;
  6 +
  7 +/**
  8 + * sp保存基类<BR>
  9 + *
  10 + * @author zhangbo
  11 + * @version [V1.0.0, 2020/8/11]
  12 + * @since V1.0.0
  13 + */
  14 +public class ConfigBase {
  15 + private String mFileName = "default_sp_file";
  16 +
  17 + public ConfigBase(String fileName) {
  18 + mFileName = fileName;
  19 + }
  20 +
  21 + private String getConfigName() {
  22 + return this.mFileName;
  23 + }
  24 +
  25 + public void put(String key, String value) {
  26 + MemStoreUtils.put(this.getConfigName(), key, value);
  27 + }
  28 +
  29 + public void put(String key, int value) {
  30 + MemStoreUtils.put(this.getConfigName(), key, value);
  31 + }
  32 +
  33 + public void put(String key, long value) {
  34 + MemStoreUtils.put(this.getConfigName(), key, value);
  35 + }
  36 +
  37 + public void put(String key, double value) {
  38 + MemStoreUtils.put(this.getConfigName(), key, value);
  39 + }
  40 +
  41 + public void put(String key, float value) {
  42 + MemStoreUtils.put(this.getConfigName(), key, value);
  43 + }
  44 +
  45 + public void put(String key, boolean value) {
  46 + MemStoreUtils.put(this.getConfigName(), key, value);
  47 + }
  48 +
  49 + public void put(String key, Object value) {
  50 + MemStoreUtils.put(this.getConfigName(), key, value);
  51 + }
  52 +
  53 + public void remove(String key) {
  54 + MemStoreUtils.remove(this.getConfigName(), key);
  55 + }
  56 +
  57 + public void removeWithSP(String key) {
  58 + MemStoreUtils.remove(this.getConfigName(), key);
  59 + SpStoreUtils.remove(this.getConfigName(), key);
  60 + }
  61 +
  62 + public Object getObj(String key) {
  63 + return MemStoreUtils.getObj(this.getConfigName(), key);
  64 + }
  65 +
  66 + public String getStringWithSP(String key) {
  67 + return this.getStringWithSP(key, (String) null);
  68 + }
  69 +
  70 + public int getIntWithSP(String key) {
  71 + return this.getIntWithSP(key, -2147483648);
  72 + }
  73 +
  74 + public long getLongWithSP(String key) {
  75 + return this.getLongWithSP(key, -9223372036854775808L);
  76 + }
  77 +
  78 + public float getFloatWithSP(String key) {
  79 + return this.getFloatWithSP(key, 1.4E-45F);
  80 + }
  81 +
  82 + public boolean getBooleanWithSP(String key) {
  83 + return this.getBooleanWithSP(key, false);
  84 + }
  85 +
  86 + public boolean getBoolean(String key) {
  87 + return MemStoreUtils.getBoolean(this.getConfigName(), key);
  88 + }
  89 +
  90 + public boolean getBoolean(String key, boolean defValue) {
  91 + return MemStoreUtils.isContains(this.getConfigName(), key) ? MemStoreUtils.getBoolean(this.getConfigName(), key)
  92 + : defValue;
  93 + }
  94 +
  95 + public void putWithSP(String key, String value) {
  96 + MemStoreUtils.put(this.getConfigName(), key, value);
  97 + SpStoreUtils.putString(this.getConfigName(), key, value);
  98 + }
  99 +
  100 + public void putWithSP(String key, int value) {
  101 + MemStoreUtils.put(this.getConfigName(), key, value);
  102 + SpStoreUtils.putInt(this.getConfigName(), key, value);
  103 + }
  104 +
  105 + public void putWithSP(String key, long value) {
  106 + MemStoreUtils.put(this.getConfigName(), key, value);
  107 + SpStoreUtils.putLong(this.getConfigName(), key, value);
  108 + }
  109 +
  110 + public void putWithSP(String key, float value) {
  111 + MemStoreUtils.put(this.getConfigName(), key, value);
  112 + SpStoreUtils.putFloat(this.getConfigName(), key, value);
  113 + }
  114 +
  115 + /**
  116 + * 保存布尔类型设置项
  117 + *
  118 + * @param key 保存key
  119 + * @param value 保存值
  120 + */
  121 + public void putWithSP(String key, boolean value) {
  122 + MemStoreUtils.put(getConfigName(), key, value);
  123 + SpStoreUtils.putBoolean(getConfigName(), key, value);
  124 + }
  125 +
  126 + public int getInt(String key) {
  127 + return MemStoreUtils.getInt(this.getConfigName(), key);
  128 + }
  129 +
  130 + public String getStringWithSP(String key, String defValue) {
  131 + if (MemStoreUtils.isContains(key)) {
  132 + return MemStoreUtils.getString(this.getConfigName(), key);
  133 + } else if (SpStoreUtils.isContains(this.getConfigName(), key)) {
  134 + String value = SpStoreUtils.getString(this.getConfigName(), key, defValue);
  135 + MemStoreUtils.put(this.getConfigName(), key, value);
  136 + return value;
  137 + } else {
  138 + return defValue;
  139 + }
  140 + }
  141 +
  142 + public int getIntWithSP(String key, int defValue) {
  143 + if (MemStoreUtils.isContains(this.getConfigName(), key)) {
  144 + return MemStoreUtils.getInt(this.getConfigName(), key);
  145 + } else if (SpStoreUtils.isContains(this.getConfigName(), key)) {
  146 + int value = SpStoreUtils.getInt(this.getConfigName(), key, defValue);
  147 + MemStoreUtils.put(this.getConfigName(), key, value);
  148 + return value;
  149 + } else {
  150 + return defValue;
  151 + }
  152 + }
  153 +
  154 + public long getLongWithSP(String key, long defValue) {
  155 + if (MemStoreUtils.isContains(this.getConfigName(), key)) {
  156 + return MemStoreUtils.getLong(this.getConfigName(), key);
  157 + } else if (SpStoreUtils.isContains(this.getConfigName(), key)) {
  158 + long value = SpStoreUtils.getLong(this.getConfigName(), key, defValue);
  159 + MemStoreUtils.put(this.getConfigName(), key, value);
  160 + return value;
  161 + } else {
  162 + return defValue;
  163 + }
  164 + }
  165 +
  166 + public float getFloatWithSP(String key, float defValue) {
  167 + if (MemStoreUtils.isContains(this.getConfigName(), key)) {
  168 + return MemStoreUtils.getFloat(this.getConfigName(), key);
  169 + } else if (SpStoreUtils.isContains(this.getConfigName(), key)) {
  170 + float value = SpStoreUtils.getFloat(this.getConfigName(), key, defValue);
  171 + MemStoreUtils.put(this.getConfigName(), key, value);
  172 + return value;
  173 + } else {
  174 + return defValue;
  175 + }
  176 + }
  177 +
  178 + /**
  179 + * 获取保存的布尔类型值
  180 + *
  181 + * @param key 键值
  182 + * @param defValue 默认值
  183 + */
  184 + public boolean getBooleanWithSP(String key, boolean defValue) {
  185 + if (MemStoreUtils.isContains(this.getConfigName(), key)) {
  186 + return MemStoreUtils.getBoolean(this.getConfigName(), key);
  187 + } else if (SpStoreUtils.isContains(this.getConfigName(), key)) {
  188 + boolean value = SpStoreUtils.getBoolean(this.getConfigName(), key, defValue);
  189 + MemStoreUtils.put(this.getConfigName(), key, value);
  190 + return value;
  191 + } else {
  192 + return defValue;
  193 + }
  194 + }
  195 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.storage;
  6 +
  7 +import java.util.HashMap;
  8 +
  9 +import com.wd.foundation.wdkitcore.tools.StringUtils;
  10 +
  11 +/**
  12 + * 内存存储类<BR>
  13 + *
  14 + * @author wangnaiwen
  15 + * @version [V1.0.0.0, 2020/5/28]
  16 + * @since V1.0.0.0
  17 + */
  18 +public class MemMgr {
  19 +
  20 + private static final MemMgr INSTANCE = new MemMgr();
  21 +
  22 + private static final String DEFAULT_MAP_GROUP = "default_map_group";
  23 +
  24 + /**
  25 + * 缓存数据容器
  26 + */
  27 + private HashMap<String, Object> mMemHashMapGroup = new HashMap<>();
  28 +
  29 + /**
  30 + * 锁
  31 + */
  32 + private final byte[] lock = new byte[0];
  33 +
  34 + private MemMgr() {
  35 +
  36 + }
  37 +
  38 + protected static MemMgr getInstance() {
  39 + return INSTANCE;
  40 + }
  41 +
  42 + public boolean isContains(String key) {
  43 + return this.isContains((String) null, key);
  44 + }
  45 +
  46 + public boolean isContains(String mapName, String key) {
  47 + if (StringUtils.isEmpty(key)) {
  48 + return false;
  49 + } else {
  50 + synchronized (this.lock) {
  51 + HashMap<String, Object> map = this.getHashMapGroup(mapName);
  52 + return map.containsKey(key);
  53 + }
  54 + }
  55 + }
  56 +
  57 + protected void put(String key, Object value) {
  58 + put(DEFAULT_MAP_GROUP, key, value);
  59 + }
  60 +
  61 + protected void put(String mapGroupName, String key, Object value) {
  62 + synchronized (lock) {
  63 + getHashMapGroup(mapGroupName).put(key, value);
  64 + }
  65 + }
  66 +
  67 + protected int getInt(String key) {
  68 + return getInt(DEFAULT_MAP_GROUP, key);
  69 + }
  70 +
  71 + protected int getInt(String mapGroupName, String key) {
  72 + synchronized (lock) {
  73 + Object object = get(mapGroupName, key);
  74 + if (object instanceof Integer) {
  75 + return (Integer) object;
  76 + }
  77 + return -1;
  78 + }
  79 + }
  80 +
  81 + protected Long getLong(String key) {
  82 + return getLong(DEFAULT_MAP_GROUP, key);
  83 + }
  84 +
  85 + protected Long getLong(String mapGroupName, String key) {
  86 + synchronized (lock) {
  87 + Object object = get(mapGroupName, key);
  88 + if (object instanceof Long) {
  89 + return (Long) object;
  90 + }
  91 + return Long.MIN_VALUE;
  92 + }
  93 + }
  94 +
  95 + protected String getString(String key) {
  96 + return getString(DEFAULT_MAP_GROUP, key);
  97 + }
  98 +
  99 + protected String getString(String mapGroupName, String key) {
  100 + synchronized (lock) {
  101 + Object object = get(mapGroupName, key);
  102 + if (object instanceof String) {
  103 + return (String) object;
  104 + }
  105 + return null;
  106 + }
  107 + }
  108 +
  109 + protected Float getFloat(String key) {
  110 + return getFloat(DEFAULT_MAP_GROUP, key);
  111 + }
  112 +
  113 + protected Float getFloat(String mapGroupName, String key) {
  114 + synchronized (lock) {
  115 + Object object = get(mapGroupName, key);
  116 + if (object instanceof Float) {
  117 + return (Float) object;
  118 + }
  119 + return Float.MIN_VALUE;
  120 + }
  121 + }
  122 +
  123 + protected Double getDouble(String key) {
  124 + return getDouble(DEFAULT_MAP_GROUP, key);
  125 + }
  126 +
  127 + protected Double getDouble(String mapGroupName, String key) {
  128 + synchronized (lock) {
  129 + Object object = get(mapGroupName, key);
  130 + if (object instanceof Double) {
  131 + return (Double) object;
  132 + }
  133 + return Double.MIN_VALUE;
  134 + }
  135 + }
  136 +
  137 + public boolean getBoolean(String key) {
  138 + return this.getBoolean((String) null, key);
  139 + }
  140 +
  141 + public boolean getBoolean(String mapName, String key) {
  142 + Object value = this.getObj(mapName, key);
  143 + if (null == value) {
  144 + return false;
  145 + } else if (value instanceof Boolean) {
  146 + return (Boolean) value;
  147 + } else if (value instanceof String) {
  148 + try {
  149 + return Boolean.parseBoolean((String) value);
  150 + } catch (Exception var5) {
  151 + return false;
  152 + }
  153 + } else {
  154 + return false;
  155 + }
  156 + }
  157 +
  158 + public Object getObj(String key) {
  159 + return this.getObj((String) null, key);
  160 + }
  161 +
  162 + public Object getObj(String mapName, String key) {
  163 + if (StringUtils.isEmpty(key)) {
  164 + return null;
  165 + } else {
  166 + synchronized (this.lock) {
  167 + HashMap<String, Object> map = getHashMapGroup(mapName);
  168 + return map.get(key);
  169 + }
  170 + }
  171 + }
  172 +
  173 + protected Object get(String key) {
  174 + return get(DEFAULT_MAP_GROUP, key);
  175 + }
  176 +
  177 + protected Object get(String mapGroupName, String key) {
  178 + synchronized (lock) {
  179 + return getHashMapGroup(mapGroupName).get(key);
  180 + }
  181 + }
  182 +
  183 + protected void clear(String mapGroupName) {
  184 + synchronized (lock) {
  185 + getHashMapGroup(mapGroupName).clear();
  186 + }
  187 + }
  188 +
  189 + protected void remove(String key) {
  190 + remove(DEFAULT_MAP_GROUP, key);
  191 + }
  192 +
  193 + protected void remove(String mapGroupName, String key) {
  194 + synchronized (lock) {
  195 + getHashMapGroup(mapGroupName).remove(key);
  196 + }
  197 + }
  198 +
  199 + private HashMap<String, Object> getHashMapGroup(String groupName) {
  200 + Object object = mMemHashMapGroup.get(groupName);
  201 + if (object == null) {
  202 + return createMapGroup(groupName);
  203 + }
  204 + return (HashMap<String, Object>) object;
  205 + }
  206 +
  207 + private HashMap<String, Object> createMapGroup(String hashMapName) {
  208 + HashMap<String, Object> hashMap = new HashMap<>();
  209 + mMemHashMapGroup.put(hashMapName, hashMap);
  210 + return hashMap;
  211 + }
  212 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.storage;
  6 +
  7 +/**
  8 + * 内存存储工具类BR>
  9 + *
  10 + * @author wangnaiwen
  11 + * @version [V1.0.0.0, 2020/5/28]
  12 + * @since V1.0.0.0
  13 + */
  14 +public final class MemStoreUtils {
  15 + /**
  16 + * 存储
  17 + *
  18 + * @param key 键值
  19 + * @param value 存储值
  20 + */
  21 + public static void put(String key, Object value) {
  22 + MemMgr.getInstance().put(key, value);
  23 + }
  24 +
  25 + /**
  26 + * 存储
  27 + *
  28 + * @param mapGroupName 组名
  29 + * @param key 键值
  30 + * @param value 存储值
  31 + */
  32 + public static void put(String mapGroupName, String key, Object value) {
  33 + MemMgr.getInstance().put(mapGroupName, key, value);
  34 + }
  35 +
  36 + public static Object getObj(String key) {
  37 + return MemMgr.getInstance().getObj(key);
  38 + }
  39 +
  40 + public static Object getObj(String mapName, String key) {
  41 + return MemMgr.getInstance().getObj(mapName, key);
  42 + }
  43 +
  44 + /**
  45 + * 获取数据
  46 + *
  47 + * @param key 键值
  48 + * @return 存储值
  49 + */
  50 + public static int getInt(String key) {
  51 + return MemMgr.getInstance().getInt(key);
  52 + }
  53 +
  54 + /**
  55 + * 获取数据
  56 + *
  57 + * @param mapGroupName 组名
  58 + * @param key 键值
  59 + * @return 存储值
  60 + */
  61 + public static int getInt(String mapGroupName, String key) {
  62 + return MemMgr.getInstance().getInt(mapGroupName, key);
  63 + }
  64 +
  65 + /**
  66 + * 获取数据
  67 + *
  68 + * @param key 键值
  69 + * @return 存储值
  70 + */
  71 + public static Long getLong(String key) {
  72 + return MemMgr.getInstance().getLong(key);
  73 + }
  74 +
  75 + /**
  76 + * 获取数据
  77 + *
  78 + * @param mapGroupName 组名
  79 + * @param key 键值
  80 + * @return 存储值
  81 + */
  82 + public static Long getLong(String mapGroupName, String key) {
  83 + return MemMgr.getInstance().getLong(mapGroupName, key);
  84 + }
  85 +
  86 + /**
  87 + * 获取数据
  88 + *
  89 + * @param key 键值
  90 + * @return 存储值
  91 + */
  92 + public static String getString(String key) {
  93 + return MemMgr.getInstance().getString(key);
  94 + }
  95 +
  96 + /**
  97 + * 获取数据
  98 + *
  99 + * @param mapGroupName 组名
  100 + * @param key 键值
  101 + * @return 存储值
  102 + */
  103 + public static String getString(String mapGroupName, String key) {
  104 + return MemMgr.getInstance().getString(mapGroupName, key);
  105 + }
  106 +
  107 + /**
  108 + * 获取数据
  109 + *
  110 + * @param key 键值
  111 + * @return 存储值
  112 + */
  113 + public static Float getFloat(String key) {
  114 + return MemMgr.getInstance().getFloat(key);
  115 + }
  116 +
  117 + /**
  118 + * 获取数据
  119 + *
  120 + * @param mapGroupName 组名
  121 + * @param key 键值
  122 + * @return 存储值
  123 + */
  124 + public static Float getFloat(String mapGroupName, String key) {
  125 + return MemMgr.getInstance().getFloat(mapGroupName, key);
  126 + }
  127 +
  128 + /**
  129 + * 获取数据
  130 + *
  131 + * @param key 键值
  132 + * @return 存储值
  133 + */
  134 + public static Double getDouble(String key) {
  135 + return MemMgr.getInstance().getDouble(key);
  136 + }
  137 +
  138 + /**
  139 + * 获取数据
  140 + *
  141 + * @param mapGroupName 组名
  142 + * @param key 键值
  143 + * @return 存储值
  144 + */
  145 + public static Double getDouble(String mapGroupName, String key) {
  146 + return MemMgr.getInstance().getDouble(mapGroupName, key);
  147 + }
  148 +
  149 + public static boolean getBoolean(String key) {
  150 + return MemMgr.getInstance().getBoolean(key);
  151 + }
  152 +
  153 + public static boolean getBoolean(String mapName, String key) {
  154 + return MemMgr.getInstance().getBoolean(mapName, key);
  155 + }
  156 +
  157 + /**
  158 + * 清除某一组数据
  159 + *
  160 + * @param mapGroupName 组名
  161 + */
  162 + public static void clear(String mapGroupName) {
  163 + MemMgr.getInstance().clear(mapGroupName);
  164 + }
  165 +
  166 + /**
  167 + * 移除某一个数据
  168 + *
  169 + * @param key 键值
  170 + */
  171 + public static void remove(String key) {
  172 + MemMgr.getInstance().remove(key);
  173 + }
  174 +
  175 + /**
  176 + * 移除某一个数据
  177 + *
  178 + * @param mapGroupName 组名
  179 + * @param key 键值
  180 + */
  181 + public static void remove(String mapGroupName, String key) {
  182 + MemMgr.getInstance().remove(mapGroupName, key);
  183 + }
  184 +
  185 + public static boolean isContains(String key) {
  186 + return MemMgr.getInstance().isContains(key);
  187 + }
  188 +
  189 + /**
  190 + * 是否包含
  191 + *
  192 + * @param key 键值
  193 + */
  194 + public static boolean isContains(String mapName, String key) {
  195 + return MemMgr.getInstance().isContains(mapName, key);
  196 + }
  197 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.storage;
  6 +
  7 +import android.content.Context;
  8 +import android.content.SharedPreferences;
  9 +
  10 +import com.wd.foundation.wdkitcore.tools.AppContext;
  11 +
  12 +/**
  13 + * SP 存储管理类<BR>
  14 + *
  15 + * @author wangnaiwen
  16 + * @version [V1.0.0.0, 2020/4/7]
  17 + * @since V1.0.0.0
  18 + */
  19 +public class SpMgr {
  20 +
  21 + private static final String DEFAULT_SP_NAME = "default_sp_name";
  22 +
  23 + private static SpMgr INSTANCE = new SpMgr();
  24 +
  25 + private SpMgr() {
  26 +
  27 + }
  28 +
  29 + protected static SpMgr getInstance() {
  30 + return INSTANCE;
  31 + }
  32 +
  33 + protected boolean isContains(String key) {
  34 + return isContains(DEFAULT_SP_NAME, key);
  35 + }
  36 +
  37 + protected boolean isContains(String spName, String key) {
  38 + SharedPreferences sp = getSp(spName);
  39 + return sp != null && sp.contains(key);
  40 + }
  41 +
  42 + protected void putString(String key, String value) {
  43 + putString(DEFAULT_SP_NAME, key, value);
  44 + }
  45 +
  46 + protected void putString(String spName, String key, String value) {
  47 + SharedPreferences sp = getSp(spName);
  48 + if (sp == null) {
  49 + return;
  50 + }
  51 + SharedPreferences.Editor editor = sp.edit();
  52 + editor.putString(key, value);
  53 + editor.apply();
  54 + }
  55 +
  56 + protected void putInt(String key, int value) {
  57 + putInt(DEFAULT_SP_NAME, key, value);
  58 + }
  59 +
  60 + protected void putInt(String spName, String key, int value) {
  61 + SharedPreferences sp = getSp(spName);
  62 + if (sp == null) {
  63 + return;
  64 + }
  65 + SharedPreferences.Editor editor = sp.edit();
  66 + editor.putInt(key, value);
  67 + editor.apply();
  68 + }
  69 +
  70 + protected void putLong(String key, long value) {
  71 + putLong(DEFAULT_SP_NAME, key, value);
  72 + }
  73 +
  74 + protected void putLong(String spName, String key, long value) {
  75 + SharedPreferences sp = getSp(spName);
  76 + if (sp == null) {
  77 + return;
  78 + }
  79 + SharedPreferences.Editor editor = sp.edit();
  80 + editor.putLong(key, value);
  81 + editor.apply();
  82 + }
  83 +
  84 + protected void putFloat(String key, float value) {
  85 + putFloat(DEFAULT_SP_NAME, key, value);
  86 + }
  87 +
  88 + protected void putFloat(String spName, String key, float value) {
  89 + SharedPreferences sp = getSp(spName);
  90 + if (sp == null) {
  91 + return;
  92 + }
  93 + SharedPreferences.Editor editor = sp.edit();
  94 + editor.putFloat(key, value);
  95 + editor.apply();
  96 + }
  97 +
  98 + protected void putBoolean(String key, boolean value) {
  99 + putBoolean(DEFAULT_SP_NAME, key, value);
  100 + }
  101 +
  102 + protected void putBoolean(String spName, String key, boolean value) {
  103 + SharedPreferences sp = getSp(spName);
  104 + if (sp == null) {
  105 + return;
  106 + }
  107 + SharedPreferences.Editor editor = sp.edit();
  108 + editor.putBoolean(key, value);
  109 + editor.apply();
  110 + }
  111 +
  112 + protected void remove(String key) {
  113 + remove(DEFAULT_SP_NAME, key);
  114 + }
  115 +
  116 + protected void remove(String spName, String key) {
  117 + SharedPreferences sp = getSp(spName);
  118 + if (sp == null) {
  119 + return;
  120 + }
  121 + SharedPreferences.Editor editor = sp.edit();
  122 + editor.remove(key);
  123 + editor.apply();
  124 + }
  125 +
  126 + protected int getInt(String key) {
  127 + return getInt(DEFAULT_SP_NAME, key);
  128 + }
  129 +
  130 + protected int getInt(String spName, String key) {
  131 + SharedPreferences sp = getSp(spName);
  132 + if (sp == null) {
  133 + return 0;
  134 + }
  135 + return sp.getInt(key, 0);
  136 + }
  137 +
  138 + protected long getLong(String key) {
  139 + return getLong(DEFAULT_SP_NAME, key);
  140 + }
  141 +
  142 + protected long getLong(String spName, String key) {
  143 + SharedPreferences sp = getSp(spName);
  144 + if (sp == null) {
  145 + return 0;
  146 + }
  147 + return sp.getLong(key, 0);
  148 + }
  149 +
  150 + protected float getFloat(String key) {
  151 + return getFloat(DEFAULT_SP_NAME, key);
  152 + }
  153 +
  154 + protected float getFloat(String spName, String key) {
  155 + SharedPreferences sp = getSp(spName);
  156 + if (sp == null) {
  157 + return 0.f;
  158 + }
  159 + return sp.getFloat(key, 0.f);
  160 + }
  161 +
  162 + protected boolean getBoolean(String key) {
  163 + return getBoolean(DEFAULT_SP_NAME, key);
  164 + }
  165 +
  166 + protected boolean getBoolean(String spName, String key) {
  167 + SharedPreferences sp = getSp(spName);
  168 + if (sp == null) {
  169 + return false;
  170 + }
  171 + return sp.getBoolean(key, false);
  172 + }
  173 +
  174 + protected String getString(String key) {
  175 + return getString(DEFAULT_SP_NAME, key);
  176 + }
  177 +
  178 + protected String getString(String spName, String key) {
  179 + SharedPreferences sp = getSp(spName);
  180 + if (sp == null) {
  181 + return "";
  182 + }
  183 + return sp.getString(key, "");
  184 + }
  185 +
  186 + protected String getString(String spName, String key, String defValue) {
  187 + SharedPreferences sp = getSp(spName);
  188 + return null == sp ? null : sp.getString(key, defValue);
  189 + }
  190 +
  191 + protected boolean getBoolean(String spName, String key, boolean defValue) {
  192 + SharedPreferences sp = getSp(spName);
  193 + return null == sp ? defValue : sp.getBoolean(key, defValue);
  194 + }
  195 +
  196 + protected long getLong(String spName, String key, long defValue) {
  197 + SharedPreferences sp = getSp(spName);
  198 + return null == sp ? defValue : sp.getLong(key, defValue);
  199 + }
  200 +
  201 + protected int getInt(String spName, String key, int defValue) {
  202 + SharedPreferences sp = getSp(spName);
  203 + return null == sp ? defValue : sp.getInt(key, defValue);
  204 + }
  205 +
  206 + protected float getFloat(String spName, String key, float defValue) {
  207 + SharedPreferences sp = getSp(spName);
  208 + return null == sp ? defValue : sp.getFloat(key, defValue);
  209 + }
  210 +
  211 + private SharedPreferences getSp(String spName) {
  212 + Context context = AppContext.getContext();
  213 + if (context == null) {
  214 + return null;
  215 + }
  216 + return context.getSharedPreferences(spName, Context.MODE_PRIVATE);
  217 + }
  218 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.storage;
  6 +
  7 +import com.wd.base.log.Logger;
  8 +
  9 +/**
  10 + * sp 存储<BR>
  11 + *
  12 + * @author wangnaiwen
  13 + * @version [V1.0.0.0, 2020/4/7]
  14 + * @since V1.0.0.0
  15 + */
  16 +public class SpStoreUtils {
  17 + public static boolean isContains(String spName, String key) {
  18 + return SpMgr.getInstance().isContains(spName, key);
  19 + }
  20 +
  21 + public static void putInt(String key, int value) {
  22 + SpMgr.getInstance().putInt(key, value);
  23 + }
  24 +
  25 + public static void putInt(String spName, String key, int value) {
  26 + SpMgr.getInstance().putInt(spName, key, value);
  27 + }
  28 +
  29 + public static void putLong(String key, long value) {
  30 + SpMgr.getInstance().putLong(key, value);
  31 + }
  32 +
  33 + public static void putLong(String spName, String key, long value) {
  34 + SpMgr.getInstance().putLong(spName, key, value);
  35 + }
  36 +
  37 + public static void putString(String key, String value) {
  38 + SpMgr.getInstance().putString(key, value);
  39 + }
  40 +
  41 + public static void putString(String spName, String key, String value) {
  42 + SpMgr.getInstance().putString(spName, key, value);
  43 + }
  44 +
  45 + public static void putBoolean(String key, boolean value) {
  46 + SpMgr.getInstance().putBoolean(key, value);
  47 + }
  48 +
  49 + public static void putBoolean(String spName, String key, boolean value) {
  50 + SpMgr.getInstance().putBoolean(spName, key, value);
  51 + }
  52 +
  53 + public static void putFloat(String key, float value) {
  54 + SpMgr.getInstance().putFloat(key, value);
  55 + }
  56 +
  57 + public static void putFloat(String spName, String key, float value) {
  58 + SpMgr.getInstance().putFloat(spName, key, value);
  59 + }
  60 +
  61 + public static void remove(String key) {
  62 + SpMgr.getInstance().remove(key);
  63 + }
  64 +
  65 + public static void remove(String spName, String key) {
  66 + SpMgr.getInstance().remove(spName, key);
  67 + }
  68 +
  69 + public static int getInt(String key) {
  70 + return SpMgr.getInstance().getInt(key);
  71 + }
  72 +
  73 + public static int getInt(String spName, String key) {
  74 + return SpMgr.getInstance().getInt(spName, key);
  75 + }
  76 +
  77 + public static int getInt(String spName, String key, int defValue) {
  78 + String value = null;
  79 +
  80 + try {
  81 + value = SpMgr.getInstance().getString(spName, key, String.valueOf(defValue));
  82 + return Integer.parseInt(value);
  83 + } catch (ClassCastException var5) {
  84 + return getIntInSP(spName, key, defValue);
  85 + } catch (Exception var6) {
  86 + Logger.d("SPStoreApi", "getInt failed, invalid value. <" + spName + ", " + key + ", " + value + ">");
  87 + return defValue;
  88 + }
  89 + }
  90 +
  91 + public static long getLong(String key) {
  92 + return SpMgr.getInstance().getLong(key);
  93 + }
  94 +
  95 + public static long getLong(String spName, String key) {
  96 + return SpMgr.getInstance().getInt(spName, key);
  97 + }
  98 +
  99 + public static long getLong(String spName, String key, long defValue) {
  100 + String value = null;
  101 +
  102 + try {
  103 + value = SpMgr.getInstance().getString(spName, key, String.valueOf(defValue));
  104 + return Long.parseLong(value);
  105 + } catch (ClassCastException var6) {
  106 + return getLongInSP(spName, key, defValue);
  107 + } catch (Exception var7) {
  108 + Logger.d("SPStoreApi", "getLong failed, invalid value. <" + spName + ", " + key + ", " + value + ">");
  109 + return defValue;
  110 + }
  111 + }
  112 +
  113 + public static boolean getBoolean(String key) {
  114 + return SpMgr.getInstance().getBoolean(key);
  115 + }
  116 +
  117 + public static boolean getBoolean(String spName, String key) {
  118 + return SpMgr.getInstance().getBoolean(spName, key);
  119 + }
  120 +
  121 + public static boolean getBoolean(String spName, String key, boolean defValue) {
  122 + String value = null;
  123 +
  124 + try {
  125 + value = SpMgr.getInstance().getString(spName, key, String.valueOf(defValue));
  126 + return Boolean.valueOf(value);
  127 + } catch (ClassCastException var5) {
  128 + return getBooleanInSP(spName, key, defValue);
  129 + } catch (Exception var6) {
  130 + Logger.d("SPStoreApi", "getBoolean failed, invalid value. <" + spName + ", " + key + ", " + value + ">");
  131 + return defValue;
  132 + }
  133 + }
  134 +
  135 + public static String getString(String key) {
  136 + return SpMgr.getInstance().getString(key);
  137 + }
  138 +
  139 + public static String getString(String spName, String key) {
  140 + return SpMgr.getInstance().getString(spName, key);
  141 + }
  142 +
  143 + public static String getString(String spName, String key, String defValue) {
  144 + return getStringInSP(spName, key, defValue);
  145 + }
  146 +
  147 + public static float getFloat(String key) {
  148 + return SpMgr.getInstance().getFloat(key);
  149 + }
  150 +
  151 + public static float getFloat(String spName, String key) {
  152 + return SpMgr.getInstance().getFloat(spName, key);
  153 + }
  154 +
  155 + public static float getFloat(String spName, String key, float defValue) {
  156 + String value = null;
  157 +
  158 + try {
  159 + value = SpMgr.getInstance().getString(spName, key, String.valueOf(defValue));
  160 + return Float.valueOf(value);
  161 + } catch (ClassCastException var5) {
  162 + return getFloatInSP(spName, key, defValue);
  163 + } catch (Exception var6) {
  164 + Logger.d("SPStoreApi", "getFloat failed, invalid value. <" + spName + ", " + key + ", " + value + ">");
  165 + return defValue;
  166 + }
  167 + }
  168 +
  169 + private static int getIntInSP(String spName, String key, int defValue) {
  170 + try {
  171 + return SpMgr.getInstance().getInt(spName, key, defValue);
  172 + } catch (Exception var4) {
  173 + Logger.d("SPStoreApi", "getIntInSp failed, invalid value. <" + spName + ", " + key + ">");
  174 + return defValue;
  175 + }
  176 + }
  177 +
  178 + private static long getLongInSP(String spName, String key, long defValue) {
  179 + try {
  180 + return SpMgr.getInstance().getLong(spName, key, defValue);
  181 + } catch (Exception var5) {
  182 + Logger.d("SPStoreApi", "getLongInSP failed, invalid value. <" + spName + ", " + key + ">");
  183 + return defValue;
  184 + }
  185 + }
  186 +
  187 + private static boolean getBooleanInSP(String spName, String key, boolean defValue) {
  188 + try {
  189 + return SpMgr.getInstance().getBoolean(spName, key, defValue);
  190 + } catch (Exception var4) {
  191 + Logger.d("SPStoreApi", "getBooleanInSP failed, invalid value. <" + spName + ", " + key + ">");
  192 + return defValue;
  193 + }
  194 + }
  195 +
  196 + private static float getFloatInSP(String spName, String key, float defValue) {
  197 + try {
  198 + return SpMgr.getInstance().getFloat(spName, key, defValue);
  199 + } catch (Exception var4) {
  200 + Logger.d("SPStoreApi", "getFloatInSP failed, invalid value. <" + spName + ", " + key + ">");
  201 + return defValue;
  202 + }
  203 + }
  204 +
  205 + private static String getStringInSP(String spName, String key, String defValue) {
  206 + try {
  207 + return SpMgr.getInstance().getString(spName, key, defValue);
  208 + } catch (Exception var4) {
  209 + Logger.d("SPStoreApi", "getStringInSP failed, invalid value. <" + spName + ", " + key + ">");
  210 + return defValue;
  211 + }
  212 + }
  213 +}
@@ -25,6 +25,11 @@ public final class AppContext { @@ -25,6 +25,11 @@ public final class AppContext {
25 25
26 public static boolean mPause = false; 26 public static boolean mPause = false;
27 27
  28 + /**
  29 + * 开发环境、正式环境
  30 + */
  31 + public static boolean DEBUG;
  32 +
28 public AppContext() { 33 public AppContext() {
29 } 34 }
30 35
@@ -32,7 +37,8 @@ public final class AppContext { @@ -32,7 +37,8 @@ public final class AppContext {
32 37
33 public static HashMap<String, Boolean> mSet = new HashMap<>(); 38 public static HashMap<String, Boolean> mSet = new HashMap<>();
34 39
35 - public static void init(Context context) { 40 + public static void init(Context context, boolean debug) {
  41 + DEBUG = debug;
36 mContext = context; 42 mContext = context;
37 } 43 }
38 44
  1 +package com.wd.foundation.wdkitcore.tools;
  2 +
  3 +
  4 +import java.io.BufferedReader;
  5 +import java.io.ByteArrayOutputStream;
  6 +import java.io.IOException;
  7 +import java.io.InputStream;
  8 +import java.io.InputStreamReader;
  9 +
  10 +/**
  11 + * 读取本地assert 工具类
  12 + *
  13 + * @author lvjinhui
  14 + */
  15 +public class AssertUtils {
  16 +
  17 + public static String readJsonFile(String file){
  18 + StringBuilder newstringBuilder = new StringBuilder();
  19 + try {
  20 + InputStream inputStream = AppContext.getContext().getResources().getAssets().open(file);
  21 + InputStreamReader isr = new InputStreamReader(inputStream);
  22 + BufferedReader reader = new BufferedReader(isr);
  23 + String jsonLine;
  24 + while ((jsonLine = reader.readLine()) != null) {
  25 + newstringBuilder.append(jsonLine);
  26 + }
  27 + reader.close();
  28 + isr.close();
  29 + inputStream.close();
  30 + } catch (IOException e) {
  31 + e.printStackTrace();
  32 + }
  33 + String data = newstringBuilder.toString();
  34 + return data;
  35 + }
  36 +
  37 + public static String getLocalGroupJson(String fileName) {
  38 + try {
  39 + InputStream is = AppContext.getContext().getAssets().open(fileName);
  40 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
  41 + int len = -1;
  42 + byte[] buffer = new byte[1024];
  43 + while ((len = is.read(buffer)) != -1) {
  44 + baos.write(buffer, 0, len);
  45 + }
  46 + String rel = baos.toString();
  47 + is.close();
  48 + return rel;
  49 + } catch (IOException e) {
  50 + e.printStackTrace();
  51 + }
  52 + return "";
  53 + }
  54 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.tools;
  6 +
  7 +import java.io.Closeable;
  8 +import java.io.IOException;
  9 +import java.net.HttpURLConnection;
  10 +
  11 +import android.database.Cursor;
  12 +import android.database.sqlite.SQLiteDatabase;
  13 +
  14 +import com.wd.base.log.Logger;
  15 +
  16 +/**
  17 + * 数据关闭工具类<BR>
  18 + *
  19 + * @author wangnaiwen
  20 + * @version [V1.0.0.0, 2020/5/16]
  21 + * @since V1.0.0.0
  22 + */
  23 +public class CloseUtils {
  24 + private static final String TAG = "CloseUtils";
  25 +
  26 + private CloseUtils() {
  27 + }
  28 +
  29 + /**
  30 + * 关闭索引
  31 + *
  32 + * @param cursor 索引
  33 + */
  34 + public static void close(Cursor cursor) {
  35 + if (null == cursor) {
  36 + Logger.t(TAG).e("cursor is empty");
  37 + } else {
  38 + try {
  39 + cursor.close();
  40 + } catch (Exception var2) {
  41 + Logger.t(TAG).e("close cursor has exception:", var2);
  42 + }
  43 +
  44 + }
  45 + }
  46 +
  47 + /**
  48 + * 关闭数据库
  49 + *
  50 + * @param db 数据库
  51 + */
  52 + public static void close(SQLiteDatabase db) {
  53 + if (null != db) {
  54 + try {
  55 + db.close();
  56 + } catch (Exception var2) {
  57 + Logger.t(TAG).e("" + var2);
  58 + }
  59 +
  60 + }
  61 + }
  62 +
  63 + /**
  64 + * 关闭资源
  65 + *
  66 + * @param closed 可关闭的资源
  67 + */
  68 + public static void close(Closeable closed) {
  69 + if (null != closed) {
  70 + try {
  71 + closed.close();
  72 + } catch (IOException var2) {
  73 + Logger.t(TAG).e("" + var2);
  74 + } catch (Exception var3) {
  75 + Logger.t(TAG).e("" + var3);
  76 + }
  77 +
  78 + }
  79 + }
  80 +
  81 + /**
  82 + * 关闭 http 连接
  83 + *
  84 + * @param conn 连接
  85 + */
  86 + public static void close(HttpURLConnection conn) {
  87 + if (null != conn) {
  88 + try {
  89 + conn.disconnect();
  90 + } catch (Exception var2) {
  91 + Logger.t(TAG).e("" + var2);
  92 + }
  93 +
  94 + }
  95 + }
  96 +}
1 -/*  
2 - * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.  
3 - */  
4 -  
5 -package com.wd.foundation.wdkitcore.tools;  
6 -  
7 -import android.content.Context;  
8 -import android.os.Build;  
9 -  
10 -/**  
11 - * 设备相关工具类<BR>  
12 - *  
13 - * @author wangnaiwen  
14 - * @version [V1.0.0.0, 2020/4/7]  
15 - * @since V1.0.0.0  
16 - */  
17 -public class DeviceUtils {  
18 -  
19 - /**  
20 - * 设备屏幕宽度  
21 - *  
22 - * @return 屏幕宽度  
23 - */  
24 - public static int getDeviceWidth() {  
25 - Context context = AppContext.getContext();  
26 - if (context == null) {  
27 - return 0;  
28 - }  
29 - return Math.min(context.getResources().getDisplayMetrics().widthPixels,  
30 - context.getResources().getDisplayMetrics().heightPixels);  
31 - }  
32 -  
33 - /**  
34 - * 设备屏幕高度  
35 - *  
36 - * @return 屏幕高度  
37 - */  
38 - public static int getDeviceHeight() {  
39 - Context context = AppContext.getContext();  
40 - if (context == null) {  
41 - return 0;  
42 - }  
43 - return Math.max(context.getResources().getDisplayMetrics().widthPixels,  
44 - context.getResources().getDisplayMetrics().heightPixels);  
45 - }  
46 -  
47 - /**  
48 - * 获得版本 Model  
49 - *  
50 - * @return 版本 Model  
51 - */  
52 - public static String getModel() {  
53 - return Build.MODEL;  
54 - }  
55 -}  
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.tools;
  6 +
  7 +import java.io.BufferedReader;
  8 +import java.io.File;
  9 +import java.io.FileInputStream;
  10 +import java.io.FileNotFoundException;
  11 +import java.io.FileOutputStream;
  12 +import java.io.IOException;
  13 +import java.io.InputStreamReader;
  14 +import java.nio.channels.FileChannel;
  15 +import java.util.Locale;
  16 +
  17 +import android.content.Context;
  18 +import android.content.res.AssetManager;
  19 +import android.text.TextUtils;
  20 +import android.webkit.MimeTypeMap;
  21 +
  22 +import com.wd.base.log.Logger;
  23 +
  24 +/**
  25 + * 文件操作工具类
  26 + *
  27 + * @author huweixiong
  28 + * @version [V1.0.0.1, 2020/8/27]
  29 + * @since V1.0.0.1
  30 + */
  31 +public class FileUtils {
  32 + private static final String TAG = "FileUtils";
  33 +
  34 + private FileUtils() {
  35 + }
  36 +
  37 + /**
  38 + * 判断文件是否存在,且不是空文件
  39 + *
  40 + * @param filePath 文件路径
  41 + * @return 文件是否存在
  42 + */
  43 + public static boolean isFileExists(String filePath) {
  44 + if (TextUtils.isEmpty(filePath)) {
  45 + return false;
  46 + } else {
  47 + try {
  48 + File f = new File(filePath);
  49 + return f.exists() && f.isFile() && f.length() > 0L;
  50 + } catch (Exception var2) {
  51 + Logger.t(TAG).e("isFileExists:", var2);
  52 + return false;
  53 + }
  54 + }
  55 + }
  56 +
  57 + /**
  58 + * 判断目录是否存在,且不是空目录
  59 + *
  60 + * @param folderPath 目录路径
  61 + * @return 目录是否存在
  62 + */
  63 + public static boolean isFolderExists(String folderPath) {
  64 + if (TextUtils.isEmpty(folderPath)) {
  65 + return false;
  66 + } else {
  67 + try {
  68 + File f = new File(folderPath);
  69 + boolean isFolderExist = f.exists() && f.isDirectory();
  70 + if (!isFolderExist) {
  71 + return false;
  72 + } else {
  73 + String[] files = f.list();
  74 + return files != null && files.length > 0;
  75 + }
  76 + } catch (Exception var4) {
  77 + Logger.t(TAG).e("isFolderExists:", var4);
  78 + return false;
  79 + }
  80 + }
  81 + }
  82 +
  83 + /**
  84 + * 删除文件
  85 + *
  86 + * @param path 文件路径
  87 + * @return 是否删除成功
  88 + */
  89 + public static boolean deleteFile(String path) {
  90 + boolean result = false;
  91 + if (!TextUtils.isEmpty(path)) {
  92 + File file = new File(path);
  93 + if (file.exists()) {
  94 + result = file.delete();
  95 + if (!result) {
  96 + Logger.t(TAG).w("delete file failed, file path=" + path);
  97 + }
  98 + }
  99 + }
  100 +
  101 + return result;
  102 + }
  103 +
  104 + /**
  105 + * 删除文件
  106 + *
  107 + * @param file 文件对象
  108 + * @return 是否删除成功
  109 + */
  110 + public static boolean deleteFile(File file) {
  111 + if (file != null && file.exists()) {
  112 + if (file.isFile()) {
  113 + boolean result = file.delete();
  114 + if (!result) {
  115 + Logger.t(TAG).w("delete file failed, file path=" + getCanonicalPath(file));
  116 + }
  117 +
  118 + return result;
  119 + } else {
  120 + File[] files = file.listFiles();
  121 + if (files != null && files.length > 0) {
  122 + int len = files.length;
  123 +
  124 + for (int i = 0; i < len; ++i) {
  125 + deleteFile(files[i]);
  126 + }
  127 + }
  128 +
  129 + return file.delete();
  130 + }
  131 + } else {
  132 + return true;
  133 + }
  134 + }
  135 +
  136 + /**
  137 + * 获取文件扩展名
  138 + *
  139 + * @param filename 文件路径
  140 + * @return 返回扩展名
  141 + */
  142 + public static String extension(String filename) {
  143 + if (TextUtils.isEmpty(filename)) {
  144 + return "";
  145 + } else {
  146 + int start = filename.lastIndexOf("/");
  147 + int stop = filename.lastIndexOf(".");
  148 + return stop >= start && stop < filename.length() - 1
  149 + ? StringUtils.cutString(filename, stop + 1, filename.length()) : "";
  150 + }
  151 + }
  152 +
  153 + /**
  154 + * 获取文件的MIME_type
  155 + *
  156 + * @param filename 文件路径
  157 + * @return 返回文件的MIME_type
  158 + */
  159 + public static String mimeType(String filename) {
  160 + String ext = extension(filename);
  161 + String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
  162 + return mime == null ? "*.*" : mime;
  163 + }
  164 +
  165 + /**
  166 + * 移动文件并修改文件名或修改文件
  167 + *
  168 + * @param newPath 新文件路径
  169 + * @param oldPath 旧文件路径
  170 + * @return 是否移动成功
  171 + */
  172 + public static boolean renameFile(String newPath, String oldPath) {
  173 + if (!TextUtils.isEmpty(newPath) && !TextUtils.isEmpty(oldPath)) {
  174 + File file = new File(oldPath);
  175 + Logger.t(TAG).d("renameFile:" + oldPath + " to " + newPath);
  176 + return file.renameTo(new File(newPath));
  177 + } else {
  178 + return false;
  179 + }
  180 + }
  181 +
  182 + /**
  183 + * 复制文件
  184 + *
  185 + * @param orgPath 原文件路径
  186 + * @param srcPath 新文件路径
  187 + * @return 是否复制文件成功
  188 + */
  189 + public static boolean copyFile(String orgPath, String srcPath) {
  190 + if (!TextUtils.isEmpty(orgPath) && !TextUtils.isEmpty(srcPath)) {
  191 + File from = new File(orgPath);
  192 + File to = new File(srcPath);
  193 + Logger.t(TAG).d("copyFile:" + orgPath + " to " + srcPath);
  194 + if (!from.exists()) {
  195 + Logger.t(TAG).w("copyFile from File isnot exists!");
  196 + return false;
  197 + }
  198 +
  199 + FileChannel input = null;
  200 + FileChannel output = null;
  201 +
  202 + try {
  203 + input = (new FileInputStream(from)).getChannel();
  204 + output = (new FileOutputStream(to)).getChannel();
  205 + output.transferFrom(input, 0L, input.size());
  206 + } catch (FileNotFoundException var11) {
  207 + Logger.t(TAG).e("" + var11);
  208 + } catch (IOException var12) {
  209 + Logger.t(TAG).e("" + var12);
  210 + } finally {
  211 + CloseUtils.close(input);
  212 + CloseUtils.close(output);
  213 + }
  214 + }
  215 +
  216 + return isFileExists(srcPath);
  217 + }
  218 +
  219 + /**
  220 + * 文件的绝对路径
  221 + *
  222 + * @param file 文件对象
  223 + * @return 返回文件的绝对路径
  224 + */
  225 + public static String getCanonicalPath(File file) {
  226 + if (null == file) {
  227 + return null;
  228 + } else {
  229 + try {
  230 + return file.getCanonicalPath();
  231 + } catch (IOException var2) {
  232 + Logger.t(TAG).w("CanonicalPath is not avaliable.");
  233 + return file.getAbsolutePath();
  234 + }
  235 + }
  236 + }
  237 +
  238 + /**
  239 + * 获取Assets目录下面文件内容,去掉头尾空字符串
  240 + *
  241 + * @param fileName 文件名称,相当Assets目录的文件名称
  242 + * @return 返回文件的绝对路径
  243 + */
  244 + public static String getJsonFromFile(Context mContext, String fileName) {
  245 + InputStreamReader ips = null;
  246 + BufferedReader br = null;
  247 + StringBuilder sb = new StringBuilder();
  248 + AssetManager am = mContext.getAssets();
  249 +
  250 + try {
  251 + ips = new InputStreamReader(am.open(fileName), "UTF-8");
  252 + br = new BufferedReader(ips);
  253 + String next = "";
  254 +
  255 + while (null != (next = br.readLine())) {
  256 + sb.append(next);
  257 + }
  258 + } catch (IOException var10) {
  259 + Logger.t(TAG).e("assets read exception", var10);
  260 + sb.delete(0, sb.length());
  261 + } finally {
  262 + CloseUtils.close(br);
  263 + CloseUtils.close(ips);
  264 + }
  265 +
  266 + return sb.toString().trim();
  267 + }
  268 +
  269 + public static boolean deleteFileInDataFileDir(String fileName) {
  270 + return AppContext.getContext().deleteFile(fileName);
  271 + }
  272 +
  273 + public static String mirrorDirection(String path, String dSign) {
  274 + return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == 1
  275 + ? path.replaceAll(dSign, "\u200f" + dSign) : path;
  276 + }
  277 +
  278 + public static void makeSureFullDirExist(File dir) {
  279 + if (!dir.exists() && !dir.mkdirs()) {
  280 + Logger.t(TAG).i("Create dir failed: " + getCanonicalPath(dir));
  281 + }
  282 +
  283 + }
  284 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.tools;
  6 +
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +import java.util.regex.Matcher;
  10 +import java.util.regex.Pattern;
  11 +
  12 +import com.alibaba.fastjson.JSON;
  13 +import com.alibaba.fastjson.JSONArray;
  14 +import com.alibaba.fastjson.JSONException;
  15 +import com.alibaba.fastjson.JSONObject;
  16 +import com.alibaba.fastjson.TypeReference;
  17 +import com.wd.base.log.Logger;
  18 +
  19 +/**
  20 + * JSON工具类<BR>
  21 + *
  22 + * @author zhengyin
  23 + * @version [V1.0.0.0, 2020/6/3]
  24 + * @since V1.0.0.0
  25 + */
  26 +public class JsonUtils {
  27 + private static final String TAG = "JsonUtils";
  28 +
  29 + /***
  30 + * 功能描述: object 转成json
  31 + *
  32 + * @param root root
  33 + * @return json字符串
  34 + */
  35 + public static String convertObjectToJson(Object root) {
  36 + String resultString = "";
  37 + try {
  38 + resultString = JSON.toJSONString(root);
  39 + } catch (Exception e) {
  40 + e.printStackTrace();
  41 + }
  42 + return resultString;
  43 + }
  44 +
  45 + /***
  46 + * 功能描述: json转成object(需要注意泛型类必须提供无参构造函数)
  47 + *
  48 + * @param json json字符串
  49 + * @param clazz 泛型类
  50 + * @return 泛型对象
  51 + */
  52 + public static <T> T convertJsonToObject(String json, Class<T> clazz) {
  53 + T object = null;
  54 + try {
  55 + object = JSON.parseObject(json, clazz);
  56 + } catch (Exception e) {
  57 + e.printStackTrace();
  58 + Logger.i(TAG, "ex:" + e.getMessage());
  59 + }
  60 + return object;
  61 + }
  62 +
  63 + /**
  64 + * 将json字串解析为JSONArray
  65 + *
  66 + * @param json json字符串
  67 + * @return JSONArray
  68 + */
  69 + public static JSONArray convertJsonArray(String json) throws JSONException {
  70 + if (StringUtils.isEmpty(json)) {
  71 + Logger.w(TAG, "convertJsonArray json is null");
  72 + return null;
  73 + }
  74 + return JSON.parseArray(json);
  75 + }
  76 +
  77 + /**
  78 + * 获取JSONArray
  79 + *
  80 + * @param jsonObject json数据对象
  81 + * @param key key
  82 + * @return JSONArray
  83 + */
  84 + public static JSONArray getJsonArray(JSONObject jsonObject, String key) throws JSONException {
  85 + if (jsonObject == null) {
  86 + return null;
  87 + }
  88 + if (!jsonObject.containsKey(key)) {
  89 + Logger.w(TAG, "getJsonArray no this key");
  90 + return null;
  91 + }
  92 + return jsonObject.getJSONArray(key);
  93 + }
  94 +
  95 + /**
  96 + * 功能描述:把JSON数据转换成jsonObject
  97 + *
  98 + * @param jsonData JSON数据
  99 + * @return
  100 + * @throws Exception
  101 + */
  102 + public static JSONObject convertJsonToJsonObject(String jsonData) throws Exception {
  103 + return JSON.parseObject(jsonData);
  104 + }
  105 +
  106 + /**
  107 + * 获取JSONObject
  108 + *
  109 + * @param jsonObject jsonObject
  110 + * @param key key
  111 + * @return JSONObject
  112 + */
  113 + public static JSONObject getJsonObject(JSONObject jsonObject, String key) throws JSONException {
  114 + if (jsonObject == null) {
  115 + return null;
  116 + }
  117 + if (!jsonObject.containsKey(key)) {
  118 + Logger.w(TAG, "getJsonObject no this key");
  119 + return null;
  120 + }
  121 + return jsonObject.getJSONObject(key);
  122 + }
  123 +
  124 + /**
  125 + * 获取指定位置的JSONObject
  126 + *
  127 + * @param jsonArray jsonArray
  128 + * @param index index
  129 + * @return JSONObject
  130 + */
  131 + public static JSONObject getJsonObject(JSONArray jsonArray, int index) throws JSONException {
  132 + if (jsonArray == null) {
  133 + return null;
  134 + }
  135 + if (jsonArray.size() < index) {
  136 + return null;
  137 + }
  138 + return jsonArray.getJSONObject(index);
  139 + }
  140 +
  141 + /**
  142 + * 功能描述:把JsonArray数据转换成泛型对象列表 (需要注意泛型类必须提供无参构造函数)
  143 + *
  144 + * @param jsonArrayString JsonArray字符串
  145 + * @param clazz 泛型类型
  146 + * @return 泛型列表
  147 + * @throws Exception
  148 + */
  149 + public static <T> List<T> convertJsonArrayToObjList(String jsonArrayString, Class<T> clazz) throws Exception {
  150 + return JSON.parseArray(jsonArrayString, clazz);
  151 + }
  152 +
  153 + /**
  154 + * 功能描述:把JSON字符串转换成较为复杂的java对象列表
  155 + *
  156 + * @param json JSON数据
  157 + * @return
  158 + * @throws Exception
  159 + */
  160 + public static List<Map<String, Object>> convertJsonToObjectMapList(String json) throws Exception {
  161 + return JSON.parseObject(json, new TypeReference<List<Map<String, Object>>>() {});
  162 + }
  163 +
  164 + /**
  165 + * 功能描述:把JSON字符串的部分转换成目标Java对象
  166 + *
  167 + * @param json JSON字符串
  168 + * @param targetPath 目标路径
  169 + * @param clazz 需要转换成的Java对象类
  170 + * @return Object对象
  171 + */
  172 + public static Object getJsonObjectFromTargetPath(String json, String targetPath, Class clazz) throws JSONException {
  173 + JSON targetJson = getJsonFromTargetPath(json, targetPath);
  174 + if (targetJson == null) {
  175 + Logger.d(TAG, "getJsonObjectFromTargetPath, targetJson is null");
  176 + throw new JSONException("getJsonObjectFromTargetPath, targetJson is null");
  177 + }
  178 + return JSON.toJavaObject(targetJson, clazz);
  179 + }
  180 +
  181 + /**
  182 + * 功能描述:把JSON字符串的部分转换成目标Java对象列表
  183 + *
  184 + * @param json JSON字符串
  185 + * @param targetPath 目标路径
  186 + * @param clazz 需要转换成的Java对象类
  187 + * @return Object对象
  188 + */
  189 + public static List getJsonObjectListFromTargetPath(String json, String targetPath, Class clazz)
  190 + throws JSONException {
  191 + JSON targetJson = getJsonFromTargetPath(json, targetPath);
  192 + JSONArray targetJsonArray = CastUtils.cast(targetJson, JSONArray.class);
  193 + if (ArrayUtils.isEmpty(targetJsonArray)) {
  194 + Logger.d(TAG, "getJsonObjectListFromTargetPath, targetJsonArray is empty");
  195 + throw new JSONException("getJsonObjectListFromTargetPath, targetJsonArray is empty");
  196 + }
  197 + return JSONObject.parseArray(targetJsonArray.toJSONString(), clazz);
  198 + }
  199 +
  200 + private static JSON getJsonFromTargetPath(String json, String targetPath) throws JSONException {
  201 + if (StringUtils.isEmpty(json)) {
  202 + Logger.d(TAG, "getJsonFromTargetPath, json is null");
  203 + throw new JSONException("getJsonFromTargetPath, json is null");
  204 + }
  205 + if (StringUtils.isEmpty(targetPath)) {
  206 + Logger.d(TAG, "getJsonFromTargetPath, targetPath is null");
  207 + throw new JSONException("getJsonFromTargetPath, targetPath is null");
  208 + }
  209 + String[] pathList = targetPath.split("\\.");
  210 + JSON tmp = JSON.parseObject(json);
  211 + Pattern pat = Pattern.compile("(\\w+)\\[(\\d*)]");
  212 + for (String path : pathList) {
  213 + Matcher matcher = pat.matcher(path);
  214 + if (matcher.find()) {
  215 + if (StringUtils.isNotEmpty(matcher.group(2))) {
  216 + JSONObject tmpObj = CastUtils.cast(tmp, JSONObject.class);
  217 + if (tmpObj == null) {
  218 + Logger.d(TAG, "getJsonFromTargetPath, tmpObj is null, matcher has index");
  219 + throw new JSONException("getJsonFromTargetPath, tmpObj is null, matcher has index");
  220 + }
  221 + JSONArray tmpArray = tmpObj.getJSONArray(matcher.group(1));
  222 + if (ArrayUtils.isEmpty(tmpArray)) {
  223 + Logger.d(TAG, "getJsonFromTargetPath, tmpArray is null, matcher has index");
  224 + throw new JSONException("getJsonFromTargetPath, tmpArray is null, matcher has index");
  225 + }
  226 + int index = MathUtils.parseInt(matcher.group(2), 0);
  227 + if (index < tmpArray.size()) {
  228 + tmp = tmpArray.getJSONObject(index);
  229 + } else {
  230 + Logger.d(TAG, "getJsonFromTargetPath, matcher has index, index out of bounds");
  231 + throw new JSONException("getJsonFromTargetPath, matcher has index, index out of bounds");
  232 + }
  233 + } else {
  234 + JSONObject tmpObj = CastUtils.cast(tmp, JSONObject.class);
  235 + if (tmpObj == null) {
  236 + Logger.d(TAG, "getJsonFromTargetPath, tmpObj is null, matcher with no index");
  237 + throw new JSONException("getJsonFromTargetPath, tmpObj is null, matcher with no index");
  238 + }
  239 + tmp = tmpObj.getJSONArray(matcher.group(1));
  240 + }
  241 + } else {
  242 + JSONObject tmpObj = CastUtils.cast(tmp, JSONObject.class);
  243 + if (tmpObj == null) {
  244 + Logger.d(TAG, "getJsonFromTargetPath, tmpObj is null, matcher not find");
  245 + throw new JSONException("getJsonFromTargetPath, tmpObj is null, matcher not find");
  246 + }
  247 + tmp = tmpObj.getJSONObject(path);
  248 + }
  249 + }
  250 + return tmp;
  251 + }
  252 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2020. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkitcore.tools;
  6 +
  7 +import android.content.Context;
  8 +import android.content.res.ColorStateList;
  9 +import android.content.res.Configuration;
  10 +import android.content.res.Resources;
  11 +import android.graphics.drawable.Drawable;
  12 +import android.util.DisplayMetrics;
  13 +import android.util.TypedValue;
  14 +
  15 +import androidx.annotation.NonNull;
  16 +
  17 +import com.wd.base.log.Logger;
  18 +
  19 +/**
  20 + * <BR>
  21 + *
  22 + * @author wangnaiwen
  23 + * @version [V1.0.0.0, 2020/4/7]
  24 + * @since V1.0.0.0
  25 + */
  26 +public final class ResUtils {
  27 + private static final String TAG = "ResUtils";
  28 +
  29 + private static final float ROUNDING = 0.5F;
  30 +
  31 + private ResUtils() {
  32 + }
  33 +
  34 + public static Resources getResources() {
  35 + return AppContext.getContext().getResources();
  36 + }
  37 +
  38 + @NonNull
  39 + public static Resources getResources(Context context) {
  40 + if (null != context) {
  41 + Resources resources = context.getResources();
  42 + if (null != resources) {
  43 + return resources;
  44 + }
  45 + }
  46 +
  47 + return AppContext.getContext().getResources();
  48 + }
  49 +
  50 + public static String getString(int resId) {
  51 + try {
  52 + return AppContext.getContext().getString(resId);
  53 + } catch (Resources.NotFoundException var2) {
  54 + Logger.t(TAG).e("" + var2);
  55 + return null;
  56 + }
  57 + }
  58 +
  59 + public static String getString(Context context, int resId) {
  60 + if (context != null) {
  61 + try {
  62 + return context.getString(resId);
  63 + } catch (Resources.NotFoundException var2) {
  64 + Logger.t(TAG).e("" + var2);
  65 + }
  66 + }
  67 + return null;
  68 + }
  69 +
  70 + public static String getString(int resId, Object... formatArgs) {
  71 + try {
  72 + return AppContext.getContext().getString(resId, formatArgs);
  73 + } catch (Resources.NotFoundException var3) {
  74 + Logger.t(TAG).e("" + var3);
  75 + return null;
  76 + }
  77 + }
  78 +
  79 + public static String getQuantityString(int resId, int quantity, Object... formatArgs) {
  80 + try {
  81 + return AppContext.getContext().getResources().getQuantityString(resId, quantity, formatArgs);
  82 + } catch (Resources.NotFoundException var4) {
  83 + Logger.t(TAG).e("" + var4);
  84 + return null;
  85 + }
  86 + }
  87 +
  88 + @Deprecated
  89 + public static int getDimensionPixelSize(int resId) {
  90 + try {
  91 + return AppContext.getContext().getResources().getDimensionPixelSize(resId);
  92 + } catch (Resources.NotFoundException var2) {
  93 + Logger.t(TAG).e("" + var2);
  94 + return 0;
  95 + }
  96 + }
  97 +
  98 + public static int getDimensionPixelSize(Context context, int resId) {
  99 + try {
  100 + return getResources(context).getDimensionPixelSize(resId);
  101 + } catch (Resources.NotFoundException var2) {
  102 + Logger.t(TAG).e("" + var2);
  103 + return 0;
  104 + }
  105 + }
  106 +
  107 + public static int getIdentifier(String name, String defType, String defPackTAGe) {
  108 + try {
  109 + return AppContext.getContext().getResources().getIdentifier(name, defType, defPackTAGe);
  110 + } catch (Resources.NotFoundException var4) {
  111 + Logger.t(TAG).e("" + var4);
  112 + return 0;
  113 + }
  114 + }
  115 +
  116 + public static float getDimension(int resId) {
  117 + try {
  118 + return AppContext.getContext().getResources().getDimension(resId);
  119 + } catch (Resources.NotFoundException var2) {
  120 + Logger.t(TAG).e("" + var2);
  121 + return 0.0F;
  122 + }
  123 + }
  124 +
  125 + public static float getFloat(int resId) {
  126 + try {
  127 + TypedValue outValue = new TypedValue();
  128 + AppContext.getContext().getResources().getValue(resId, outValue, true);
  129 + return outValue.getFloat();
  130 + } catch (Resources.NotFoundException var2) {
  131 + Logger.t(TAG).e("" + var2);
  132 + return 0.0F;
  133 + }
  134 + }
  135 +
  136 + public static int getColor(int resId) {
  137 + try {
  138 + return AppContext.getContext().getResources().getColor(resId);
  139 + } catch (Resources.NotFoundException var2) {
  140 + Logger.t(TAG).e("" + var2);
  141 + return 0;
  142 + }
  143 + }
  144 +
  145 + public static int getInt(int resId) {
  146 + try {
  147 + return AppContext.getContext().getResources().getInteger(resId);
  148 + } catch (Resources.NotFoundException var2) {
  149 + Logger.t(TAG).e("" + var2);
  150 + return 0;
  151 + }
  152 + }
  153 +
  154 + public static Drawable getDrawable(int resId) {
  155 + try {
  156 + return AppContext.getContext().getResources().getDrawable(resId);
  157 + } catch (Resources.NotFoundException var2) {
  158 + Logger.t(TAG).e("" + var2);
  159 + return null;
  160 + }
  161 + }
  162 +
  163 + public static String[] getStringArray(int resId) {
  164 + try {
  165 + return AppContext.getContext().getResources().getStringArray(resId);
  166 + } catch (Resources.NotFoundException var2) {
  167 + Logger.t(TAG).e("" + var2);
  168 + return new String[0];
  169 + }
  170 + }
  171 +
  172 + public static int[] getIntegerArray(int resId) {
  173 + try {
  174 + return AppContext.getContext().getResources().getIntArray(resId);
  175 + } catch (Resources.NotFoundException var2) {
  176 + Logger.t(TAG).e("" + var2);
  177 + return new int[0];
  178 + }
  179 + }
  180 +
  181 + public static ColorStateList getColorStateList(int resId) {
  182 + try {
  183 + return AppContext.getContext().getResources().getColorStateList(resId);
  184 + } catch (Resources.NotFoundException var2) {
  185 + Logger.t(TAG).e("" + var2);
  186 + return null;
  187 + }
  188 + }
  189 +
  190 + public static boolean getBoolean(int resId) {
  191 + try {
  192 + return AppContext.getContext().getResources().getBoolean(resId);
  193 + } catch (Resources.NotFoundException var2) {
  194 + Logger.t(TAG).e("" + var2);
  195 + return false;
  196 + }
  197 + }
  198 +
  199 + public static int dp2Px(float dp) {
  200 + float scale = AppContext.getContext().getResources().getDisplayMetrics().density;
  201 + return (int) (dp * scale + ROUNDING);
  202 + }
  203 +
  204 + public static int sp2Px(float sp) {
  205 + float scale = AppContext.getContext().getResources().getDisplayMetrics().scaledDensity;
  206 + return (int) (sp * scale + ROUNDING);
  207 + }
  208 +
  209 + public static int px2Dp(float px) {
  210 + float scale = AppContext.getContext().getResources().getDisplayMetrics().density;
  211 + return (int) (px / scale + ROUNDING);
  212 + }
  213 +
  214 + public static boolean isDirectionLTR() {
  215 + return getResources().getConfiguration().getLayoutDirection() == 0;
  216 + }
  217 +
  218 + public static int getIdentifier(Context context, String name, String defType, String defPackTAGe) {
  219 + try {
  220 + return getResources(context).getIdentifier(name, defType, defPackTAGe);
  221 + } catch (Resources.NotFoundException var5) {
  222 + Logger.t(TAG).e("" + var5);
  223 + return 0;
  224 + }
  225 + }
  226 +
  227 + public static int getColor(Context context, int resId) {
  228 + try {
  229 + return getResources(context).getColor(resId);
  230 + } catch (Resources.NotFoundException var3) {
  231 + Logger.t(TAG).e("" + var3);
  232 + return 0;
  233 + }
  234 + }
  235 +
  236 + public static Drawable getDrawable(Context context, int resId) {
  237 + try {
  238 + return getResources(context).getDrawable(resId);
  239 + } catch (Resources.NotFoundException var3) {
  240 + Logger.t(TAG).e("" + var3);
  241 + return null;
  242 + }
  243 + }
  244 +
  245 + public static String[] getStringArray(Context context, int resId) {
  246 + try {
  247 + return getResources(context).getStringArray(resId);
  248 + } catch (Resources.NotFoundException var3) {
  249 + Logger.t(TAG).e("" + var3);
  250 + return new String[0];
  251 + }
  252 + }
  253 +
  254 + public static ColorStateList getColorStateList(Context context, int resId) {
  255 + try {
  256 + return getResources(context).getColorStateList(resId);
  257 + } catch (Resources.NotFoundException var3) {
  258 + Logger.t(TAG).e("" + var3);
  259 + return null;
  260 + }
  261 + }
  262 +
  263 + public static boolean getBoolean(Context context, int resId) {
  264 + try {
  265 + return getResources(context).getBoolean(resId);
  266 + } catch (Resources.NotFoundException var3) {
  267 + Logger.t(TAG).e("" + var3);
  268 + return false;
  269 + }
  270 + }
  271 +
  272 + public static DisplayMetrics getDisplayMetrics() {
  273 + return getResources().getDisplayMetrics();
  274 + }
  275 +
  276 + public static Configuration getConfiguration() {
  277 + return getResources().getConfiguration();
  278 + }
  279 +
  280 + public static int getDimensionPixelOffset(int resId) {
  281 + try {
  282 + return getResources().getDimensionPixelOffset(resId);
  283 + } catch (Resources.NotFoundException var2) {
  284 + Logger.t(TAG).e("" + var2);
  285 + return 0;
  286 + }
  287 + }
  288 +}
  1 +
  2 +package com.wd.foundation.wdkitcore.tools;
  3 +
  4 +import android.text.TextUtils;
  5 +
  6 +import com.wd.foundation.wdkitcore.storage.ConfigBase;
  7 +
  8 +/**
  9 + * 描述:key-value存储
  10 + * TODO 待梳理,考虑上移
  11 + *
  12 + * @author : lvjinhui
  13 + * @since: 2022/12/15
  14 + */
  15 +public class SpUtils {
  16 +
  17 + /**
  18 + * tag
  19 + */
  20 + private static final String TAG = "SpUtils";
  21 +
  22 + /**
  23 + * 默认环境变量
  24 + */
  25 + private static String BASE_URL_VALUE = "";
  26 +
  27 + /**
  28 + * 接口服务器默认地址
  29 + */
  30 + private static final String KEY_BASE_URL_TAG = "key_base_url_tag";
  31 +
  32 + private static final String BASE_URL_TAG = "base_url_tag";
  33 +
  34 + /**
  35 + * http收到406的情况
  36 + */
  37 + private static final String HTTP_406 = "http_406";
  38 +
  39 + /**
  40 + * http收到377的情况
  41 + */
  42 + private static final String HTTP_377 = "http_377";
  43 +
  44 + /**
  45 + * 用户token
  46 + */
  47 + private static final String USER_TOKE = "user_token";
  48 +
  49 + /**
  50 + * 用户 融云token
  51 + */
  52 + private static final String USER_RONGYUN_TOKE = "user_rongyun_token";
  53 +
  54 + /**
  55 + * 用户refreshToken
  56 + */
  57 + private static final String REFRE_TOKEN = "refer_token";
  58 +
  59 + /**
  60 + * 用户信息
  61 + */
  62 + private static final String USER_ID = "user_id";
  63 +
  64 + /**
  65 + * 用户创作者名称
  66 + */
  67 + private static final String USER_CREATOR_NAME = "user_creator_name";
  68 +
  69 + /**
  70 + * 用户id值
  71 + */
  72 + private static String USER_ID_VALUE = "";
  73 +
  74 + /**
  75 + * 缓存的key保存起来,用来清理缓存
  76 + */
  77 + private static final String NETWORK_CACHE_DATA_KEY = "network_cache_data_key";
  78 +
  79 + /**
  80 + *
  81 + */
  82 + private static final String PROVINCE = "province";
  83 +
  84 + /**
  85 + * 城市
  86 + */
  87 + private static final String CITY = "city";
  88 +
  89 + /**
  90 + * 城市值
  91 + */
  92 + private static String CITY_VALUE = "";
  93 +
  94 + /**
  95 + * 首次打开app 用户协议提示
  96 + */
  97 + private static final String APP_FIRST_AGREEMENT_TIP = "app_first_agreement_tip";
  98 +
  99 + /**
  100 + * 播放时间
  101 + */
  102 + private static final String LIVE_LOADING_TIME = "live_loading_time";
  103 +
  104 + /**
  105 + * 缓存网络数据
  106 + */
  107 + private static final String NETWORK_CACHE_DATA_SP = "network_cache_data_sp";
  108 +
  109 + /**
  110 + * 彩蛋id 存储
  111 + */
  112 + private static final String POPUPS_SAVE_FILE = "popups_save_file";
  113 +
  114 + /**
  115 + * 页面彩蛋
  116 + */
  117 + public static final String POPUP_PAGE = "popup_page";
  118 +
  119 + /**
  120 + * 展示的广告记录
  121 + */
  122 + private static final String ADS_RECORD = "ads_record";
  123 +
  124 + /**
  125 + * 广告类型-开屏
  126 + */
  127 + private static final String TYPE_LAUNCH = "type_launch";
  128 +
  129 + /**
  130 + * 广告类型-挂角
  131 + */
  132 + private static final String TYPE_CORNERS = "type_corners";
  133 +
  134 + /**
  135 + * 启动相关,非启动不要使用
  136 + */
  137 + public static final String LAUNCH = "launch";
  138 +
  139 + /**
  140 + * 首次开启引导页
  141 + */
  142 + private static final String APP_FIRST_GUIDE = "app_first_guide";
  143 +
  144 + /**
  145 + * 数据存储的XML名称 存储置顶应用用
  146 + **/
  147 + private static final String FILENAME_RMRB = "rmrb_config";
  148 + /**
  149 + * 数据存储的音频数据
  150 + **/
  151 + // private static final String USER_MUSIC = "user_music";
  152 +
  153 + /**
  154 + * 用户协议H5
  155 + */
  156 +
  157 + private static final String USER_AGREE_URL = "user_agree_url";
  158 +
  159 + /**
  160 + * 用户协议版本
  161 + */
  162 +
  163 + private static final String USER_AGREE_VERSION = "user_agree_version";
  164 +
  165 + /**
  166 + * 创作者资质认证状态,
  167 + * 0:未认证,1:机审中、2:认证中 3.:认证不通过 4:已认证 5:已认证变更中 6:认证驳回
  168 + */
  169 + private static final String USER_STATUS = "user_status";
  170 +
  171 + /**
  172 + * 注销协议
  173 + */
  174 +
  175 + private static final String LOG_OUT_AGREE_URL = "log_out_agreee_url";
  176 +
  177 + /**
  178 + * 隐私政策H5
  179 + */
  180 + private static final String PRIVATE_AGREE_URL = "private_agree_url";
  181 +
  182 + /**
  183 + * 隐私政策版本
  184 + */
  185 + private static final String PRIVATE_AGREE_VERSION = "private_agree_version";
  186 +
  187 + /**
  188 + * 隐私政策中相机权限
  189 + */
  190 + private static final String PRIVATE_CAMERA_URL = "private_camera_url";
  191 +
  192 + /**
  193 + * 直播规范
  194 + */
  195 + private static final String PRIVATE_LIVEBROADCAST_URL = "private_livebroadcast_url";
  196 +
  197 + /**
  198 + * 直播协议
  199 + */
  200 + private static final String PRIVATE_LIVEPROTOCAL_URL = "private_liveprotocal_url";
  201 +
  202 + /**
  203 + * 实名认证服务协议
  204 + */
  205 + private static final String PRIVATE_CERTIFICATION_URL = "private_certification_url";
  206 +
  207 + /**
  208 + * 留言板-隐私协议
  209 + */
  210 + private static final String MESSAGE_BOARD_PRIVATE_URL = "message_board_private_url";
  211 +
  212 + /**
  213 + * 留言板-用户协议
  214 + */
  215 + private static final String MESSAGE_BOARD_USER_URL = "message_board_user_url";
  216 +
  217 + /**
  218 + * 留言板-发布提问规定
  219 + */
  220 + private static final String MESSAGE_BOARD_PULISH_URL = "message_board_publish_url";
  221 +
  222 + /**
  223 + * 地区编码
  224 + */
  225 + private static String CITY_DISTRICTCODE_VALUE = "";
  226 +
  227 + /**
  228 + * 区、县编码编码
  229 + */
  230 + private static final String DISTRICT_CODE = "district_code";
  231 +
  232 + /**
  233 + * 问政频道地理编码
  234 + */
  235 + private static final String WENZHEN_CHANNEL_AREA = "wenzhen_channel_area";
  236 +
  237 + /**
  238 + * 问政频道地理名称
  239 + */
  240 + private static final String WENZHEN_CHANNEL_AREA_NAME = "wenzhen_channel_area_name";
  241 +
  242 + /**
  243 + * 直播红点数据
  244 + */
  245 + private static final String LIVE_RED_POINT_DATA = "live_red_point_data";
  246 +
  247 + /**
  248 + * 问政红点数据
  249 + */
  250 + private static final String ASK_RED_POINT_DATA = "ask_red_point_data";
  251 +
  252 + /**
  253 + * 广告id 存储
  254 + */
  255 + public static final String ADV_SAVE_FILE = "adv_save_file";
  256 +
  257 + /**
  258 + * 展示的广告
  259 + */
  260 + public static final String ADV_ = "adv_";
  261 +
  262 + /**
  263 + * 配置config 存储
  264 + */
  265 + private static final String CONFIG_SAVE_FILE = "config_save_file";
  266 +
  267 + /**
  268 + * 保存 是否 拒绝 定位权限
  269 + */
  270 + private static final String LOCATION_PERMISSION = "location_permission";
  271 +
  272 + /**
  273 + * 覆盖安装,保存的上个版本号
  274 + */
  275 + private static final String LAST_APP_VERSION = "last_app_version";
  276 +
  277 + /**
  278 + * 邀请码
  279 + */
  280 + private static final String INVITER_CODE = "inviter_code";
  281 +
  282 + /**
  283 + * 推送开关
  284 + */
  285 + private static final String UM_PUSH_SWITCH = "um_push_switch";
  286 +
  287 + /**
  288 + * 仅wifi下加载图片
  289 + */
  290 + private static final String WIFI_LOAD_IMG_SWITCH = "wifi_load_img_switch";
  291 +
  292 + /**
  293 + * 仅wifi下播放视频
  294 + */
  295 + private static final String WIFI_PLAY_VIDEO_SWITCH = "wifi_play_video_switch";
  296 +
  297 + /**
  298 + * 视频悬浮窗
  299 + */
  300 + private static final String PLAY_VIDEO_WINDOW_SWITCH = "play_video_window_switch";
  301 +
  302 + /**
  303 + * token时间节点
  304 + */
  305 + private static final String END_POINT = "end_point";
  306 +
  307 + /**
  308 + * 头像
  309 + */
  310 + private static final String RMRB_HEAD_IMG = "rmrb_head_img";
  311 +
  312 + /**
  313 + * 用户类型userType
  314 + */
  315 + private static final String USER_TYPE = "user_type";
  316 +
  317 + /**
  318 + * 创作者id
  319 + */
  320 + private static final String CREATOR_ID = "creator_id";
  321 +
  322 + /**
  323 + * 头像Url
  324 + */
  325 + private static final String AVATAR_URL = "avatar_url";
  326 +
  327 + /**
  328 + * 用户号码
  329 + */
  330 + private static final String USER_PHONE = "user_phone";
  331 +
  332 + /**
  333 + * 直播过期token 时间
  334 + */
  335 + private static final String LIVE_TOKEN_TIME = "live_token_time";
  336 +
  337 + /**
  338 + * 直播过accessToken
  339 + */
  340 + private static final String LIVE_ACCESSTOKEN = "live_accesstoken";
  341 +
  342 + /**
  343 + * 直播refreshToken
  344 + */
  345 + private static final String LIVE_REFRESHTOKEN = "live_refreshToken";
  346 +
  347 + /**
  348 + * 用户名称
  349 + */
  350 + private static final String USER_NAME = "user_name";
  351 +
  352 + /**
  353 + * 用户是否听过次音乐 存储id
  354 + */
  355 + private static final String USER_MUSIC_OLD_ID = "user_music_old_id";
  356 +
  357 + /**
  358 + * 性别
  359 + */
  360 + private static final String SEX = "sex";
  361 +
  362 + /**
  363 + * 出生年月日
  364 + */
  365 + private static final String BIRTHDAY = "BIRTHDAY";
  366 +
  367 + /**
  368 + * 阿里 直播 APPID
  369 + */
  370 + private static final String LIVE_IM_APPID = "im_appId";
  371 +
  372 + /**
  373 + * 阿里 直播 APPKEY
  374 + */
  375 + private static final String LIVE_IM_APPKEY = "im_appKey";
  376 +
  377 + /**
  378 + * 用户成长值等级
  379 + */
  380 + private static int USER_LEVEL_VALUE = -1;
  381 +
  382 + /**
  383 + * 用户成长值等级
  384 + */
  385 + private static final String USER_LEVEL = "user_level";
  386 +
  387 + /**
  388 + * push数据
  389 + */
  390 + private static final String PUSH_DATA = "push_data";
  391 +
  392 + /**
  393 + * push数据
  394 + */
  395 + private static final String PUSH_MESSAGEID = "push_messageid";
  396 +
  397 + /**
  398 + * 设置-夜间模式标识
  399 + */
  400 + private static final String SET_NIGHTMODE = "set_nightmode";
  401 +
  402 + /**
  403 + * 设置-夜间模式-日间模式值
  404 + */
  405 + public static final String LIGHT_MODE = "Light Mode";
  406 +
  407 + /**
  408 + * 设置-夜间模式-夜间模式值
  409 + */
  410 + public static final String NIGHT_MODE = "Night Mode";
  411 +
  412 + /**
  413 + * 设置-夜间模式-跟随系统模式值
  414 + */
  415 + public static final String FOLLOWUP_SYSTEM = "System Default";
  416 +
  417 + /**
  418 + * 是否已经非wifi弹窗一次,VIDEO
  419 + */
  420 + private static final String NO_USER_WIFI_FOR_VIDEO = "no_user_wifi_for_video";
  421 +
  422 + /**
  423 + * 启动页数据
  424 + */
  425 + private static final String SPLASHINFO = "splashinfo";
  426 +
  427 + /**
  428 + * 启动页数据
  429 + * 0:没有,1:展现广告,2:广告中心开机屏
  430 + */
  431 + private static final String SPLASH_CACHE_TYPE = "splash_cache_type";
  432 +
  433 + /**
  434 + * 启动页数据md5
  435 + */
  436 + private static final String SPLASH_CACHE_MD5 = "splash_cache_md5";
  437 +
  438 + /**
  439 + * 设备id
  440 + */
  441 + private static final String DEVICE_ID = "device_id";
  442 +
  443 + /**
  444 + * 邮件订阅曝光时间
  445 + */
  446 + private static final String SUB_EMAIL_EXPORE = "sub_email_expore";
  447 +
  448 + /**
  449 + * 设置-夜间模式标识
  450 + */
  451 + private static final String UPDATE_ID = "update_id";
  452 +
  453 + private static final String KEY_DEFAULT_CHANNEL_ID = "key_default_channel_id"; // 默认频道
  454 +
  455 + /**
  456 + * 语音播放标识
  457 + */
  458 + private static final String ARTICLE_DETAIL_SP = "article_detail_sp";
  459 +
  460 + /**
  461 + * 语音播放图文内容参数
  462 + */
  463 + private static final String CONTENT_ID = "content_id";
  464 +
  465 + private static final String CONTENT_TYPE = "content_type";
  466 +
  467 + private static final String TOPIC_ID = "topic_id";
  468 +
  469 + private static final String CHANNEL_ID = "channel_id";
  470 +
  471 + private static final String COMP_ID = "compId";
  472 +
  473 + private static final String SOURCE_PAGE = "sourcePage";
  474 +
  475 + private static final String CONTENT_REL_TYPE = "contentRelType";
  476 +
  477 + private static final String CONTENT_REL_ID = "contentRelId";
  478 +
  479 + private static final String SCROLL_TO_BOTTOM = "scrollToBottom";
  480 +
  481 + /**
  482 + * 数据存储的XML名称 存储置顶应用用
  483 + **/
  484 + private static final String FILENAME_PLAY_UTILS = "mgtv_player_config";
  485 +
  486 + /**
  487 + * 经度
  488 + */
  489 + private static String LOCATION_LONGITUDE = "longitude";
  490 +
  491 + /**
  492 + * 纬度
  493 + */
  494 + private static String LOCATION_LATITUDE = "latitude";
  495 +
  496 + /**
  497 + * 地址
  498 + */
  499 + private static String LOCATION_ADDRESS = "location_address";
  500 +
  501 + /**
  502 + * 视频播放环境设置 0:Mobile data and Wi-Fi / 默认 1:Wi-Fi only
  503 + */
  504 + private static final String VIDEO_PLAYBACK = "video_playback";
  505 +
  506 + /**
  507 + * 用户活动权限:0:有权限 1:无权限
  508 + */
  509 + private static final String USER_ACTIVITY_CONTROL = "user_activity_control";
  510 +
  511 + /**
  512 + * 是否点过分享海报
  513 + */
  514 + private static final String SHARE_ICON_NEW_TAG = "share_icon_new_tag";
  515 +
  516 + /**
  517 + * 推送消息数目
  518 + */
  519 + private static final String PUSH_MESSAGE_COUNT = "push_message_count";
  520 +
  521 + /**
  522 + * client
  523 + */
  524 + private static final String CLIENT_ID = "client_id";
  525 +
  526 + /**
  527 + * client
  528 + */
  529 + private static final String ONCE_UPDATE = "once_update";
  530 +
  531 + /**
  532 + * 获取用户name
  533 + */
  534 + public static String getUserName() {
  535 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_NAME, "");
  536 + }
  537 +
  538 + /**
  539 + * 保存用户name
  540 + */
  541 + public static void saveUserName(String name) {
  542 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_NAME, name);
  543 + }
  544 +
  545 + /**
  546 + * 获取用户性别
  547 + */
  548 + public static String getSex() {
  549 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(SEX, "");
  550 + }
  551 +
  552 + /**
  553 + * 保存用户性别
  554 + */
  555 + public static void saveSex(String sex) {
  556 + new ConfigBase(FILENAME_RMRB).putWithSP(SEX, sex);
  557 + }
  558 +
  559 + /**
  560 + * 获取用户生日
  561 + */
  562 + public static String getBirthday() {
  563 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(BIRTHDAY, "");
  564 + }
  565 +
  566 + /**
  567 + * 保存用户生日
  568 + */
  569 + public static void saveBirthday(String birthday) {
  570 + new ConfigBase(FILENAME_RMRB).putWithSP(BIRTHDAY, birthday);
  571 + }
  572 +
  573 + /**
  574 + * 设置使用哪个默认请求地址
  575 + *
  576 + * @param tag
  577 + */
  578 + public static void saveBaseUrlTag(String tag) {
  579 + if (!TextUtils.isEmpty(tag)) {
  580 + BASE_URL_VALUE = tag;
  581 + new ConfigBase(KEY_BASE_URL_TAG).putWithSP(BASE_URL_TAG, tag);
  582 + }
  583 +
  584 + }
  585 +
  586 + /**
  587 + * 获取服务器默认地址 是哪个
  588 + *
  589 + * @return
  590 + */
  591 + public static String getBaseUrlTag() {
  592 + if (!TextUtils.isEmpty(BASE_URL_VALUE)) {
  593 + return BASE_URL_VALUE;
  594 + }
  595 + return new ConfigBase(KEY_BASE_URL_TAG).getStringWithSP(BASE_URL_TAG);
  596 + }
  597 +
  598 + /**
  599 + * 获取http状态406的情况
  600 + */
  601 + public static boolean getHttp406() {
  602 + return new ConfigBase(FILENAME_RMRB).getBooleanWithSP(HTTP_406, false);
  603 + }
  604 +
  605 + /**
  606 + * 保存http状态406的情况
  607 + */
  608 + public static void saveHttp406(boolean isTrue) {
  609 + new ConfigBase(FILENAME_RMRB).putWithSP(HTTP_406, isTrue);
  610 + }
  611 +
  612 + /**
  613 + * 保存用户token
  614 + */
  615 + public static void saveUserToken(String token) {
  616 + if (!"null".equals(token) && token != null) {
  617 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_TOKE, token);
  618 + }
  619 + }
  620 +
  621 + /**
  622 + * 获取融云token
  623 + */
  624 + public static String getUserRongYunToken() {
  625 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_RONGYUN_TOKE, "");
  626 + }
  627 +
  628 + /**
  629 + * 保存融云token
  630 + */
  631 + public static void saveUserRongYunToken(String token) {
  632 + if (!"null".equals(token) && token != null) {
  633 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_RONGYUN_TOKE, token);
  634 + }
  635 + }
  636 +
  637 + /**
  638 + * 获取用户token
  639 + */
  640 + public static String getUserToken() {
  641 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_TOKE, "");
  642 + }
  643 +
  644 + /**
  645 + * 存userid
  646 + */
  647 + public static void saveUserId(String userId) {
  648 + if (StringUtils.isEmpty(getUserId()) || !StringUtils.isEqual(userId, getUserId())) {
  649 + // 登录状态变化,清除广告数据
  650 + clearNormalRecordAdvBeanList();
  651 + }
  652 + USER_ID_VALUE = userId;
  653 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_ID, userId);
  654 + }
  655 +
  656 + /**
  657 + * get userid
  658 + */
  659 + public static String getUserId() {
  660 + if (!TextUtils.isEmpty(USER_ID_VALUE)) {
  661 + return USER_ID_VALUE;
  662 + }
  663 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_ID, "");
  664 + }
  665 +
  666 + /**
  667 + * 保存用户传作者name
  668 + */
  669 + public static void saveUserCreatorName(String name) {
  670 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_CREATOR_NAME, name);
  671 + }
  672 +
  673 + /**
  674 + * 获取r用户传作者name
  675 + */
  676 + public static String getUserCreatorName() {
  677 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_CREATOR_NAME, getUserName());
  678 + }
  679 +
  680 + /**
  681 + * 保存refreshToken
  682 + */
  683 + public static void saveRefreshToken(String token) {
  684 + if (!"null".equals(token) && token != null) {
  685 + new ConfigBase(FILENAME_RMRB).putWithSP(REFRE_TOKEN, token);
  686 + }
  687 + }
  688 +
  689 + /**
  690 + * 获取refreshToken
  691 + */
  692 + public static String getRefreshToken() {
  693 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(REFRE_TOKEN);
  694 + }
  695 +
  696 + /**
  697 + * 保存用户类型 userType,默认普通用户
  698 + */
  699 + public static void saveUserType(int userType) {
  700 + if (0 == userType) {
  701 + userType = 1;
  702 + }
  703 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_TYPE, userType);
  704 + }
  705 +
  706 + /**
  707 + * 获取userType
  708 + * 1:普通用户 2:视频号 3:矩阵号 4内容子账号 5内容号
  709 + */
  710 + public static int getUserType() {
  711 + return new ConfigBase(FILENAME_RMRB).getIntWithSP(USER_TYPE, 1);
  712 + }
  713 +
  714 + /**
  715 + * 保存endPoint
  716 + */
  717 + public static void saveEndPoint(String endPoint) {
  718 + if (!"null".equals(endPoint) && endPoint != null) {
  719 + new ConfigBase(FILENAME_RMRB).putWithSP(END_POINT, endPoint);
  720 + }
  721 + }
  722 +
  723 + /**
  724 + * 获取endPoint
  725 + */
  726 + public static String getEndPoint() {
  727 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(END_POINT);
  728 + }
  729 +
  730 + /**
  731 + * 保存rmrbHeadImg
  732 + */
  733 + public static void saveRmrbHeadImg(String rmrbHeadImg) {
  734 + if (!"null".equals(rmrbHeadImg) && rmrbHeadImg != null) {
  735 + new ConfigBase(FILENAME_RMRB).putWithSP(RMRB_HEAD_IMG, rmrbHeadImg);
  736 + }
  737 + }
  738 +
  739 + /**
  740 + * 获取头像
  741 + */
  742 + public static String getRmrbHeadImg() {
  743 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(RMRB_HEAD_IMG);
  744 + }
  745 +
  746 + /**
  747 + * creatorId
  748 + */
  749 + public static void saveCreatorId(String creatorId) {
  750 + if ("0".equals(creatorId)) {
  751 + creatorId = "";
  752 + }
  753 + new ConfigBase(FILENAME_RMRB).putWithSP(CREATOR_ID, creatorId);
  754 + }
  755 +
  756 + /**
  757 + * get creatorId
  758 + */
  759 + public static String getCreatorId() {
  760 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(CREATOR_ID, "");
  761 + }
  762 +
  763 + /**
  764 + * 头像headPhotoUrl
  765 + */
  766 + public static void saveHeadPhotoUrl(String url) {
  767 + new ConfigBase(FILENAME_RMRB).putWithSP(AVATAR_URL, url);
  768 + }
  769 +
  770 + /**
  771 + * 头像地址headPhotoUrl
  772 + */
  773 + public static String getHeadPhotoUrl() {
  774 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(AVATAR_URL, "");
  775 + }
  776 +
  777 + /**
  778 + * 保存手机号码
  779 + */
  780 + public static void saveUserPhone(String key) {
  781 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_PHONE, key);
  782 + }
  783 +
  784 + /**
  785 + * 获取手机号码
  786 + */
  787 + public static String getUserPhone() {
  788 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_PHONE);
  789 + }
  790 +
  791 + /**
  792 + * 保存用户等级
  793 + */
  794 + public static void saveUserLevel(String userLevel) {
  795 + try {
  796 + USER_LEVEL_VALUE = Integer.parseInt(userLevel);
  797 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_LEVEL, USER_LEVEL_VALUE);
  798 + } catch (NumberFormatException e) {
  799 + }
  800 + }
  801 +
  802 + /**
  803 + * 获取用户等级
  804 + */
  805 + public static int getUserLevel() {
  806 + if (USER_LEVEL_VALUE != -1) {
  807 + return USER_LEVEL_VALUE;
  808 + }
  809 + return new ConfigBase(FILENAME_RMRB).getIntWithSP(USER_LEVEL, -1);
  810 + }
  811 +
  812 + /**
  813 + * 获取http状态377的情况
  814 + */
  815 + public static boolean getHttp377() {
  816 + return new ConfigBase(FILENAME_RMRB).getBooleanWithSP(HTTP_377, false);
  817 + }
  818 +
  819 + /**
  820 + * 保存http状态377的情况
  821 + */
  822 + public static void saveHttp377(boolean isTrue) {
  823 + new ConfigBase(FILENAME_RMRB).putWithSP(HTTP_377, isTrue);
  824 + }
  825 +
  826 + /**
  827 + * 保存城市
  828 + */
  829 + public static void saveCity(String cityCode) {
  830 + CITY_VALUE = cityCode;
  831 + new ConfigBase(FILENAME_RMRB).putWithSP(CITY, cityCode);
  832 + }
  833 +
  834 + /**
  835 + * 获取城市
  836 + *
  837 + * @return
  838 + */
  839 + public static String getCity() {
  840 + if (!TextUtils.isEmpty(CITY_VALUE)) {
  841 + return CITY_VALUE;
  842 + }
  843 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(CITY, "");
  844 + }
  845 +
  846 + /**
  847 + * 省份编码
  848 + *
  849 + * @return
  850 + */
  851 + public static String getProvinceCode() {
  852 + if (!TextUtils.isEmpty(getDistrictCode()) && getDistrictCode().length() > 1) {
  853 + return getDistrictCode().substring(0, 2) + "0000";
  854 + } else {
  855 + return "";
  856 + }
  857 + }
  858 +
  859 + /**
  860 + * 获取城市编码
  861 + *
  862 + * @return
  863 + */
  864 + public static String getCityCode() {
  865 + if (!TextUtils.isEmpty(getDistrictCode()) && getDistrictCode().length() > 3) {
  866 + return getDistrictCode().substring(0, 4) + "00";
  867 + } else {
  868 + return "";
  869 + }
  870 + }
  871 +
  872 + /**
  873 + * 是否首次使用协议
  874 + *
  875 + * @return 默认true
  876 + */
  877 + public static boolean isFirstAgreementFlag() {
  878 + // 默认首次为true
  879 + return new ConfigBase(LAUNCH).getBooleanWithSP(APP_FIRST_AGREEMENT_TIP, true);
  880 + }
  881 +
  882 + /**
  883 + * 修改首次使用协议
  884 + */
  885 + public static void editFirstAgreementFlag() {
  886 +
  887 + new ConfigBase(LAUNCH).putWithSP(APP_FIRST_AGREEMENT_TIP, false);
  888 + }
  889 +
  890 + // 记录直播加载时间
  891 + public static long getLiveLoadTime() {
  892 + return new ConfigBase(FILENAME_RMRB).getLongWithSP(LIVE_LOADING_TIME, 0);
  893 + }
  894 +
  895 + public static void saveLiveLoadTime(long time) {
  896 + new ConfigBase(FILENAME_RMRB).put(LIVE_LOADING_TIME, time);
  897 + }
  898 +
  899 + /**
  900 + * 保存网络数据
  901 + */
  902 +
  903 + public static void saveNetworkDataCache(String spKey, String data) {
  904 + // 保存数据
  905 + ConfigBase configBase = new ConfigBase(NETWORK_CACHE_DATA_SP);
  906 + configBase.putWithSP(spKey, data);
  907 +
  908 + // 保存key,重复key不保存
  909 + String cacheDataKeys = configBase.getStringWithSP(NETWORK_CACHE_DATA_KEY);
  910 + if (isContainKey(cacheDataKeys, spKey)) {
  911 + return;
  912 + }
  913 + if (StringUtils.isBlank(cacheDataKeys)) {
  914 + configBase.putWithSP(NETWORK_CACHE_DATA_KEY, spKey + ";");
  915 + } else {
  916 + configBase.putWithSP(NETWORK_CACHE_DATA_KEY, cacheDataKeys + spKey + ";");
  917 + }
  918 +
  919 + }
  920 +
  921 + /**
  922 + * 是否包含了该key
  923 + *
  924 + * @param key
  925 + * @return
  926 + */
  927 + private static boolean isContainKey(String cacheDataKeys, String key) {
  928 + if (cacheDataKeys == null) {
  929 + return false;
  930 + }
  931 + String[] keys = cacheDataKeys.split(";");
  932 + if (keys != null && keys.length > 0) {
  933 + for (int i = 0; i < keys.length; i++) {
  934 + if (keys[i].equals(key)) {
  935 + return true;
  936 + }
  937 + }
  938 + }
  939 + return false;
  940 + }
  941 +
  942 + /**
  943 + * 清除接口缓存
  944 + */
  945 + public static void cleanNetworkDataCache() {
  946 + ConfigBase configBase = new ConfigBase(NETWORK_CACHE_DATA_SP);
  947 + String cacheDataKeys = configBase.getStringWithSP(NETWORK_CACHE_DATA_KEY);
  948 + if (cacheDataKeys == null) {
  949 + return;
  950 + }
  951 + String[] keys = cacheDataKeys.split(";");
  952 + if (keys != null && keys.length > 0) {
  953 + for (int i = 0; i < keys.length; i++) {
  954 + configBase.removeWithSP(keys[i]);
  955 + }
  956 + }
  957 + // 把key清空
  958 + configBase.putWithSP(NETWORK_CACHE_DATA_KEY, "");
  959 + }
  960 +
  961 + /**
  962 + * 获取网络缓存数据
  963 + *
  964 + * @param spKey
  965 + * @return
  966 + */
  967 + public static String getNetworkDataCache(String spKey) {
  968 + return new ConfigBase(NETWORK_CACHE_DATA_SP).getStringWithSP(spKey);
  969 + }
  970 +
  971 + /**
  972 + * 保存展示的彩蛋
  973 + *
  974 + * @param type 彩蛋类型
  975 + * @param id 彩蛋id
  976 + */
  977 + public static void savePopUpIsShow(String type, String id) {
  978 + new ConfigBase(POPUPS_SAVE_FILE).putWithSP(type + "_" + id + "_" + getUserId(), true);
  979 + }
  980 +
  981 + /**
  982 + * 获取彩蛋是否展示过
  983 + *
  984 + * @param type 彩蛋类型
  985 + * @param id 彩蛋id
  986 + * @return
  987 + */
  988 + public static Boolean getPopUpIsShow(String type, String id) {
  989 + return new ConfigBase(POPUPS_SAVE_FILE).getBooleanWithSP(type + "_" + id + "_" + getUserId(), false);
  990 + }
  991 +
  992 + //
  993 + // /**
  994 + // * 存储或更新 广告
  995 + // *
  996 + // * @param type 0:开屏
  997 + // * 1:挂角
  998 + // * @param bean
  999 + // */
  1000 + // public static void saveOrUpdateNormalAdvInfor(int type, RecordNormalAdvBean bean) {
  1001 + //
  1002 + // StringBuilder fileName = new StringBuilder();
  1003 + // fileName.append(ADS_RECORD);
  1004 + // if (type == 0) {
  1005 + // fileName.append("_");
  1006 + // fileName.append(TYPE_LAUNCH);
  1007 + // } else if (type == 1) {
  1008 + // fileName.append("_");
  1009 + // fileName.append(TYPE_CORNERS);
  1010 + // }
  1011 + //
  1012 + // List<RecordNormalAdvBean> list = getRecordNormalAdvBeanList(type);
  1013 + //
  1014 + // if (list == null || list.size() == 0) {
  1015 + // bean.setShowCount(1);
  1016 + // List<RecordNormalAdvBean> aList = new ArrayList<>();
  1017 + // aList.add(bean);
  1018 + // String jsonArray = JsonUtils.convertObjectToJson(aList);
  1019 + // Logger.t(TAG).d("saveOrUpdateNormalAdvInfor====>" + jsonArray);
  1020 + // new ConfigBase(fileName.toString()).putWithSP(ADS_RECORD, jsonArray);
  1021 + // } else {
  1022 + // boolean addNewAdsId = true;
  1023 + // int showCount = getRecordNormalAdvCount(type, bean.getAdvId());
  1024 + // for (int i = 0; i < list.size(); i++) {
  1025 + // if (StringUtils.isEqual(bean.getAdvId(), list.get(i).getAdvId())) {
  1026 + // // id一样,不添加
  1027 + // list.get(i).setShowCount(1);
  1028 + // addNewAdsId = false;
  1029 + // } else if (showCount == 1) {
  1030 + // // 新循环开始,将其他缓存的数据展示次数置为0
  1031 + // list.get(i).setShowCount(0);
  1032 + // }
  1033 + // }
  1034 + // if (addNewAdsId) {
  1035 + // // 需要添加
  1036 + // bean.setShowCount(1);
  1037 + // list.add(bean);
  1038 + // }
  1039 + // String jsonArray = JsonUtils.convertObjectToJson(list);
  1040 + // new ConfigBase(fileName.toString()).putWithSP(ADS_RECORD, jsonArray);
  1041 + // Logger.t(TAG).d("saveOrUpdateNormalAdvInfor====>" + jsonArray);
  1042 + // }
  1043 + // }
  1044 +
  1045 + // /**
  1046 + // * 获取展示的次数 -1:未展示过,0:已展示过,但当前循环未展示,1:当前循环已展示
  1047 + // *
  1048 + // * @param type 0:开屏
  1049 + // * 1:挂角
  1050 + // * @param id
  1051 + // * @return
  1052 + // */
  1053 + // public static int getRecordNormalAdvCount(int type, String id) {
  1054 + // int count = -1;
  1055 + // List<RecordNormalAdvBean> list = getRecordNormalAdvBeanList(type);
  1056 + // if (list == null || list.size() == 0) {
  1057 + // return count;
  1058 + // } else {
  1059 + // for (RecordNormalAdvBean bean : list) {
  1060 + // if (StringUtils.isEqual(id, bean.getAdvId())) {
  1061 + // // id一样,不添加
  1062 + // count = bean.getShowCount();
  1063 + // break;
  1064 + // }
  1065 + // }
  1066 + // return count;
  1067 + // }
  1068 + // }
  1069 +
  1070 + // /**
  1071 + // * 获取普通广告的记录信息
  1072 + // *
  1073 + // * @param type 0:开屏
  1074 + // * 1:挂角
  1075 + // * @return
  1076 + // */
  1077 + // private static List<RecordNormalAdvBean> getRecordNormalAdvBeanList(int type) {
  1078 + //
  1079 + // StringBuilder fileName = new StringBuilder();
  1080 + // fileName.append(ADS_RECORD);
  1081 + // if (type == 0) {
  1082 + // fileName.append("_");
  1083 + // fileName.append(TYPE_LAUNCH);
  1084 + // } else if (type == 1) {
  1085 + // fileName.append("_");
  1086 + // fileName.append(TYPE_CORNERS);
  1087 + // }
  1088 + //
  1089 + // String jsonArrayStr = new ConfigBase(fileName.toString()).getStringWithSP(ADS_RECORD, "");
  1090 + // List<RecordNormalAdvBean> idList = null;
  1091 + // try {
  1092 + // idList = JsonUtils.convertJsonArrayToObjList(jsonArrayStr, RecordNormalAdvBean.class);
  1093 + // } catch (Exception e) {
  1094 + // e.printStackTrace();
  1095 + // }
  1096 + // return idList;
  1097 + // }
  1098 +
  1099 + /**
  1100 + * 清理广告数据
  1101 + */
  1102 + public static void clearNormalRecordAdvBeanList() {
  1103 + // 清理开屏广告数据
  1104 + clearNormalRecordAdvBeanList(0);
  1105 + // 清理挂角广告数据
  1106 + clearNormalRecordAdvBeanList(1);
  1107 +
  1108 + }
  1109 +
  1110 + /**
  1111 + * 清理普通广告记录
  1112 + *
  1113 + * @param type 0:开屏
  1114 + * 1:挂角
  1115 + */
  1116 + public static void clearNormalRecordAdvBeanList(int type) {
  1117 + // 切换账号清理广告数据
  1118 + StringBuilder fileName = new StringBuilder();
  1119 + fileName.append(ADS_RECORD);
  1120 + if (type == 0) {
  1121 + fileName.append("_");
  1122 + fileName.append(TYPE_LAUNCH);
  1123 + } else if (type == 1) {
  1124 + fileName.append("_");
  1125 + fileName.append(TYPE_CORNERS);
  1126 + }
  1127 + // 清理未登录的广告数据
  1128 + new ConfigBase(fileName.toString()).removeWithSP(ADS_RECORD);
  1129 + }
  1130 +
  1131 + /**
  1132 + * 是否首次使用引导页
  1133 + *
  1134 + * @return 默认true
  1135 + */
  1136 + public static boolean isFirstGuideFlag() {
  1137 + return new ConfigBase(FILENAME_RMRB).getBooleanWithSP(APP_FIRST_GUIDE, true);
  1138 + }
  1139 +
  1140 + /**
  1141 + * 修改首次使用引导页
  1142 + */
  1143 + public static void editFirstGuideFlag() {
  1144 + new ConfigBase(FILENAME_RMRB).putWithSP(APP_FIRST_GUIDE, false);
  1145 + }
  1146 +
  1147 + /**
  1148 + * 保存用户协议版本
  1149 + */
  1150 + public static void saveUserAgreeVersion(String version) {
  1151 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_AGREE_VERSION, version);
  1152 + }
  1153 +
  1154 + /**
  1155 + * 获取用户协议版本
  1156 + *
  1157 + * @return
  1158 + */
  1159 + public static String getUserAgreeVersion() {
  1160 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_AGREE_VERSION);
  1161 + }
  1162 +
  1163 + public static void saveUserStatus(String userStatus) {
  1164 + try {
  1165 + new ConfigBase(FILENAME_PLAY_UTILS).putWithSP(USER_STATUS, userStatus);
  1166 + } catch (NumberFormatException e) {
  1167 + }
  1168 + }
  1169 +
  1170 + /**
  1171 + * 获取用户活动展示权限:0:有权限 1:无权限, 默认有权限(普通用户)
  1172 + */
  1173 + public static String getUserStatus() {
  1174 + return new ConfigBase(FILENAME_PLAY_UTILS).getStringWithSP(USER_STATUS);
  1175 + }
  1176 +
  1177 + /**
  1178 + * 保存隐私政策版本号
  1179 + */
  1180 + public static void savePrivateAgreeVersion(String version) {
  1181 + new ConfigBase(FILENAME_RMRB).putWithSP(PRIVATE_AGREE_VERSION, version);
  1182 + }
  1183 +
  1184 + /**
  1185 + * 获取隐私政策版本号
  1186 + *
  1187 + * @return
  1188 + */
  1189 + public static String getPrivateAgreeVersion() {
  1190 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PRIVATE_AGREE_VERSION);
  1191 + }
  1192 +
  1193 + /**
  1194 + * 保存用户协议
  1195 + */
  1196 + public static void saveUserAgreeUrl(String h5url) {
  1197 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_AGREE_URL, h5url);
  1198 + }
  1199 +
  1200 + public static String getUserAgreeUrl() {
  1201 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_AGREE_URL);
  1202 + }
  1203 +
  1204 + /**
  1205 + * 保存隐私政策
  1206 + */
  1207 + public static void savePrivateAgreeUrl(String h5url) {
  1208 + new ConfigBase(FILENAME_RMRB).putWithSP(PRIVATE_AGREE_URL, h5url);
  1209 + }
  1210 +
  1211 + public static String getPrivateAgreeUrl() {
  1212 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PRIVATE_AGREE_URL);
  1213 + }
  1214 +
  1215 + /**
  1216 + * 保存隐私政策中相应权限
  1217 + */
  1218 + public static void saveCameraPermissionUrl(String url) {
  1219 + new ConfigBase(FILENAME_RMRB).putWithSP(PRIVATE_CAMERA_URL, url);
  1220 + }
  1221 +
  1222 + /**
  1223 + * 获取隐私政策中相应权限
  1224 + *
  1225 + * @return
  1226 + */
  1227 + public static String getCameraPermissionUrl() {
  1228 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PRIVATE_CERTIFICATION_URL, "");
  1229 + }
  1230 +
  1231 + /**
  1232 + * 保存留言板隐私协议
  1233 + */
  1234 + public static void saveMessageBoardPrivateUrl(String url) {
  1235 + new ConfigBase(FILENAME_RMRB).putWithSP(MESSAGE_BOARD_PRIVATE_URL, url);
  1236 + }
  1237 +
  1238 + /**
  1239 + * 获取留言板隐私协议
  1240 + *
  1241 + * @return
  1242 + */
  1243 + public static String getMessageBoardPrivateUrl() {
  1244 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(MESSAGE_BOARD_PRIVATE_URL, "");
  1245 + }
  1246 +
  1247 + /**
  1248 + * 保存留言板用户协议
  1249 + */
  1250 + public static void saveMessageBoardUserUrl(String url) {
  1251 + new ConfigBase(FILENAME_RMRB).putWithSP(MESSAGE_BOARD_USER_URL, url);
  1252 + }
  1253 +
  1254 + /**
  1255 + * 获取留言板用户协议
  1256 + *
  1257 + * @return
  1258 + */
  1259 + public static String getMessageBoardUserUrl() {
  1260 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(MESSAGE_BOARD_USER_URL, "");
  1261 + }
  1262 +
  1263 + /**
  1264 + * 保存留言板发布提问规定
  1265 + */
  1266 + public static void saveMessageBoardPublishUrl(String url) {
  1267 + new ConfigBase(FILENAME_RMRB).putWithSP(MESSAGE_BOARD_PULISH_URL, url);
  1268 + }
  1269 +
  1270 + /**
  1271 + * 获取留言板发布提问规定
  1272 + *
  1273 + * @return
  1274 + */
  1275 + public static String getMessageBoardPublishUrl() {
  1276 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(MESSAGE_BOARD_PULISH_URL, "");
  1277 + }
  1278 +
  1279 + /**
  1280 + * 保存注销协议
  1281 + */
  1282 + public static void saveLogoutAgreeUrl(String h5url) {
  1283 + new ConfigBase(FILENAME_RMRB).putWithSP(LOG_OUT_AGREE_URL, h5url);
  1284 + }
  1285 +
  1286 + public static String getLogoutAgreeUrl() {
  1287 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(LOG_OUT_AGREE_URL);
  1288 + }
  1289 +
  1290 + /**
  1291 + * 保存实名认证服务协议
  1292 + */
  1293 + public static void saveCertificationUrl(String url) {
  1294 + new ConfigBase(FILENAME_RMRB).putWithSP(PRIVATE_CERTIFICATION_URL, url);
  1295 + }
  1296 +
  1297 + /**
  1298 + * 获取实名认证服务协议
  1299 + *
  1300 + * @return
  1301 + */
  1302 + public static String getCertificationionUrl() {
  1303 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PRIVATE_CERTIFICATION_URL, "");
  1304 + }
  1305 +
  1306 + /**
  1307 + * 保存直播规范
  1308 + */
  1309 + public static void saveLiveBroadcastUrl(String h5url) {
  1310 + new ConfigBase(FILENAME_RMRB).putWithSP(PRIVATE_LIVEBROADCAST_URL, h5url);
  1311 + }
  1312 +
  1313 + /**
  1314 + * 获取直播规范
  1315 + */
  1316 + public static String getLiveBroadcastUrl() {
  1317 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PRIVATE_LIVEBROADCAST_URL);
  1318 + }
  1319 +
  1320 + /**
  1321 + * 保存直播协议
  1322 + */
  1323 + public static void saveLiveProtocalUrl(String h5url) {
  1324 + new ConfigBase(FILENAME_RMRB).putWithSP(PRIVATE_LIVEPROTOCAL_URL, h5url);
  1325 + }
  1326 +
  1327 + /**
  1328 + * 获取直播协议
  1329 + */
  1330 + public static String getLiveProtocalUrl() {
  1331 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PRIVATE_LIVEPROTOCAL_URL);
  1332 + }
  1333 +
  1334 + /**
  1335 + * 保存区、县编码
  1336 + */
  1337 + public static void saveDistrictCode(String districtCode) {
  1338 + CITY_DISTRICTCODE_VALUE = districtCode;
  1339 + new ConfigBase(FILENAME_RMRB).putWithSP(DISTRICT_CODE, districtCode);
  1340 + }
  1341 +
  1342 + /**
  1343 + * 存储问政频道地理信息
  1344 + *
  1345 + * @param fullCode
  1346 + */
  1347 + public static void saveWenZhenChannelAreaCode(String fullCode) {
  1348 + new ConfigBase(FILENAME_RMRB).putWithSP(WENZHEN_CHANNEL_AREA, fullCode);
  1349 + }
  1350 +
  1351 + /**
  1352 + * 获取问政频道地理信息code
  1353 + *
  1354 + * @return
  1355 + */
  1356 + public static String getWenZhenChannelAreaCode() {
  1357 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(WENZHEN_CHANNEL_AREA, "");
  1358 + }
  1359 +
  1360 + /**
  1361 + * 存储问政频道地理信息名称
  1362 + *
  1363 + * @param fullCode
  1364 + */
  1365 + public static void saveWenZhenChannelAreaName(String fullCode) {
  1366 + new ConfigBase(FILENAME_RMRB).putWithSP(WENZHEN_CHANNEL_AREA_NAME, fullCode);
  1367 + }
  1368 +
  1369 + /**
  1370 + * 获取问政频道地理信息名称
  1371 + *
  1372 + * @return
  1373 + */
  1374 + public static String getWenZhenChannelAreaName() {
  1375 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(WENZHEN_CHANNEL_AREA_NAME, "");
  1376 + }
  1377 +
  1378 + public static String getUserLocalProviceName() {
  1379 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PROVINCE, "");
  1380 + }
  1381 +
  1382 + public static void saveUserLocalProviceName(String proviceName) {
  1383 + new ConfigBase(FILENAME_RMRB).putWithSP(PROVINCE, proviceName);
  1384 + }
  1385 +
  1386 + /**
  1387 + * 存储直播红点提示的md5值
  1388 + *
  1389 + * @param liveMd5
  1390 + */
  1391 + public static void saveLiveIdMD5(String liveMd5) {
  1392 +
  1393 + new ConfigBase(FILENAME_RMRB).putWithSP(LIVE_RED_POINT_DATA, liveMd5);
  1394 + }
  1395 +
  1396 + /**
  1397 + * 获取直播红点提示的md5值
  1398 + *
  1399 + * @return
  1400 + */
  1401 + public static String getLiveIdMD5() {
  1402 +
  1403 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(LIVE_RED_POINT_DATA, "");
  1404 + }
  1405 +
  1406 + /**
  1407 + * 存储个人中心红点提示的md5值
  1408 + *
  1409 + * @param askMd5
  1410 + */
  1411 + public static void saveAskMarkMD5(String askMd5) {
  1412 + new ConfigBase(FILENAME_RMRB).putWithSP(ASK_RED_POINT_DATA, askMd5);
  1413 + }
  1414 +
  1415 + /**
  1416 + * 获取个人中心问政红点提示的md5值
  1417 + *
  1418 + * @return
  1419 + */
  1420 + public static String getAskMarkMD5() {
  1421 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(ASK_RED_POINT_DATA, "");
  1422 + }
  1423 +
  1424 + /**
  1425 + * 获取区、县编码
  1426 + */
  1427 + public static String getDistrictCode() {
  1428 + if (!TextUtils.isEmpty(CITY_DISTRICTCODE_VALUE)) {
  1429 + return CITY_DISTRICTCODE_VALUE;
  1430 + }
  1431 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(DISTRICT_CODE);
  1432 + }
  1433 +
  1434 + /**
  1435 + * 获取是否拒绝过定位权限
  1436 + */
  1437 + public static boolean getRefusedLocation() {
  1438 + return new ConfigBase(CONFIG_SAVE_FILE).getBooleanWithSP(LOCATION_PERMISSION, false);
  1439 + }
  1440 +
  1441 + /**
  1442 + * 保存是否拒绝过定位权限
  1443 + */
  1444 + public static void saveRefusedLocation(boolean b) {
  1445 + new ConfigBase(CONFIG_SAVE_FILE).putWithSP(LOCATION_PERMISSION, b);
  1446 + }
  1447 +
  1448 + /**
  1449 + * 设置广告展示的次数
  1450 + *
  1451 + * @param type 广告类型
  1452 + * @param id 广告id
  1453 + * @return
  1454 + */
  1455 + public static void setAdvShowCount(String type, String id) {
  1456 + int count = getAdvShowCount(type, id);
  1457 + count = count + 1;
  1458 + new ConfigBase(SpUtils.ADV_SAVE_FILE).putWithSP(SpUtils.ADV_ + type + "_" + id + "_" + SpUtils.getUserId(),
  1459 + count);
  1460 + }
  1461 +
  1462 + /**
  1463 + * 获取广告展示的次数
  1464 + *
  1465 + * @param type 广告类型
  1466 + * @param id 广告id
  1467 + * @return
  1468 + */
  1469 + public static Integer getAdvShowCount(String type, String id) {
  1470 + return new ConfigBase(SpUtils.ADV_SAVE_FILE)
  1471 + .getIntWithSP(SpUtils.ADV_ + type + "_" + id + "_" + SpUtils.getUserId(), 0);
  1472 + }
  1473 +
  1474 + /**
  1475 + * 获取覆盖安装前的版本号
  1476 + */
  1477 + public static String getLastAppVersion() {
  1478 + return new ConfigBase(CONFIG_SAVE_FILE).getStringWithSP(LAST_APP_VERSION, "");
  1479 + }
  1480 +
  1481 + /**
  1482 + * 保存覆盖安装前的版本号
  1483 + */
  1484 + public static void saveLastAppVersion(String version) {
  1485 + new ConfigBase(CONFIG_SAVE_FILE).putWithSP(LAST_APP_VERSION, version);
  1486 + }
  1487 +
  1488 + /**
  1489 + * 获取邀请码
  1490 + */
  1491 + public static String getInviterCode() {
  1492 + return new ConfigBase(CONFIG_SAVE_FILE).getStringWithSP(INVITER_CODE, "");
  1493 + }
  1494 +
  1495 + /**
  1496 + * 保存邀请码
  1497 + */
  1498 + public static void saveInviterCode(String inviterCode) {
  1499 + new ConfigBase(CONFIG_SAVE_FILE).putWithSP(INVITER_CODE, inviterCode);
  1500 + }
  1501 +
  1502 + /**
  1503 + * 保存推送开关
  1504 + *
  1505 + * @param tag
  1506 + */
  1507 + public static void savePushSwitchTag(String tag) {
  1508 + new ConfigBase(FILENAME_RMRB).putWithSP(UM_PUSH_SWITCH, tag);
  1509 + }
  1510 +
  1511 + /**
  1512 + * 获取推送开关状态
  1513 + *
  1514 + * @return
  1515 + */
  1516 + public static String getPushSwitchTag() {
  1517 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(UM_PUSH_SWITCH);
  1518 + }
  1519 +
  1520 + public static void saveWifiLoadImgTag(String tag) {
  1521 + new ConfigBase(FILENAME_RMRB).putWithSP(WIFI_LOAD_IMG_SWITCH, tag);
  1522 + }
  1523 +
  1524 + /**
  1525 + * 默认关闭
  1526 + * 仅wifi网络加载图片:默认关闭
  1527 + *
  1528 + * @return
  1529 + */
  1530 + public static String getWifiLoadImgSwitchTag() {
  1531 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(WIFI_LOAD_IMG_SWITCH, "0");
  1532 + }
  1533 +
  1534 + public static void saveWifiPlayVideoTag(String tag) {
  1535 + new ConfigBase(FILENAME_RMRB).putWithSP(WIFI_PLAY_VIDEO_SWITCH, tag);
  1536 + }
  1537 +
  1538 + /**
  1539 + * 默认开启
  1540 + * wifi网络下自动播放视频:默认打开
  1541 + *
  1542 + * @return
  1543 + */
  1544 + public static String getWifiPlayVideoSwitchTag() {
  1545 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(WIFI_PLAY_VIDEO_SWITCH, "1");
  1546 + }
  1547 +
  1548 + public static void savePlayVideoWindowTag(String tag) {
  1549 + new ConfigBase(FILENAME_RMRB).putWithSP(PLAY_VIDEO_WINDOW_SWITCH, tag);
  1550 + }
  1551 +
  1552 + /**
  1553 + * 默认关闭画中画
  1554 + *
  1555 + * @return 1 是开启 0 是关闭
  1556 + */
  1557 + public static String getPlayVideoWindowSwitchTag() {
  1558 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PLAY_VIDEO_WINDOW_SWITCH, "0");
  1559 + }
  1560 +
  1561 + // 记录token有效期加载加载时间
  1562 + public static long getLiveTokenTime() {
  1563 + return new ConfigBase(FILENAME_RMRB).getLongWithSP(LIVE_TOKEN_TIME, 0);
  1564 + }
  1565 +
  1566 + public static void saveLiveTokeTime(long time) {
  1567 + new ConfigBase(FILENAME_RMRB).put(LIVE_TOKEN_TIME, time);
  1568 + }
  1569 +
  1570 + // 记录accessToken
  1571 + public static String getLiveAccessToken() {
  1572 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(LIVE_ACCESSTOKEN, "");
  1573 + }
  1574 +
  1575 + public static void saveLiveAccessToken(String accessToken) {
  1576 + new ConfigBase(FILENAME_RMRB).put(LIVE_ACCESSTOKEN, accessToken);
  1577 + }
  1578 +
  1579 + // 记录refreshToken
  1580 + public static String getLiveRefreshToken() {
  1581 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(LIVE_REFRESHTOKEN, "");
  1582 + }
  1583 +
  1584 + public static void saveLiveRefreshToken(String refreshToken) {
  1585 + new ConfigBase(FILENAME_RMRB).put(LIVE_REFRESHTOKEN, refreshToken);
  1586 + }
  1587 +
  1588 + /**
  1589 + * 保存IMAPPID
  1590 + */
  1591 + public static void saveIMAppId(String appid) {
  1592 + new ConfigBase(FILENAME_RMRB).putWithSP(LIVE_IM_APPID, appid);
  1593 + }
  1594 +
  1595 + /**
  1596 + * 保存IMAPPKEY
  1597 + */
  1598 + public static void saveIMAppkey(String appKey) {
  1599 + new ConfigBase(FILENAME_RMRB).putWithSP(LIVE_IM_APPKEY, appKey);
  1600 + }
  1601 +
  1602 + /**
  1603 + * 获取IMAPPKEY
  1604 + *
  1605 + * @return
  1606 + */
  1607 + public static String getIMAppKey() {
  1608 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(LIVE_IM_APPKEY);
  1609 + }
  1610 +
  1611 + /**
  1612 + * 清理用户信息
  1613 + */
  1614 + public static void clearUserInfo() {
  1615 + saveUserToken("");
  1616 + saveUserId("");
  1617 + saveUserName("");
  1618 + saveCreatorId("");
  1619 + saveRefreshToken("");
  1620 + saveUserType(-1);
  1621 + saveHeadPhotoUrl("");
  1622 + saveUserLevel("");
  1623 + saveIMAppId("");
  1624 + saveIMAppkey("");
  1625 + saveLiveTokeTime(3600000L);
  1626 + saveLiveAccessToken("");
  1627 + saveLiveRefreshToken("");
  1628 + saveSex("");
  1629 + saveBirthday("");
  1630 + }
  1631 +
  1632 + /**
  1633 + * 获取推送数据
  1634 + */
  1635 + public static String getpushData() {
  1636 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PUSH_DATA, "");
  1637 + }
  1638 +
  1639 + /**
  1640 + * 保存推送数据
  1641 + */
  1642 + public static void savePushData(String strData) {
  1643 + new ConfigBase(FILENAME_RMRB).putWithSP(PUSH_DATA, strData);
  1644 + }
  1645 +
  1646 + /**
  1647 + * 保存推送数据
  1648 + */
  1649 + public static void savePushMessageId(String strData) {
  1650 + new ConfigBase(FILENAME_RMRB).putWithSP(PUSH_MESSAGEID, strData);
  1651 + }
  1652 +
  1653 + /**
  1654 + * 获取推送数据
  1655 + */
  1656 + public static String getPushMessageId() {
  1657 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(PUSH_MESSAGEID, "");
  1658 + }
  1659 +
  1660 + /**
  1661 + * 保存夜间模式状态
  1662 + *
  1663 + * @param mode 日间模式(默认)、夜间模式、跟随系统
  1664 + * Light Mode 、Night Mode 、Follow-up System
  1665 + **/
  1666 + public static void saveNightMode(String mode) {
  1667 + new ConfigBase(LAUNCH).putWithSP(SET_NIGHTMODE, mode);
  1668 + }
  1669 +
  1670 + /**
  1671 + * 获取本地配置的夜间模式状态
  1672 + * 日间模式
  1673 + * 夜间模式
  1674 + * 跟随系统
  1675 + *
  1676 + * @return
  1677 + */
  1678 + public static String getNightMode() {
  1679 + return new ConfigBase(LAUNCH).getStringWithSP(SET_NIGHTMODE, LIGHT_MODE);
  1680 + }
  1681 +
  1682 + /**
  1683 + * 获取实时的夜间模式状态
  1684 + * 日间模式 false
  1685 + * 夜间模式 true
  1686 + */
  1687 + public static boolean isNightMode() {
  1688 + // 获取夜间模式状态
  1689 + String nightModeState = SpUtils.getNightMode();
  1690 + // 注释系统设置来改变夜间模式
  1691 + /*
  1692 + * if (SpUtils.FOLLOWUP_SYSTEM.equals(nightModeState)) {
  1693 + * //获取系统深浅色
  1694 + * switch (AppContext.getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK)
  1695 + * {
  1696 + * case Configuration.UI_MODE_NIGHT_YES:
  1697 + * //深色夜间模式
  1698 + * nightModeState = SpUtils.NIGHT_MODE;
  1699 + * break;
  1700 + * case Configuration.UI_MODE_NIGHT_NO:
  1701 + * // 浅色日间模式
  1702 + * nightModeState = SpUtils.LIGHT_MODE;
  1703 + * break;
  1704 + * default:
  1705 + * break;
  1706 + * }
  1707 + * }
  1708 + */
  1709 + return SpUtils.NIGHT_MODE.equals(nightModeState);
  1710 + }
  1711 +
  1712 + /**
  1713 + * 视频播放使用wifi
  1714 + *
  1715 + * @param isWifi
  1716 + */
  1717 + public static void saveNoUseWifiForVideo(boolean isWifi) {
  1718 + new ConfigBase(LAUNCH).putWithSP(NO_USER_WIFI_FOR_VIDEO, isWifi);
  1719 + }
  1720 +
  1721 + public static boolean getNoUseWifiForVideo() {
  1722 + return new ConfigBase(LAUNCH).getBooleanWithSP(NO_USER_WIFI_FOR_VIDEO, false);
  1723 + }
  1724 +
  1725 + /**
  1726 + * 开屏数据
  1727 + */
  1728 + public static void saveSplashCache(String json) {
  1729 + new ConfigBase(LAUNCH).putWithSP(SPLASHINFO, json);
  1730 + }
  1731 +
  1732 + public static String getSplashCache() {
  1733 + return new ConfigBase(LAUNCH).getStringWithSP(SPLASHINFO, "");
  1734 + }
  1735 +
  1736 + public static void setSplashCacheType(int type) {
  1737 + new ConfigBase(LAUNCH).putWithSP(SPLASH_CACHE_TYPE, type);
  1738 + }
  1739 +
  1740 + public static int getSplashCacheType() {
  1741 + return new ConfigBase(LAUNCH).getIntWithSP(SPLASH_CACHE_TYPE, 0);
  1742 + }
  1743 +
  1744 + public static void setSplashCacheMd5(String md5) {
  1745 + new ConfigBase(LAUNCH).putWithSP(SPLASH_CACHE_MD5, md5);
  1746 + }
  1747 +
  1748 + public static String getSplashCacheMd5() {
  1749 + return new ConfigBase(LAUNCH).getStringWithSP(SPLASH_CACHE_MD5, "");
  1750 + }
  1751 +
  1752 + /**
  1753 + * 保存设备id
  1754 + */
  1755 + public static void saveDeviceId(String deviceId) {
  1756 + new ConfigBase(FILENAME_RMRB).putWithSP(DEVICE_ID, deviceId);
  1757 + }
  1758 +
  1759 + /**
  1760 + * 获取设备id
  1761 + *
  1762 + * @return
  1763 + */
  1764 + public static String getDeviceId() {
  1765 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(DEVICE_ID, "");
  1766 + }
  1767 +
  1768 + /**
  1769 + * 记录邮件订阅曝光时间
  1770 + *
  1771 + * @param exporeTime
  1772 + */
  1773 + public static void saveSubEmailExporeTime(long exporeTime) {
  1774 + //
  1775 + new ConfigBase(FILENAME_RMRB).putWithSP(SUB_EMAIL_EXPORE, exporeTime);
  1776 + }
  1777 +
  1778 + /**
  1779 + * 获取邮件订阅曝光时间
  1780 + *
  1781 + * @return
  1782 + */
  1783 + public static long getSubEmailExporeTime() {
  1784 + return new ConfigBase(FILENAME_RMRB).getLongWithSP(SUB_EMAIL_EXPORE, 0);
  1785 + }
  1786 +
  1787 + /**
  1788 + * 更新单次升级id
  1789 + **/
  1790 + public static void saveUpdateOnceState(String mode) {
  1791 + new ConfigBase(LAUNCH).putWithSP(UPDATE_ID, mode);
  1792 + }
  1793 +
  1794 + /**
  1795 + * 上次单次升级id
  1796 + *
  1797 + * @return
  1798 + */
  1799 + public static String getUpdateOnceState() {
  1800 + return new ConfigBase(LAUNCH).getStringWithSP(UPDATE_ID, "");
  1801 + }
  1802 +
  1803 + /**
  1804 + * 保存语音播报图文详情页参数
  1805 + */
  1806 + public static void saveContentId(String mContentId) {
  1807 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(CONTENT_ID, mContentId);
  1808 + }
  1809 +
  1810 + public static void saveContentType(String mContentType) {
  1811 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(CONTENT_TYPE, mContentType);
  1812 + }
  1813 +
  1814 + public static void saveTopicId(String mTopicId) {
  1815 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(TOPIC_ID, mTopicId);
  1816 + }
  1817 +
  1818 + public static void saveChannelId(String mChannelId) {
  1819 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(CHANNEL_ID, mChannelId);
  1820 + }
  1821 +
  1822 + public static void saveCompId(String mCompId) {
  1823 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(COMP_ID, mCompId);
  1824 + }
  1825 +
  1826 + public static void saveSourcePage(String mSourcePage) {
  1827 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(SOURCE_PAGE, mSourcePage);
  1828 + }
  1829 +
  1830 + public static void saveContentRelType(String contentRelType) {
  1831 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(CONTENT_REL_TYPE, contentRelType);
  1832 + }
  1833 +
  1834 + public static void saveContentRelId(String contentRelId) {
  1835 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(CONTENT_REL_ID, contentRelId);
  1836 + }
  1837 +
  1838 + public static void saveScrollToBottom(boolean scrollToBottom) {
  1839 + new ConfigBase(ARTICLE_DETAIL_SP).putWithSP(SCROLL_TO_BOTTOM, scrollToBottom);
  1840 + }
  1841 +
  1842 + /**
  1843 + * 获取语音播报图文详情页参数
  1844 + *
  1845 + * @return
  1846 + */
  1847 + public static String getContentId() {
  1848 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(CONTENT_ID);
  1849 + }
  1850 +
  1851 + public static String getContentType() {
  1852 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(CONTENT_TYPE);
  1853 + }
  1854 +
  1855 + public static String getTopicId() {
  1856 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(TOPIC_ID);
  1857 + }
  1858 +
  1859 + public static String getChannelId() {
  1860 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(CHANNEL_ID);
  1861 + }
  1862 +
  1863 + public static String getCompId() {
  1864 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(COMP_ID);
  1865 + }
  1866 +
  1867 + public static String getSourcePage() {
  1868 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(SOURCE_PAGE);
  1869 + }
  1870 +
  1871 + public static String getRelID() {
  1872 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(CONTENT_REL_ID);
  1873 + }
  1874 +
  1875 + public static String getRelType() {
  1876 + return new ConfigBase(ARTICLE_DETAIL_SP).getStringWithSP(CONTENT_REL_TYPE);
  1877 + }
  1878 +
  1879 + public static boolean getScrollToBottom() {
  1880 + return new ConfigBase(ARTICLE_DETAIL_SP).getBooleanWithSP(SCROLL_TO_BOTTOM);
  1881 + }
  1882 +
  1883 + /**
  1884 + * 首页默认选中项
  1885 + */
  1886 + public static String getKeyDefaultChannelId() {
  1887 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(KEY_DEFAULT_CHANNEL_ID, "");
  1888 + }
  1889 +
  1890 + public static void setKeyDefaultChannelId(String keyRecommend) {
  1891 + new ConfigBase(FILENAME_RMRB).putWithSP(KEY_DEFAULT_CHANNEL_ID, keyRecommend);
  1892 + }
  1893 +
  1894 + /**
  1895 + * 获取经度
  1896 + */
  1897 + public static String getLongitude() {
  1898 + return new ConfigBase(FILENAME_PLAY_UTILS).getStringWithSP(LOCATION_LONGITUDE);
  1899 + }
  1900 +
  1901 + /**
  1902 + * 保存经度
  1903 + *
  1904 + * @param longitude
  1905 + */
  1906 + public static void saveLongitude(String longitude) {
  1907 + new ConfigBase(FILENAME_PLAY_UTILS).putWithSP(LOCATION_LONGITUDE, longitude);
  1908 + }
  1909 +
  1910 + /**
  1911 + * 获取纬度
  1912 + */
  1913 + public static String getLatitude() {
  1914 + return new ConfigBase(FILENAME_PLAY_UTILS).getStringWithSP(LOCATION_LATITUDE);
  1915 + }
  1916 +
  1917 + /**
  1918 + * 保存纬度
  1919 + *
  1920 + * @param latitude
  1921 + */
  1922 + public static void saveLatitude(String latitude) {
  1923 + new ConfigBase(FILENAME_PLAY_UTILS).putWithSP(LOCATION_LATITUDE, latitude);
  1924 + }
  1925 +
  1926 + /**
  1927 + * 获取地址
  1928 + *
  1929 + * @return
  1930 + */
  1931 + public static String getAddress() {
  1932 + return new ConfigBase(FILENAME_PLAY_UTILS).getStringWithSP(LOCATION_ADDRESS);
  1933 + }
  1934 +
  1935 + /**
  1936 + * 保存地址
  1937 + *
  1938 + * @param address
  1939 + */
  1940 + public static void saveAddress(String address) {
  1941 + new ConfigBase(FILENAME_PLAY_UTILS).putWithSP(LOCATION_ADDRESS, address);
  1942 + }
  1943 +
  1944 + /**
  1945 + * 是否拉起
  1946 + */
  1947 + public static boolean isPullup = false;
  1948 +
  1949 + /**
  1950 + * 拉起是否经过appmain oncreate方法
  1951 + */
  1952 + public static boolean isAppMainCreate = false;
  1953 +
  1954 + /**
  1955 + * 拉起数据缓存
  1956 + */
  1957 + public static String pulldata = "";
  1958 +
  1959 + /**
  1960 + * 获取视频播放环境设置
  1961 + */
  1962 + public static int getVideoPlayback() {
  1963 + return new ConfigBase(FILENAME_RMRB).getIntWithSP(VIDEO_PLAYBACK, 0);
  1964 + }
  1965 +
  1966 + /**
  1967 + * 保存用户活动权限
  1968 + */
  1969 + public static void saveUserActivityControl(int activityControl) {
  1970 + try {
  1971 + new ConfigBase(FILENAME_PLAY_UTILS).putWithSP(USER_ACTIVITY_CONTROL, activityControl);
  1972 + } catch (NumberFormatException e) {
  1973 + }
  1974 + }
  1975 +
  1976 + /**
  1977 + * 获取用户活动展示权限:0:有权限 1:无权限, 默认有权限(普通用户)
  1978 + */
  1979 + public static int getUserActivityControl() {
  1980 + return new ConfigBase(FILENAME_PLAY_UTILS).getIntWithSP(USER_ACTIVITY_CONTROL, 0);
  1981 + }
  1982 +
  1983 + /**
  1984 + * 发布本地的上传状态
  1985 + */
  1986 + private static final String PUBLISH_UPLOAD_STATUS = "publish_upload_status";
  1987 +
  1988 + /**
  1989 + * 是否正在上传视频
  1990 + *
  1991 + * @return 默认true
  1992 + */
  1993 + public static boolean isPublishUploading() {
  1994 + return new ConfigBase(FILENAME_PLAY_UTILS).getBooleanWithSP(PUBLISH_UPLOAD_STATUS, false);
  1995 + }
  1996 +
  1997 + /**
  1998 + * 修改发布视频本地的上传状态为上传中
  1999 + */
  2000 + public static void setPublishUploadStatusIsRunning() {
  2001 + new ConfigBase(FILENAME_PLAY_UTILS).putWithSP(PUBLISH_UPLOAD_STATUS, true);
  2002 + }
  2003 +
  2004 + /**
  2005 + * 修改发布视频本地的上传状态为上传完成
  2006 + */
  2007 + public static void setPublishUploadStatusIsComplete() {
  2008 + new ConfigBase(FILENAME_PLAY_UTILS).putWithSP(PUBLISH_UPLOAD_STATUS, false);
  2009 + }
  2010 +
  2011 + /**
  2012 + * 保存用户是否点过分享海报
  2013 + */
  2014 + public static void saveShareIconNewClick(int click) {
  2015 + new ConfigBase(FILENAME_RMRB).putWithSP(SHARE_ICON_NEW_TAG, click);
  2016 + }
  2017 +
  2018 + /**
  2019 + * 获取用户是否点过分享海报
  2020 + */
  2021 + public static int getShareIconNewClick() {
  2022 + return new ConfigBase(FILENAME_RMRB).getIntWithSP(SHARE_ICON_NEW_TAG, 0);
  2023 + }
  2024 +
  2025 + /**
  2026 + * 用户是否听过次音乐
  2027 + */
  2028 + public static void saveUserMusicOldId(String name) {
  2029 + new ConfigBase(FILENAME_RMRB).putWithSP(USER_MUSIC_OLD_ID, name);
  2030 + }
  2031 +
  2032 + /**
  2033 + * 用户是否听过次音乐
  2034 + */
  2035 + public static String getUserMusicOldId() {
  2036 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(USER_MUSIC_OLD_ID, "");
  2037 + }
  2038 +
  2039 + /**
  2040 + * 保存推送历史数目
  2041 + *
  2042 + * @param count
  2043 + */
  2044 + public static void savePushMsgCount(int count) {
  2045 + new ConfigBase(FILENAME_RMRB).putWithSP(PUSH_MESSAGE_COUNT, count);
  2046 + }
  2047 +
  2048 + public static int getPushMsgCount() {
  2049 + return new ConfigBase(FILENAME_RMRB).getIntWithSP(PUSH_MESSAGE_COUNT, 0);
  2050 + }
  2051 +
  2052 + /**
  2053 + * 存clientId
  2054 + */
  2055 + public static void saveClientId(String clientId) {
  2056 + new ConfigBase(FILENAME_RMRB).putWithSP(CLIENT_ID, clientId);
  2057 + }
  2058 +
  2059 + /**
  2060 + * get clientId
  2061 + */
  2062 + public static String getClientId() {
  2063 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(CLIENT_ID, "");
  2064 + }
  2065 +
  2066 + public static void saveUpGrade(String version) {
  2067 + new ConfigBase(FILENAME_RMRB).put(ONCE_UPDATE, version);
  2068 + }
  2069 +
  2070 + public static String getUpGrade() {
  2071 + return new ConfigBase(FILENAME_RMRB).getStringWithSP(ONCE_UPDATE, "");
  2072 + }
  2073 +}