135 lines
3.3 KiB
Java
135 lines
3.3 KiB
Java
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 {
|
|
|
|
private static final String PRE_WEL_PIC = "PRE_WEL_PIC";
|
|
|
|
/**
|
|
* 存用户信息
|
|
*
|
|
* @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;
|
|
}
|
|
|
|
/**
|
|
* 保存欢迎页网络地址
|
|
* @param context
|
|
* @param url
|
|
*/
|
|
public static void setPreWelPic(Context context, String url){
|
|
put(context,PRE_WEL_PIC,url);
|
|
}
|
|
|
|
/**
|
|
* 获取欢迎页地址
|
|
* @param context
|
|
* @return
|
|
*/
|
|
public static String getPreWelPic(Context context){
|
|
return (String) get(context,PRE_WEL_PIC,"");
|
|
}
|
|
|
|
}
|