kotlin转化
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package com.arpa.hndahesudintocctmsdriver.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.bean.UserBean;
|
||||
import com.dahe.mylibrary.net.JsonUtils;
|
||||
import com.dahe.mylibrary.utils.BaseSPUtils;
|
||||
|
||||
|
||||
public class SPUtils extends BaseSPUtils {
|
||||
|
||||
/**
|
||||
* 存用户信息
|
||||
*
|
||||
* @param context
|
||||
* @param json
|
||||
*/
|
||||
public static void setUserInfo(Context context, String json) {
|
||||
put(context, USER_INFO_KEY, json);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拿用户信息
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static UserBean getUserInfo(Context context) {
|
||||
return JsonUtils.getInstance().fromJson((String) get(context, USER_INFO_KEY, ""), UserBean.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存服务器类型
|
||||
*
|
||||
* @param context
|
||||
* @param isTestService
|
||||
*/
|
||||
public static void setNetServiceType(Context context, boolean isTestService) {
|
||||
put(context, NET_SERVICE_TEST, isTestService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拿服务器类型
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static boolean geNetServiceType(Context context) {
|
||||
return (boolean) get(context, NET_SERVICE_TEST, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存搜索数据
|
||||
*
|
||||
* @param context
|
||||
* @param json
|
||||
*/
|
||||
public static void setSearchCache(Context context, String json) {
|
||||
put(context, SEARRH_CACHE, json);
|
||||
}
|
||||
|
||||
public static String getSearchCache(Context context) {
|
||||
return JsonUtils.getInstance().fromJson((String) get(context, SEARRH_CACHE, ""), String.class);
|
||||
}
|
||||
|
||||
public static void removeSearchCache(Context context) {
|
||||
remove(context, SEARRH_CACHE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航偏好设置
|
||||
*/
|
||||
public static void setNaviPreferenceCache(Context context, String json) {
|
||||
put(context, NAVI_PH_EDIT_CACHE, json);
|
||||
}
|
||||
|
||||
public static String getNaviPreferenceCache(Context context) {
|
||||
return JsonUtils.getInstance().fromJson((String) get(context, NAVI_PH_EDIT_CACHE, ""), String.class);
|
||||
}
|
||||
|
||||
public static void removeNaviPreference(Context context) {
|
||||
remove(context, NAVI_PH_EDIT_CACHE);
|
||||
}
|
||||
|
||||
//第一次登录
|
||||
public static boolean getIsFirstOpen(Context context){
|
||||
boolean b = (boolean) get(context, FIRST_OPEN, true);
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
public static void setIsFirstOpen(Context context, boolean json){
|
||||
put(context, FIRST_OPEN, json);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置隐私协议是否同意
|
||||
*
|
||||
* @param value 是否同意
|
||||
*/
|
||||
public static void setAgreePrivacyAgreement(Context context, boolean value) {
|
||||
put(context, KEY_PRIVACY_AGREEMENT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否同意了隐私协议
|
||||
*
|
||||
* @return true 已经同意;false 还没有同意
|
||||
*/
|
||||
public static boolean hasAgreePrivacyAgreement(Context context) {
|
||||
boolean b = (boolean) get(context, KEY_PRIVACY_AGREEMENT, false);
|
||||
return b;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user