public class AppContext extends Application {
	private final String TAG = AppContext.class.getSimpleName();
	private static AppContext mInstance;
	private RequestQueuePool mRequestQueuePool;
	private RequestQueuePool mMulitiRequestQueuePool;

	@Override
	public void onCreate() {
		super.onCreate();
		mInstance = this;

		// 创建 请求队列池
		createRequestQueuePool();

		// debug
		if (Constant.DEBUG) {
			if (TextUtils.isEmpty(ConfigHelper.getInstance().loadLoginUserInfoConfig().getUserId())) {
				ConfigHelper.getInstance().saveLoginUserInfoConfig(new LoginUserInfo(Constant.DEBUG_USER_ID, Constant.DEBUG_USER_PWD));
			}
		}

		// 创建的时候自动登录
		LoginService.getInstance().autoLogin();
	}

	public static AppContext getInstance() {
		return mInstance;
	}

	/**
	 * 创建 请求队列管理池
	 */
	private void createRequestQueuePool() {
		mRequestQueuePool = new RequestQueuePool();
		// 创建多个 请求队列
		for (int i = 0; i < Constant.REQUESTQUEUE_HTTP_REQUEST_SIZE; i++) {
			RequestQueue queue = Volley.newRequestQueue(getApplicationContext(), new HurlStack());
			queue.start();
			mRequestQueuePool.put(queue);
		}
		mMulitiRequestQueuePool = new RequestQueuePool();
		for (int i = 0; i < Constant.REQUESTQUEUE_HTTP_MULITI_REQUEST_SIZE; i++) {
			RequestQueue queue = Volley.newRequestQueue(getApplicationContext(), new MultiPartStack());
			queue.start();
			mMulitiRequestQueuePool.put(queue);
		}
	}

	/**
	 * 获取一个请求队列管理池中的 RequestQueue
	 * 
	 * @return
	 */
	public RequestQueue getRequestQueue() {
		return getRequestQueue(false);
	}

	/**
	 * 获取一个 RequestQueue
	 * 
	 * @param isNew
	 *            时候新建一个新的RequestQueue， </br>true:新建一个新的RequestQueue,并启用
	 *            。但是不会加入到 请求队列管理池当中 </br>false:获取管理池中的一个 RequestQueue
	 * @return
	 */
	public RequestQueue getRequestQueue(boolean isNew) {
		if (isNew) {
			RequestQueue q = Volley.newRequestQueue(getApplicationContext());
			q.start();
			return q;
		} else {
			return mRequestQueuePool.getFreeRequestQueue();
		}
	}

	/**
	 * 获取一个请求队列管理池中的 RequestQueue
	 * 
	 * @return
	 */
	public RequestQueue getMulitiRequestQueue() {
		return getMulitiRequestQueue(false);
	}

