Search in sources :

Example 16 with UserInfoVo

use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.

the class JsonUtil method readLocalInfo.

/**
 * Read local information
 */
public static ArrayList<UserInfoVo> readLocalInfo(Context mContext) {
    String localInfo = MySharedPrefs.readString(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOCAL_USERINFO);
    ArrayList<String> localidList = new ArrayList<>();
    ArrayList<UserInfoVo> localInfoList = new ArrayList<>();
    try {
        JSONArray array = new JSONArray(localInfo);
        if (array.length() > 0) {
            for (int i = 0; i < array.length(); i++) {
                localidList.add(array.optString(i));
            }
        }
        for (int j = 0; j < localidList.size(); j++) {
            String jsonString = MySharedPrefs.readString(mContext, MySharedPrefs.FILE_USER, localidList.get(j));
            JSONObject jsonObject = new JSONObject(jsonString);
            UserInfoVo infoVo = new UserInfoVo().parse(jsonObject.optJSONObject(localidList.get(j)));
            localInfoList.add(infoVo);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return localInfoList;
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo)

Aggregations

UserInfoVo (com.lingtuan.firefly.vo.UserInfoVo)16 JSONObject (org.json.JSONObject)8 JSONException (org.json.JSONException)6 JSONArray (org.json.JSONArray)5 Intent (android.content.Intent)4 RequestListener (com.lingtuan.firefly.listener.RequestListener)4 MainFragmentUI (com.lingtuan.firefly.ui.MainFragmentUI)2 SuppressLint (android.annotation.SuppressLint)1 Configuration (android.content.res.Configuration)1 Resources (android.content.res.Resources)1 Uri (android.net.Uri)1 Handler (android.os.Handler)1 NearByPeopleAdapter (com.lingtuan.firefly.adapter.NearByPeopleAdapter)1 CrashHandler (com.lingtuan.firefly.util.CrashHandler)1 UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)1 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)1 ArrayList (java.util.ArrayList)1