public static XLLXUserInfo getUserInfoFromLocal(Context context) { SharedPreferences preferences = context.getSharedPreferences(XL_PREFERENCES, Context.MODE_PRIVATE); XLLXUserInfo info = new XLLXUserInfo(); info.autopay = preferences.getInt("autopay", -1); info.daily = preferences.getInt("daily", -1); info.expiredate = preferences.getString("expiredate", ""); info.growvalue = preferences.getInt("growvalue", -1); info.isvip = preferences.getInt("isvip", -1); info.isyear = preferences.getInt("isvip", -1); info.level = preferences.getInt("level", -1); info.nickname = preferences.getString("nickname", ""); info.usrname = preferences.getString("usrname", ""); info.payname = preferences.getString("payname", ""); return info; }
/** * 获取 用户 信息 * * @param url * @param cookieStore * @return */ public static XLLXUserInfo getUser(Context context, Header cookies) { String content = HttpUtils.getContent(USERINFO_URL, new Header[] {cookies}, null); if (content != null) { try { String json = content.substring(content.indexOf("{")); XLLXUserInfo info = new XLLXUserInfo(); JSONTokener jsonParser = new JSONTokener(json); JSONObject object = (JSONObject) jsonParser.nextValue(); info.autopay = Integer.parseInt(object.getString("autopay")); info.daily = Integer.parseInt(object.getString("daily")); info.expiredate = object.getString("expiredate"); info.growvalue = Integer.parseInt(object.getString("growvalue")); info.isvip = Integer.parseInt(object.getString("isvip")); info.isyear = Integer.parseInt(object.getString("isvip")); info.level = Integer.parseInt(object.getString("level")); info.nickname = object.getString("nickname"); info.usrname = object.getString("usrname"); info.payname = object.getString("payname"); saveUserInfo(context, info); return info; } catch (Exception e) { e.printStackTrace(); } } return null; }