	/**
	 * 获取一个 Muliti 类型的 RequestQueue
	 * 
	 * @param isNew
	 *            时候新建一个新的RequestQueue， </br>true:新建一个新的RequestQueue,并启用
	 *            。但是不会加入到 请求队列管理池当中 </br>false:获取管理池中的一个 RequestQueue
	 * @return
	 */
	public RequestQueue getMulitiRequestQueue(boolean isNew) {
		if (isNew) {
			RequestQueue q = Volley.newRequestQueue(getApplicationContext(), new MultiPartStack());
			q.start();
			return q;
		} else {
			return mMulitiRequestQueuePool.getFreeRequestQueue();
		}
	}
} public class Constant {
	public final static boolean DEBUG = true;
	public final static String DEBUG_USER_ID = "453333657@qq.com";
	public final static String DEBUG_USER_PWD = "chenzipeng";

	/**
	 * 服务器配置
	 */
	public final static String SERVER_HOST = "www.lingganhezi.com";
	public final static int SERVER_PORT = 80;
	public final static String SERVER_PART = "/";
	public final static String SERVER_ADD = "http://" + SERVER_HOST + ":" + SERVER_PORT + SERVER_PART;

	public final static String PROVIDER_AUTHORITY = "com.lingganhezi.myapp.data";

	/**
	 * http 请求队列 ，个数 预先创建多少个 请求队列
	 * 
	 */
	public final static int REQUESTQUEUE_HTTP_REQUEST_SIZE = 4;
	/**
	 * http mulitipat 请求队列 ，个数 预先创建多少个 请求队列
	 * 
	 */
	public final static int REQUESTQUEUE_HTTP_MULITI_REQUEST_SIZE = 2;

	public final static int STATE_CODE_FAILD = 0;
	public final static int STATE_CODE_SUCCESS = 1;

	public final static Uri CONTENT_URI_ARTICLE_PROVIDER = Uri.parse("content://com.lingganhezi.myapp.data.ArticleProvider");
	public final static Uri CONTENT_URI_MESSAGE_SESSION_PROVIDER = Uri.parse("content://com.lingganhezi.myapp.data.MessageSessionProvider");
	public final static Uri CONTENT_URI_USERINFO_PROVIDER = Uri.parse("content://com.lingganhezi.myapp.data.UserInfoProvider");
	public final static Uri CONTENT_URI_PLACE_PROVIDER = Uri.parse("content://com.lingganhezi.myapp.data.PlaceProvider");
	public final static Uri CONTENT_URI_MESSAGE_PROVIDER = Uri.parse("content://com.lingganhezi.myapp.data.MessageProvider");

	/**
	 * 普通文章类型
	 */
	public final static int ARTICLE_TYPE_SPECIAL = -1;
	/**
	 * 专题文章类型，幻灯片
	 */
	public final static int ARTICLE_TYPE_NORMAL = 1;

	/**
	 * 头像 裁剪 图像生成宽高
	 */
	public final static int PERSONAL_AVATAR_CLIP_LENGTH = 200;

	/**
	 * http contenttype
	 */
	public final static ContentType HTTP_CONTENTTYPE_IMAGE_JPEG = ContentType.create("image/jpeg");
	public final static ContentType HTTP_CONTENTTYPE_IMAGE_PNG = ContentType.create("image/png");
	public final static ContentType HTTP_CONTENTTYPE_IMAGE_WBMP = ContentType.create("image/wbmp");

	public final static int SEX_UNKONW = -1;
	public final static int SEX_MAN = 0;
	public final static int SEX_WOMEN = 1;

	/**
	 * 收件箱
	 */
	public final static String MESSAGE_BOX_INBOX = "inbox";
	/**
	 * 发件箱
	 */
	public final static String MESSAGE_BOX_OUTBOX = "outbox";

	public final static int MESSAGE_ID_UNDIFINED = -1;
	public final static int MESSAGE_STATE_SENDING = 0;
	public final static int MESSAGE_STATE_FAILD = -1;
	public final static int MESSAGE_STATE_SENED = 1;

	public final static int MESSAGESESSION_ID_UNDIFINED = -1;
} public class HttpHelper {
	private final static String TAG = HttpHelper.class.getSimpleName();
	public static Gson gson = new Gson();

	public static String parserParameters(Map<String, String> params) {
		StringBuilder paramsStr = new StringBuilder();
		for (Map.Entry<String, String> entry : params.entrySet()) {
			paramsStr.append(entry.getKey());
			paramsStr.append('=');
			paramsStr.append(entry.getValue());
			paramsStr.append('&');
		}
		if (paramsStr.length() > 0) {
			paramsStr.deleteCharAt(paramsStr.length() - 1);
		}
		return paramsStr.toString();
	}

	public static Object getJsonObject(JSONObject json, Class clazz) {
		return gson.fromJson(json.toString(), clazz);
	}

	public static List getJsonArray(JSONArray json, TypeToken token) {
		return gson.fromJson(json.toString(), token.getType());
	}

	/**
	 * 获取 header 的中cookie
	 * 
	 * @param headers
	 * @return
	 */
	public static Map<String, String> getCookieMap(Map<String, String> headers) {
		final String cookieKey = "Set-Cookie";
		if (headers.containsKey(cookieKey)) {
			return parseCookieString(headers.get(cookieKey));

		} else {
			return new HashMap<String, String>();
		}

	}

	/**
	 * 解析header 特殊封装jsonArray格式的 cookie字符串
	 * 
	 * @param cookieString
	 * 
	 * @return
	 */
	public static Map<String, String> parseCookieString(String cookieJsonArrayStr) {
		JSONArray cookieJsonArray = new JSONArray();
		Map<String, String> cookieMap = new HashMap<String, String>();
		try {

			cookieJsonArray = new JSONArray(cookieJsonArrayStr);

			for (int i = 0; i < cookieJsonArray.length(); i++) {
				String cookieStr = cookieJsonArray.getString(i);
				String[] cookieStrs = cookieStr.split(";");
				for (int j = 0; j < cookieStrs.length; j++) {
					String[] onecookie = cookieStrs[j].split("=");
					cookieMap.put(onecookie[0], onecookie[1]);
				}
			}
		} catch (Exception e) {
			Log.e(TAG, "parseCookieString", e);
		}

		return cookieMap;
	}

	/**
	 * 根据一个map返回cookie字符串 </br>格式: a=b;c=d
	 * 
	 * @param cookieMap
	 * @return
	 */
	public static String converCookieToString(Map<String, String> cookieMap) {
		StringBuffer sb = new StringBuffer();
		for (String key : cookieMap.keySet()) {
			sb.append(key);
			sb.append("=");
			sb.append(cookieMap.get(key));
			sb.append(";");
		}
		return sb.toString();
	}

	/**
	 * 根据 cookie字符串 生成 一个map </br>格式: a=b;c=d
	 * 
	 * @param cookieMap
	 * @return
	 */
	public static Map<String, String> converCookieStringToMap(String cookieMapString) {

		if (TextUtils.isEmpty(cookieMapString)) {
			return new HashMap<String, String>();
		}

		Map<String, String> cookieMap = new HashMap<String, String>();
		String[] cookieStrs = cookieMapString.split(";");
		for (int i = 0; i < cookieStrs.length; i++) {
			try {
				String[] onecookie = cookieStrs[i].split("=");
				cookieMap.put(onecookie[0], onecookie[1]);
			} catch (Exception e) {
				Log.w("converCookieStringToMap", e.getMessage());
			}
		}

		return cookieMap;
	}
} public static class PlaceColumns {
	public static final String _ID = BaseColumns._ID;
	public static final String NAME = "NAME";
	public static final String REID = "REID";
	public static final String DISORDER = "DISORDER";
} public static class UserInfoColumns {
	public static final String _ID = BaseColumns._ID;
	public static final String NAME = "NAME";
	public static final String EMAIL = "EMAIL";
	public static final String PORTRAIT = "PORTRAIT";
	public static final String BIRTHDAY = "BIRTHDAY";
	public static final String CITY = "CITY";
	public static final String DESCRIPTION = "DESCRIPTION";
	public static final String SEX = "SEX";
	public static final String ISFRIEND = "ISFRIEND";
} public class LoginUserInfo {
	private UserInfo UserInfo;
	private String userId = "";
	private String password = "";

	public LoginUserInfo(String userid, String password) {
		setUserId(userid);
		setPassword(password);
	}

	public LoginUserInfo(UserInfo userInfo) {
		setUserInfo(userInfo);
	}

	public UserInfo getUserInfo() {
		return UserInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		UserInfo = userInfo;
		if (userInfo != null) {
			userId = userInfo.getId();
		}
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

} public class Place {
	private int id;
	private int reid;
	private String name;
	private int disOrder;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getReid() {
		return reid;
	}

	public void setReid(int reid) {
		this.reid = reid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getDisOrder() {
		return disOrder;
	}

	public void setDisOrder(int disOrder) {
		this.disOrder = disOrder;
	}

} public class Respone {
	public int stateCode;
	public String message;
	private Map data;

	private JSONObject dataJson;

	public JSONObject getData() {
		if (dataJson == null) {
			if (data == null) {
				dataJson = new JSONObject();
			} else {
				dataJson = new JSONObject(data);
			}
		}
		return dataJson;
	}
} public class UserInfo {
	private String id;
	private String name;
	private String email;
	private String birthday;
	private String city;
	private String description;
	private Integer sex;
	private int isFriend;
	/**
	 * 头像
	 */
	private String protrait;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getProtrait() {
		return protrait;
	}

	public void setProtrait(String protrait) {
		this.protrait = protrait;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public int getIsFriend() {
		return isFriend;
	}

	public boolean IsFriend() {
		return isFriend != 0;
	}

	public void setIsFriend(int isFriend) {
		this.isFriend = isFriend;
	}

} public abstract class ResultResponeListener implements Response.Listener<JSONObject> {
	private Respone mResultRespone;
	private Message mMessage;

	@Override
	public void onResponse(JSONObject json) {
		mResultRespone = (Respone) HttpHelper.getJsonObject(json, Respone.class);
		mMessage = new Message();
		setServerMessage();
		if (mResultRespone.stateCode == Constant.STATE_CODE_SUCCESS) {
			handeResponeSuccess(mResultRespone);
		} else {
			handeResponeFaild(mResultRespone);
		}
	}

	/**
	 * 处理成功
	 * 
	 * @param result
	 */
	protected abstract void handeResponeSuccess(Respone result);

	/**
	 * 处理失败
	 * 
	 * @param result
	 */
	protected abstract void handeResponeFaild(Respone result);

	/**
	 * 把reponse 的 message
	 * 
	 * @param message
	 */
	private void setServerMessage() {
		mMessage.getData().putString(BaseService.MESSAGE_FALG, mResultRespone.message);
	}

	/**
	 * 获取 handler 使用的message
	 * 
	 * @return
	 */
	public Message getMessage() {
		return mMessage;
	}

	/**
	 * 获取 handler 使用的message
	 * 
	 * @return
	 */
	public Message getMessage(int what) {
		mMessage.what = what;
		return mMessage;
	}

	/**
	 * 获取 handler 使用的message
	 * 
	 * @return
	 */
	public Message getMessage(int what, Object entry) {
		mMessage.what = what;
		mMessage.obj = entry;
		return mMessage;
	}

	/**
	 * 发送handler 消息
	 * 
	 * @param handler
	 * @param message
	 */
	public void sendHandlerMessage(Handler handler, Message message) {
		if (handler != null) {
			handler.sendMessage(message);
		}
	}
} public class FileUploader {
	private final static String TAG = FileUploader.class.getSimpleName();

	public static FileUploader mInstance;

	private Context mContext;

	private RequestQueue getRequestQueue() {
		return AppContext.getInstance().getMulitiRequestQueue();
	}

	private FileUploader(Context context) {
		mContext = context;
	}

	public static FileUploader getInstance(Context context) {
		if (mInstance == null) {
			mInstance = new FileUploader(context);
		}
		return mInstance;
	}

	/**
	 * 上传文件
	 * 
	 * @param url
	 * @param files
	 *            文件map， key 参数名 ，value 文件路径
	 * @param params
	 *            参数
	 * @param responseListener
	 * @param errorListener
	 * @param contentType
	 */
	public void upload(final String url, final Map<String, File> files, final Map<String, String> params,
			final Response.Listener responseListener, final Response.ErrorListener errorListener, final ContentType contentType) {
		if (null == url || null == responseListener) {
			return;
		}

		FileMultiPartResultRequest multiPartRequest = new FileMultiPartResultRequest(url, responseListener, errorListener) {

			@Override
			public Map<String, File> getFileUploads() {
				return files;
			}

			@Override
			public Map<String, String> getStringUploads() {
				return params;
			}

			@Override
			public ContentType getFileContentType() {
				return contentType;
			}

		};

		// Log.i(TAG, " volley put : uploadFile " + url);

		getRequestQueue().add(multiPartRequest);
	}

	private class FileMultiPartResultRequest extends CustomMultiPartRequest<JSONObject> {

		private final int TIME_OUT = 2 * 60 * 1000;// 上传超时 2分钟
		private final int RETRY_TIMES_MAX = 0;// 不重试

		public FileMultiPartResultRequest(String url, Listener<JSONObject> listener, ErrorListener errorListener) {
			super(Request.Method.POST, url, listener, errorListener);
			setRetryPolicy(new DefaultRetryPolicy(TIME_OUT, RETRY_TIMES_MAX, 1f));
		}

		@Override
		protected void deliverResponse(Object response) {
			if(mListener !=null){
				mListener.onResponse((JSONObject)response);
			}
		}

		@Override
		protected Response parseNetworkResponse(NetworkResponse response) {
			try {
				String parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
				return Response.success( new JSONObject(parsed), HttpHeaderParser.parseCacheHeaders(response));
			} catch (UnsupportedEncodingException e) {
				return Response.error(new ParseError(e));
			} catch (JSONException je) {
				return Response.error(new ParseError(je));
			}
		}
	}
} public class JsonArrayRequest extends Request<JSONArray> {
	private Map<String, String> mParams;
	private Listener<JSONArray> mListener;

	public JsonArrayRequest(String url, Map<String, String> params, Listener<JSONArray> listener, ErrorListener errorListener) {
		super(Method.POST, url, errorListener);
		mListener = listener;
		mParams = params;
	}

	@Override
	protected Map<String, String> getParams() throws AuthFailureError {
		return mParams;
	}

	@Override
	protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
		try {
			String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers));

			// 保存cookie
			ConfigHelper.getInstance().saveCookie(HttpHelper.getCookieMap(response.headers));

			return Response.success(new JSONArray(jsonString), HttpHeaderParser.parseCacheHeaders(response));
		} catch (UnsupportedEncodingException e) {
			return Response.error(new ParseError(e));
		} catch (JSONException je) {
			return Response.error(new ParseError(je));
		}
	}

	@Override
	protected void deliverResponse(JSONArray response) {
		mListener.onResponse(response);
	}

	@Override
	public Map<String, String> getHeaders() throws AuthFailureError {
		Map<String, String> headers = new HashMap<String, String>();
		String cookieStr = ConfigHelper.getInstance().getCookie();
		if (!TextUtils.isEmpty(cookieStr)) {
			headers.put("Cookie", cookieStr);
		}
		return headers;
	}
} public class JsonObjectRequest extends Request<JSONObject> {
	private Map<String, String> mParams;
	private Listener<JSONObject> mListener;

	public JsonObjectRequest(String url, Map<String, String> params, Listener<JSONObject> listener, ErrorListener errorListener) {
		super(Method.POST, url, errorListener);
		mListener = listener;
		mParams = params;
	}

	@Override
	protected Map<String, String> getParams() throws AuthFailureError {
		return mParams;
	}

	@Override
	protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
		try {
			String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
			// 保存cookie
			ConfigHelper.getInstance().saveCookie(HttpHelper.getCookieMap(response.headers));

			return Response.success(new JSONObject(jsonString), HttpHeaderParser.parseCacheHeaders(response));
		} catch (UnsupportedEncodingException e) {
			return Response.error(new ParseError(e));
		} catch (JSONException je) {
			return Response.error(new ParseError(je));
		}
	}

	@Override
	protected void deliverResponse(JSONObject response) {
		mListener.onResponse(response);
	}

	@Override
	public Map<String, String> getHeaders() throws AuthFailureError {
		Map<String, String> headers = new HashMap<String, String>();
		String cookieStr = ConfigHelper.getInstance().getCookie();
		if (!TextUtils.isEmpty(cookieStr)) {
			headers.put("Cookie", cookieStr);
		}
		return headers;
	}
}
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import com.android.volley.Request;
import com.android.volley.Response.Listener;
import com.google.gson.reflect.TypeToken;
import com.lingganhezi.myapp.AppContext;
import com.lingganhezi.myapp.Constant;
import com.lingganhezi.myapp.HttpHelper;
import com.lingganhezi.myapp.PlaceProvider.PlaceColumns;
import com.lingganhezi.myapp.R;
import com.lingganhezi.myapp.UserInfoProvider.UserInfoColumns;
import com.lingganhezi.myapp.entity.LoginUserInfo;
import com.lingganhezi.myapp.entity.Place;
import com.lingganhezi.myapp.entity.Respone;
import com.lingganhezi.myapp.entity.UserInfo;
import com.lingganhezi.myapp.net.ResultResponeListener;
import com.lingganhezi.net.FileUploader;
import com.lingganhezi.net.JsonArrayRequest;
import com.lingganhezi.net.JsonObjectRequest;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
package com.lingganhezi.myapp.service;




