社区对接接口
This commit is contained in:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user