社区对接接口

This commit is contained in:
kehaoyuan
2017-12-12 17:13:00 +08:00
parent dc186e2e6b
commit b58bbbe705
32 changed files with 465 additions and 112 deletions

View File

@ -1,5 +1,8 @@
package com.gh.gamecenter.manager;
import android.content.Context;
import android.preference.PreferenceManager;
import com.gh.gamecenter.entity.LoginTokenEntity;
import com.gh.gamecenter.entity.UserInfoEntity;
@ -8,6 +11,7 @@ import com.gh.gamecenter.entity.UserInfoEntity;
*/
public class UserManager {
private final String COMMUNITY_ID = "CommunityId";
private static volatile UserManager singleton;
@ -15,6 +19,8 @@ public class UserManager {
private LoginTokenEntity mLoginTokenEntity;
private String mCommunityId;
public static UserManager getInstance() {
if (singleton == null) {
synchronized (UserManager.class) {
@ -47,6 +53,20 @@ public class UserManager {
return null;
}
public void setCommunityId(Context context, String communityId) {
if (!mCommunityId.equals(communityId)) {
PreferenceManager.getDefaultSharedPreferences(context).edit().putString(COMMUNITY_ID, communityId).apply();
}
this.mCommunityId = communityId;
}
public String getCommunityId(Context context) {
if (mCommunityId == null) {
mCommunityId = PreferenceManager.getDefaultSharedPreferences(context).getString(COMMUNITY_ID, "");
}
return mCommunityId;
}
public void logout() {
mUserInfoEntity = null;
mLoginTokenEntity = null;