/**
 * 用户信息 service
 * 
 * @author chenzipeng
 *
 */
public class UserService extends BaseService {
	private final String TAG = UserService.class.getSimpleName();

	private final static String URL_GET_USER_INFO = Constant.SERVER_ADD + "/app/userInfo.php";
	private final static String URL_UPDATE_USER_INFO = Constant.SERVER_ADD + "/app/userInfo.php";
	private final static String URL_UPLOAD_USER_AVATAR = Constant.SERVER_ADD + "/app/userInfo_edit_avatar.php";
	private final static String URL_FRIEND = Constant.SERVER_ADD + "/app/space.php";

	/**
	 * MSG 编号 200~300
	 */
	public final static int MSG_SYNC_USERINFO_SUCCESS = 200;
	public final static int MSG_SYNC_USERINFO_FAILD = 201;
	public final static int MSG_UPLOAD_USER_AVATR_SUCCESS = 210;
	public final static int MSG_UPLOAD_USER_AVATR_FAILD = 211;
	public final static int MSG_UPDATE_USERINFO_SUCCESS = 220;
	public final static int MSG_UPDATE_USERINFO_FAILD = 221;
	public final static int MSG_QUERY_UNFRIEND_SUCCESS = 230;
	public final static int MSG_QUERY_UNFRIEND_FAILD = 231;
	public final static int MSG_NEW_FRIEND_SUCCESS = 240;
	public final static int MSG_NEW_FRIEND_FAILD = 241;
	public final static int MSG_SYNC_FRIEND_SUCCESS = 250;
	public final static int MSG_SYNC_FRIEND_FAILD = 251;
	public final static int MSG_DEL_FRIEND_SUCCESS = 260;
	public final static int MSG_DEL_FRIEND_FAILD = 261;
	
