多语言切换
This commit is contained in:
@@ -27,6 +27,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.LifeCycleListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.ClickUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -48,6 +49,7 @@ public abstract class AbsActivity extends AppCompatActivity {
|
||||
Resources res = super.getResources();
|
||||
Configuration config = new Configuration();
|
||||
config.setToDefaults();
|
||||
config.locale = IMLoginManager.get(this).getLocaleLanguage();
|
||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,26 @@ public class LiveClassBean {
|
||||
private boolean isAll;
|
||||
private String des;
|
||||
private boolean checked;
|
||||
private String chinese;
|
||||
private String english;
|
||||
|
||||
public String getChinese() {
|
||||
return chinese;
|
||||
}
|
||||
|
||||
public LiveClassBean setChinese(String chinese) {
|
||||
this.chinese = chinese;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEnglish() {
|
||||
return english;
|
||||
}
|
||||
|
||||
public LiveClassBean setEnglish(String english) {
|
||||
this.english = english;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.yunbao.common.event.FollowEvent;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.APKManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.LiveClassManager;
|
||||
import com.yunbao.common.manager.NewLevelManager;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
@@ -156,7 +157,7 @@ public class CommonHttpUtil {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
locale = context.getResources().getConfiguration().getLocales().get(0);
|
||||
} else {
|
||||
locale = context.getResources().getConfiguration().locale;
|
||||
locale = IMLoginManager.get(context).getLocaleLanguage();
|
||||
}
|
||||
if (locale.getLanguage().equals("zh")) {
|
||||
lang = "chinese";
|
||||
@@ -202,6 +203,10 @@ public class CommonHttpUtil {
|
||||
JSONArray levelArray = obj.getJSONArray("levelanchor_new");
|
||||
new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString());
|
||||
}
|
||||
if (obj.containsKey("liveclass")) {//缓存直播间分类
|
||||
JSONArray levelArray = obj.getJSONArray("liveclass");
|
||||
new LiveClassManager(context).UpDataLiveClass(levelArray.toJSONString());
|
||||
}
|
||||
if (obj.containsKey("apk_ver")) {
|
||||
APKManager.get().setApkVer(obj.getString("apk_ver"));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 登录者信息管理
|
||||
*/
|
||||
@@ -46,6 +48,20 @@ public class IMLoginManager extends BaseCacheManager {
|
||||
private final String STATUS_ANCHOR_SAY = "anchorSay";
|
||||
private final String STATUS_ANCHOR_CALL = "anchorCallMe";
|
||||
|
||||
private final String KEY_LANGUAGE = "language";
|
||||
|
||||
public void setLanguage(boolean isEnglish) {
|
||||
put(KEY_LANGUAGE, isEnglish);
|
||||
}
|
||||
|
||||
public Locale getLocaleLanguage() {
|
||||
if (!getBoolean(KEY_LANGUAGE, false)) {
|
||||
return Locale.SIMPLIFIED_CHINESE;
|
||||
} else {
|
||||
return new Locale("en", "rUS");
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultBubbleUrl(String defaultBubbleUrl) {
|
||||
put(keyDefaultBubbleUrl, defaultBubbleUrl);
|
||||
}
|
||||
@@ -55,7 +71,6 @@ public class IMLoginManager extends BaseCacheManager {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setXiaJBG(boolean xjbg) {
|
||||
put(xiaJBG, xjbg);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.yunbao.common.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.bean.NewLevelModel;
|
||||
import com.yunbao.common.manager.base.BaseCacheManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveClassManager extends BaseCacheManager {
|
||||
private final String KEY_LIVE_CLASS = "keyLiveClass";
|
||||
private List<LiveClassBean> liveClass = new ArrayList<>();
|
||||
|
||||
public LiveClassManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存等级图标
|
||||
*
|
||||
* @param json
|
||||
*/
|
||||
public void UpDataLiveClass(String json) {
|
||||
liveClass = new Gson().fromJson(json, new TypeToken<List<LiveClassBean>>() {
|
||||
}.getType());
|
||||
put(KEY_LIVE_CLASS, liveClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取等级数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<LiveClassBean> getLiveClass() {
|
||||
return getList(KEY_LIVE_CLASS, new TypeToken<List<LiveClassBean>>() {
|
||||
}.getType());
|
||||
}
|
||||
}
|
||||
1129
common/src/main/res/values-en-rUS/string.xml
Normal file
1129
common/src/main/res/values-en-rUS/string.xml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user