diff --git a/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java b/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java index 6e9e513ef..4b6267a74 100644 --- a/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/BindUserActivity.java @@ -34,6 +34,7 @@ import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ToastUtil; @@ -47,6 +48,8 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import java.util.ArrayList; + /** * 綁定手機號 */ @@ -79,6 +82,7 @@ public class BindUserActivity extends AbsActivity { private String isBind = "0", mobile = ""; private WebView webview; private WebSettings webSettings; + private ArrayList allCountries = new ArrayList<>(); @Override protected int getLayoutId() { @@ -201,6 +205,21 @@ public class BindUserActivity extends AbsActivity { webview.addJavascriptInterface(new JsBridge(), "jsBridge"); // 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html")) webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html"); + + allCountries.clear(); + allCountries.addAll(Country.getAll(mContext, null)); + + String ct = IMLoginManager.get(mContext).getString("sys_user_area"); + ct = TextUtils.equals("中国", ct) ? "中国香港" : ct; + for (int i = 0; i < allCountries.size(); i++) { + if (allCountries.get(i).chs.equals(ct)) { + String countryName = allCountries.get(i).name; + countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName; + mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName); + mCountryCode = allCountries.get(i).code; + return; + } + } } private void mTvCountryCodeClick() { @@ -230,7 +249,9 @@ public class BindUserActivity extends AbsActivity { CountryPicker.newInstance(null, new OnPick() { @Override public void onPick(Country country) { - mTvCountryCode.setText("+" + country.code); + String countryName = country.name; + countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName; + mTvCountryCode.setText(" +" + country.code + " " + countryName); mCountryCode = country.code; } }).show(getSupportFragmentManager(), "country"); diff --git a/main/src/main/java/com/yunbao/main/activity/FindPwdActivity.java b/main/src/main/java/com/yunbao/main/activity/FindPwdActivity.java index 83b762f15..9d6938a61 100644 --- a/main/src/main/java/com/yunbao/main/activity/FindPwdActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/FindPwdActivity.java @@ -29,6 +29,7 @@ import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ValidatePhoneUtil; @@ -42,6 +43,8 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import java.util.ArrayList; + /** * Created by cxf on 2018/9/25. */ @@ -66,6 +69,7 @@ public class FindPwdActivity extends AbsActivity { private TextView mTvCountryCode; private WebView webview; private WebSettings webSettings; + private ArrayList allCountries = new ArrayList<>(); @Override protected int getLayoutId() { @@ -149,6 +153,22 @@ public class FindPwdActivity extends AbsActivity { }; mDialog = DialogUitl.loadingDialog(mContext); EventBus.getDefault().register(this); + + + allCountries.clear(); + allCountries.addAll(Country.getAll(mContext, null)); + + String ct = IMLoginManager.get(mContext).getString("sys_user_area"); + ct = TextUtils.equals("中国", ct) ? "中国香港" : ct; + for (int i = 0; i < allCountries.size(); i++) { + if (allCountries.get(i).chs.equals(ct)) { + String countryName = allCountries.get(i).name; + countryName = countryName.length() > 4 ? countryName.substring(0, 4) : countryName; + mTvCountryCode.setText("+" + allCountries.get(i).code + " " + countryName); + mCountryCode = allCountries.get(i).code; + return; + } + } } private void mTvCountryCodeClick() { @@ -208,7 +228,9 @@ public class FindPwdActivity extends AbsActivity { CountryPicker.newInstance(null, new OnPick() { @Override public void onPick(Country country) { - mTvCountryCode.setText("+"+country.code); + String countryName = country.name; + countryName = countryName.length() > 4 ? countryName.substring(0, 4) + "..." : countryName; + mTvCountryCode.setText(" +" + country.code + " " + countryName); mCountryCode=country.code; } }).show(getSupportFragmentManager(), "country");