	private static UserService instance;
	private LoginUserInfo mCurrentLoginUser;

	// TODO 放到其他地方
	/**
	 * 性别资源
	 */
	public static Map<Integer, Integer> SEX_NAME_MAP = new HashMap<Integer, Integer>();
	static {
		SEX_NAME_MAP.put(Constant.SEX_UNKONW, R.string.sex_unknow);
		SEX_NAME_MAP.put(Constant.SEX_MAN, R.string.sex_man);
		SEX_NAME_MAP.put(Constant.SEX_WOMEN, R.string.sex_women);
	}

	public static Integer[] SEX_ARRAY = SEX_NAME_MAP.keySet().toArray(new Integer[3]);

	public static Map<Integer, Integer> SEX_DRAWABLE_MAP = new HashMap<Integer, Integer>();
	static {
		SEX_DRAWABLE_MAP.put(Constant.SEX_UNKONW, R.drawable.sex_unkonw);
		SEX_DRAWABLE_MAP.put(Constant.SEX_MAN, R.drawable.sex_man);
		SEX_DRAWABLE_MAP.put(Constant.SEX_WOMEN, R.drawable.sex_women);
	}

	private UserService(Context context) {
		super(context);
	}

	private static UserService getInstance(Context context) {
		if (instance == null) {
			instance = new UserService(context);
		}
		return instance;
	}

