public static void setCsrf(String csrf) { if (csrf == null) { return; } if (SessionManager.csrf == null || !SessionManager.csrf.equals(csrf)) { SessionManager.csrf = csrf; SharedData.getInstance().push(Default.CsrfName, csrf); } }
public static void setCookie(String cookie) { if (cookie == null) { return; } if (SessionManager.cookie == null || !SessionManager.cookie.equals(cookie)) { SessionManager.cookie = cookie; SharedData.getInstance().push(Default.CookieName, cookie); } }
public static String getCookie() { if (cookie != null) { return cookie; } // load cookie from SharedData cookie = SharedData.getInstance().get(Default.CookieName); if (cookie != null) { return cookie; } return cookie; }
public static <T> T getModUser(TypeToken token) { // 获取保存的用户数据 String json = SharedData.getInstance().get(USER_INFO); if (json == null) { return null; } JSONObject user; try { user = new JSONObject(json); } catch (JSONException e) { return null; } GsonParser<T> modUser = GsonParser.fromJson(user, token); return modUser.getDetail(); }
public static String getCsrf() { if (csrf != null) { return csrf; } return SharedData.getInstance().get(Default.CsrfName); }
/** 清除用户数据 */ public static void clearUser() { SharedData.getInstance().pop(USER_INFO); }
/** * 保存登陆用户信息 * * @param response */ public static void saveUser(JSONObject response) { SharedData.getInstance().push(USER_INFO, response.toString()); }