	public static UserService getInstance() {
		return getInstance(AppContext.getInstance());
	}

	/**
	 * 设置当前登录用户
	 * 
	 * @param loginUserInfo
	 */
	public void setCurrentLoginUser(LoginUserInfo loginUserInfo) {
		mCurrentLoginUser = loginUserInfo;
		getServiceManager().getLoginService().saveLoginUserInfoConfig(loginUserInfo);
	}

	/**
	 * 获取当前登录用户的id
	 * 如果没有登录就返回一个空字符串
	 * @return
	 */
	public String getCurrentLoginUserId(){
		if(getCurrentLoginUser() != null){
			return getCurrentLoginUser().getUserId();
		}else{
			return "";
		}
	}
	/**
	 * 获取当前登陆用户
	 * 
	 * @return
	 */
	public LoginUserInfo getCurrentLoginUser() {
		return mCurrentLoginUser;
	}

	/**
	 * 同步获取服务器用户的信息
	 * 
	 * @return
	 */
	public void syncUserInfo(String userid, final Handler handler) {
		Log.i(TAG, "#syncUserInfo:" + userid);
		// 从网络获取
		Map<String, String> params = new HashMap<String, String>();
		params.put("action", "get");
		params.put("userid", userid);

		Request request = new JsonObjectRequest(URL_GET_USER_INFO, params, new ResultResponeListener() {