| | |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityHomeLoginBinding; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlResidenceLogic; |
| | | import com.hdl.photovoltaic.ui.account.ChangePassword; |
| | | import com.hdl.photovoltaic.ui.account.RegisterAccountActivity; |
| | |
| | | import com.hdl.photovoltaic.other.HdlAccountLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.ui.me.WebActivity; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.LocalManageUtil; |
| | | import com.hdl.photovoltaic.utils.SharedPreUtils; |
| | | import com.hdl.photovoltaic.utils.TimeUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog1; |
| | | import com.hdl.photovoltaic.widget.ListDialog; |
| | | import com.hdl.photovoltaic.widget.adapter.ListDialogAdapter; |
| | | |
| | |
| | | |
| | | @Override |
| | | public Object getContentView() { |
| | | |
| | | setNotificationBarBackgroundColor(CustomColor.blue); |
| | | viewBinding = ActivityHomeLoginBinding.inflate(getLayoutInflater()); |
| | | return viewBinding.getRoot(); |
| | | } |
| | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_00000000)); |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | |
| | | * 初始化UI |
| | | */ |
| | | private void initView() { |
| | | viewBinding.homeLoginCheckBCCl.setSelected(UserConfigManage.getInstance().isBAccount()); |
| | | viewBinding.homeLoginPrivacyCheckIv.setSelected(UserConfigManage.getInstance().isAcceiptPolicy()); |
| | | setStringDifferentColors(viewBinding.homeLoginPrivacyTv); |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.zh)) { |
| | | viewBinding.homeLoginLanguageTv.setText("简体中文"); |
| | | } else { |
| | | viewBinding.homeLoginLanguageTv.setText("English"); |
| | | } |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | viewBinding.homeLoginRegisterTv.setVisibility(View.GONE); |
| | | } else { |
| | | viewBinding.homeLoginRegisterTv.setVisibility(View.VISIBLE); |
| | | } |
| | | try { |
| | | viewBinding.homeLoginCheckBCCl.setSelected(UserConfigManage.getInstance().isBAccount()); |
| | | viewBinding.homeLoginPrivacyCheckIv.setSelected(UserConfigManage.getInstance().isAcceiptPolicy()); |
| | | setStringDifferentColors(viewBinding.homeLoginPrivacyTv, false); |
| | | |
| | | String acc = "13375012441"; |
| | | //注册和忘记密码需要加下划线 |
| | | String registerTvStr = viewBinding.homeLoginRegisterTv.getText().toString(); |
| | | String forgetPasswordTvStr = viewBinding.homeLoginForgetPasswordTv.getText().toString(); |
| | | SpannableStringBuilder registerTvStrSpannable = new SpannableStringBuilder(registerTvStr); |
| | | registerTvStrSpannable.setSpan(new ClickableSpan() { |
| | | @Override |
| | | public void onClick(@NonNull View widget) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(R.color.text_FFACACAC, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(true); |
| | | } |
| | | |
| | | |
| | | }, 0, registerTvStr.length(), 0); |
| | | viewBinding.homeLoginRegisterTv.setText(registerTvStrSpannable); |
| | | |
| | | SpannableStringBuilder forgetPasswordTvStrSpannable = new SpannableStringBuilder(forgetPasswordTvStr); |
| | | forgetPasswordTvStrSpannable.setSpan(new ClickableSpan() { |
| | | @Override |
| | | public void onClick(@NonNull View widget) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(R.color.text_FFACACAC, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(true); |
| | | } |
| | | |
| | | |
| | | }, 0, forgetPasswordTvStr.length(), 0); |
| | | viewBinding.homeLoginForgetPasswordTv.setText(forgetPasswordTvStrSpannable); |
| | | |
| | | |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.zh)) { |
| | | viewBinding.homeLoginLanguageTv.setText("简体中文"); |
| | | } else { |
| | | viewBinding.homeLoginLanguageTv.setText("English"); |
| | | } |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | viewBinding.homeLoginRegisterTv.setVisibility(View.GONE); |
| | | } else { |
| | | viewBinding.homeLoginRegisterTv.setVisibility(View.VISIBLE); |
| | | } |
| | | // String acc = "18402017839"; |
| | | // String acc = "13375012441"; |
| | | // String acc = "18316672920"; |
| | | // String acc = "nuy13368@uzxia.com"; |
| | | String pws = "123456"; |
| | | //测试用 |
| | | viewBinding.homeLoginAccountEt.setText(acc); |
| | | viewBinding.homeLoginPasswordEt.setText(pws); |
| | | isLoginTextViewEnabled(); |
| | | // String pws = "123456"; |
| | | //测试用 |
| | | viewBinding.homeLoginAccountEt.setText(UserConfigManage.getInstance().getAccount()); |
| | | // viewBinding.homeLoginPasswordEt.setText(pws); |
| | | checkClearIconShowOrNot(viewBinding.homeLoginAccountEt.getText().toString()); |
| | | isLoginTextViewEnabled(); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void initEvent() { |
| | | |
| | | viewBinding.homeLoginMoreIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlThreadLogic.toast(_mActivity, getString(R.string.loading_not_supported)); |
| | | } |
| | | }); |
| | | |
| | | //语言选择 |
| | | viewBinding.homeLoginLanguageTv.setOnClickListener(new View.OnClickListener() { |
| | | viewBinding.homeLoginLanguageLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | ListDialog listDialog = new ListDialog(_mActivity); |
| | |
| | | } |
| | | }); |
| | | |
| | | //输入账号 |
| | | viewBinding.homeLoginAccountEt.addTextChangedListener(accountTextWatcher); |
| | | //清除账号按钮 |
| | | viewBinding.homeLoginClearContentsIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | viewBinding.homeLoginAccountEt.setText(""); |
| | | } |
| | | }); |
| | | |
| | | //输入密码 |
| | | viewBinding.homeLoginPasswordEt.addTextChangedListener(passwordTextWatcher); |
| | | //密码隐藏按钮 |
| | | viewBinding.homeLoginHideIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | |
| | | UserConfigManage.getInstance().setBAccount(v.isSelected()); |
| | | viewBinding.homeLoginCheckBCIv.setSelected(UserConfigManage.getInstance().isBAccount()); |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | viewBinding.homeLoginRegisterTv.setVisibility(View.GONE); |
| | | viewBinding.homeLoginRegisterTv.setVisibility(View.INVISIBLE); |
| | | } else { |
| | | viewBinding.homeLoginRegisterTv.setVisibility(View.VISIBLE); |
| | | } |
| | |
| | | viewBinding.homeLoginTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | HDLUniMPSDKManager.isExistsActivity=false; |
| | | String account = viewBinding.homeLoginAccountEt.getText().toString().replace(" ", ""); |
| | | String password = viewBinding.homeLoginPasswordEt.getText().toString().replace(" ", ""); |
| | | boolean is_login = isLocalCheckAccountAndPassword(account, password); |
| | |
| | | boolean isSelected = UserConfigManage.getInstance().isAcceiptPolicy(); |
| | | if (!isSelected) { |
| | | //隐私协议提示 |
| | | getDialog(); |
| | | getAcceiptPolicyDialog(); |
| | | return; |
| | | } |
| | | showLoading(getString(R.string.home_login_be_logging_in)); |
| | | HdlAccountLogic.getInstance().regionByAccount(account, new CloudCallBeak<HDLUserRegionBean>() { |
| | | @Override |
| | | public void onSuccess(HDLUserRegionBean obj) { |
| | | //开发环境 |
| | | String APP_REGIONURL_TEST = "http://47.114.131.143:27199"; |
| | | AppConfigManage.setUserRegionUrl(APP_REGIONURL_TEST); |
| | | //初始化服务域名 |
| | | // AppConfigManage.setUserRegionUrl(obj.getRegionUrl()); |
| | | HDLLinkPMUser.getInstance().setUserRegionUrl(AppConfigManage.getUserRegionUrl()); |
| | | HdlAccountLogic.getInstance().loginByPassword(account, password, new ILoginCallBack() { |
| | | @Override |
| | | public void onSuccess(HDLLoginBean obj) { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | restoreButtonStyleToInitializeState(); |
| | | //安装商跳转界面 |
| | | startActivity(BPowerStationActivity.class); |
| | | hideLoading(); |
| | | finish(); |
| | | } else { |
| | | //C端需要先获取电站列表; |
| | | HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() { |
| | | @Override |
| | | public void onSuccess(List<HouseIdBean> obj) { |
| | | hideLoading(); |
| | | HdlResidenceLogic.getInstance().setHouseIdList(obj); |
| | | restoreButtonStyleToInitializeState(); |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //安装商跳转界面 |
| | | startActivity(BPowerStationActivity.class); |
| | | } else { |
| | | //C端用户跳转界面 |
| | | startActivity(CPowerStationActivity.class); |
| | | |
| | | } |
| | | finish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | restoreButtonStyleToInitializeState(); |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //安装商跳转界面 |
| | | startActivity(BPowerStationActivity.class); |
| | | } else { |
| | | //C端用户跳转界面 |
| | | startActivity(CPowerStationActivity.class); |
| | | } |
| | | finish(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | if (e.getCode() == 10019) { |
| | | //用户已经被锁定错误码 |
| | | try { |
| | | if (e.getmExtra() != null) { |
| | | if (System.currentTimeMillis() < e.getmExtra().getUnlockTime()) { |
| | | long time = e.getmExtra().getUnlockTime() - System.currentTimeMillis(); |
| | | int minute = Integer.parseInt(TimeUtils.getMinuteTime(time)); |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + getString(R.string.residue) + minute + getString(R.string.minute) + "(" + e.getCode() + ")"); |
| | | } |
| | | } |
| | | } catch (Exception ee) { |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | |
| | | } else { |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | }); |
| | | //登录 |
| | | loginAccount(account, password); |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 登录 |
| | | * |
| | | * @param account 账号 |
| | | * @param password 密码 |
| | | */ |
| | | private void loginAccount(String account, String password) { |
| | | showLoading(getString(R.string.home_login_be_logging_in)); |
| | | HdlAccountLogic.getInstance().regionByAccount(account, new CloudCallBeak<HDLUserRegionBean>() { |
| | | @Override |
| | | public void onSuccess(HDLUserRegionBean obj) { |
| | | HdlLogLogic.print("账号登录成功---" + account, true); |
| | | //开发环境 |
| | | // String APP_REGIONURL_TEST = "http://47.114.131.143:27197"; |
| | | // AppConfigManage.setUserRegionUrl(APP_REGIONURL_TEST); |
| | | //初始化服务域名 |
| | | AppConfigManage.setUserRegionUrl(obj.getRegionUrl()); |
| | | HDLLinkPMUser.getInstance().setUserRegionUrl(AppConfigManage.getUserRegionUrl()); |
| | | HdlAccountLogic.getInstance().loginByPassword(account, password, new ILoginCallBack() { |
| | | @Override |
| | | public void onSuccess(HDLLoginBean obj) { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | restoreButtonStyleToInitializeState(); |
| | | //安装商跳转界面 |
| | | startActivity(BPowerStationActivity.class); |
| | | hideLoading(); |
| | | finish(); |
| | | //云端还没有匹配平台好,先隐藏校验账号功能 2025年03月24日15:16:37 |
| | | // HdlAccountLogic.getInstance().getCompanyParterMenu_B(new CloudCallBeak<Boolean>() { |
| | | // @Override |
| | | // public void onSuccess(Boolean isBoolean) { |
| | | // if (isBoolean) { |
| | | // //2025年03月03日14:45:17 杨涛要求b端账号需要检验权限 |
| | | // restoreButtonStyleToInitializeState(); |
| | | // //安装商跳转界面 |
| | | // startActivity(BPowerStationActivity.class); |
| | | // hideLoading(); |
| | | // finish(); |
| | | // } else { |
| | | // hideLoading(); |
| | | // HdlThreadLogic.toast(_mActivity, getString(R.string.forbidden_login)); |
| | | // } |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFailure(HDLException e) { |
| | | // hideLoading(); |
| | | // HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | // } |
| | | // }); |
| | | |
| | | } else { |
| | | //C端需要先获取电站列表; |
| | | HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() { |
| | | @Override |
| | | public void onSuccess(List<HouseIdBean> obj) { |
| | | hideLoading(); |
| | | HdlResidenceLogic.getInstance().setHouseIdList(obj); |
| | | restoreButtonStyleToInitializeState(); |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //安装商跳转界面 |
| | | startActivity(BPowerStationActivity.class); |
| | | } else { |
| | | //C端用户跳转界面 |
| | | startActivity(CPowerStationActivity.class); |
| | | |
| | | } |
| | | finish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | restoreButtonStyleToInitializeState(); |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //安装商跳转界面 |
| | | startActivity(BPowerStationActivity.class); |
| | | } else { |
| | | //C端用户跳转界面 |
| | | startActivity(CPowerStationActivity.class); |
| | | } |
| | | finish(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | if (e.getCode() == 10019) { |
| | | //用户已经被锁定错误码 |
| | | try { |
| | | if (e.getmExtra() != null) { |
| | | if (System.currentTimeMillis() < e.getmExtra().getUnlockTime()) { |
| | | long time = e.getmExtra().getUnlockTime() - System.currentTimeMillis(); |
| | | int minute = Integer.parseInt(TimeUtils.getMinuteTime(time)); |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + getString(R.string.residue) + minute + getString(R.string.minute) + "(" + e.getCode() + ")"); |
| | | } |
| | | } |
| | | } catch (Exception ee) { |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | |
| | | } else { |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 校验登录按钮是否启用 |
| | | */ |
| | | private void isLoginTextViewEnabled() { |
| | | String account = viewBinding.homeLoginAccountEt.getText().toString().replace(" ", ""); |
| | | String password = viewBinding.homeLoginPasswordEt.getText().toString().replace(" ", ""); |
| | | boolean isEnabled = account.length() > 0 && password.length() > 0; |
| | | if (isEnabled) { |
| | | viewBinding.homeLoginTv.setTextColor(getColor(R.color.text_FFACACAC)); |
| | | } else { |
| | | viewBinding.homeLoginTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | } |
| | | viewBinding.homeLoginTv.setEnabled(isEnabled); |
| | | if (password.length() < 6 || password.length() > 16) { |
| | | return; |
| | | } |
| | | //符合密码规则后隐藏错误提示; |
| | | viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_E1E1E1)); |
| | | // viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_FF5A5A5A)); |
| | | viewBinding.homeLoginPasswordTextErrorTv.setText(""); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 检测清除图标是否显示 |
| | | */ |
| | | private void checkClearIconShowOrNot(String s) { |
| | | if (s.replace(" ", "").length() > 0) { |
| | | if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.GONE) { |
| | | viewBinding.homeLoginClearContentsIv.setVisibility(View.VISIBLE); |
| | | } |
| | | } else { |
| | | if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.VISIBLE) { |
| | | viewBinding.homeLoginClearContentsIv.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private boolean isLocalCheckAccountAndPassword(String account, String password) { |
| | | if (TextUtils.isEmpty(account)) { |
| | | viewBinding.homeLoginLine1V.setBackgroundColor(getColor(R.color.text_D34545)); |
| | | // viewBinding.homeLoginLine1V.setBackgroundColor(getColor(R.color.text_D34545)); |
| | | viewBinding.homeLoginAccountTextErrorTv.setText(R.string.home_login_error_account_null); |
| | | return false; |
| | | } |
| | | if (TextUtils.isEmpty(password)) { |
| | | viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_D34545)); |
| | | // viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_D34545)); |
| | | viewBinding.homeLoginPasswordTextErrorTv.setText(R.string.home_login_error_password_null); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | if (password.length() < 6 || password.length() > 16) { |
| | | viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_D34545)); |
| | | // viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_D34545)); |
| | | viewBinding.homeLoginPasswordTextErrorTv.setText(R.string.home_login_error_6_16_str); |
| | | return false; |
| | | } |
| | |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | viewBinding.homeLoginLine1V.setBackgroundColor(getColor(R.color.text_E1E1E1)); |
| | | // viewBinding.homeLoginLine1V.setBackgroundColor(getColor(R.color.text_E1E1E1)); |
| | | viewBinding.homeLoginAccountTextErrorTv.setText(""); |
| | | viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_E1E1E1)); |
| | | // viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_E1E1E1)); |
| | | viewBinding.homeLoginPasswordTextErrorTv.setText(""); |
| | | } |
| | | }, null, null); |
| | |
| | | /** |
| | | * 设置一串字符多种颜色以及点击事件 |
| | | * |
| | | * @param textView 当前组件 |
| | | * @param textView 当前组件 |
| | | * @param isHighlight 是否高亮(true表示高亮) |
| | | */ |
| | | private void setStringDifferentColors(TextView textView) { |
| | | private void setStringDifferentColors(TextView textView, boolean isHighlight) { |
| | | try { |
| | | |
| | | if (textView == null) { |
| | | return; |
| | | int text_color = isHighlight ? R.color.text_38C494 : R.color.text_FFACACAC; |
| | | if (textView == null) { |
| | | return; |
| | | } |
| | | |
| | | String s = textView.getText().toString(); |
| | | if (!s.contains("《")) { |
| | | return; |
| | | } |
| | | |
| | | int startIndex1 = s.indexOf("《"); |
| | | int endIndex1 = s.indexOf("》") + 1; |
| | | |
| | | |
| | | int startIndex2 = s.lastIndexOf("《"); |
| | | int endIndex2 = s.lastIndexOf("》") + 1; |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.en)) { |
| | | s = s.replace("《", "").replace("》", ""); |
| | | endIndex1 -= 1; |
| | | startIndex2 -= 2;//移除"《"和"》"总长度发生变化,索引也改变; |
| | | endIndex2 -= 4;//移除"《"和"》"总长度发生变化,索引也改变; |
| | | } |
| | | SpannableStringBuilder spannable = new SpannableStringBuilder(s); |
| | | //设置文字的前景色 |
| | | if (textView.getTag() != null && textView.getTag().toString().equals("click")) { |
| | | spannable.setSpan(new ClickableSpan() { |
| | | @Override |
| | | public void onClick(@NonNull View widget) { |
| | | //todo 需要跳转到服务协议界面 |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("type", WebActivity.ServiceAgreement); |
| | | intent.setClass(_mActivity, WebActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | @Override |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(text_color, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(!UserConfigManage.getInstance().isZh()); |
| | | } |
| | | |
| | | |
| | | }, startIndex1, endIndex1, 0); |
| | | // spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), startIndex1, endIndex1, 0); |
| | | |
| | | spannable.setSpan(new ClickableSpan() { |
| | | @Override |
| | | public void onClick(@NonNull View widget) { |
| | | //todo 需要跳转到隐私界面 |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("type", WebActivity.PrivacyAgreement); |
| | | intent.setClass(_mActivity, WebActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | @Override |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(text_color, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(!UserConfigManage.getInstance().isZh()); |
| | | } |
| | | |
| | | }, startIndex2, endIndex2, 0); |
| | | // spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), startIndex2, endIndex2, 0); |
| | | |
| | | |
| | | } |
| | | textView.setText(spannable); |
| | | //中途遇到点击后字体显示高亮,取消高亮 |
| | | textView.setHighlightColor(getResources().getColor(R.color.text_FFACACAC, null)); |
| | | //最后设置可点击,必须实现,否则只能显示样式,无法实现点击效果 |
| | | textView.setMovementMethod(LinkMovementMethod.getInstance()); |
| | | } catch (Exception ignored) { |
| | | } |
| | | |
| | | String s = textView.getText().toString(); |
| | | if (!s.contains("《")) { |
| | | return; |
| | | } |
| | | int startIndex1 = s.indexOf("《"); |
| | | int endIndex1 = s.indexOf("》") + 1; |
| | | |
| | | int startIndex2 = s.lastIndexOf("《"); |
| | | int endIndex2 = s.lastIndexOf("》") + 1; |
| | | |
| | | SpannableStringBuilder spannable = new SpannableStringBuilder(s); |
| | | //设置文字的前景色 |
| | | if (textView.getTag() != null && textView.getTag().toString().equals("click")) { |
| | | spannable.setSpan(new ClickableSpan() { |
| | | @Override |
| | | public void onClick(@NonNull View widget) { |
| | | //todo 需要跳转到服务协议界面 |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("type", WebActivity.ServiceAgreement); |
| | | intent.setClass(_mActivity, WebActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | @Override |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(R.color.text_245EC3, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(false); |
| | | } |
| | | |
| | | |
| | | }, startIndex1, endIndex1, 0); |
| | | |
| | | spannable.setSpan(new ClickableSpan() { |
| | | @Override |
| | | public void onClick(@NonNull View widget) { |
| | | //todo 需要跳转到隐私界面 |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("type", WebActivity.PrivacyAgreement); |
| | | intent.setClass(_mActivity, WebActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | |
| | | @Override |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(R.color.text_245EC3, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(false); |
| | | } |
| | | |
| | | |
| | | }, startIndex2, endIndex2, 0); |
| | | |
| | | |
| | | } |
| | | textView.setText(spannable); |
| | | //中途遇到点击后字体显示高亮,取消高亮 |
| | | textView.setHighlightColor(getResources().getColor(R.color.text_00000000, null)); |
| | | //最后设置可点击,必须实现,否则只能显示样式,无法实现点击效果 |
| | | textView.setMovementMethod(LinkMovementMethod.getInstance()); |
| | | |
| | | } |
| | | |
| | |
| | | /** |
| | | * 弹窗 |
| | | */ |
| | | private void getDialog() { |
| | | ConfirmationCancelDialog1 dialog = new ConfirmationCancelDialog1(_mActivity); |
| | | dialog.show(); |
| | | // dialog.setTitle(getString(R.string.loading_privacy)); |
| | | dialog.isHideTitle(true); |
| | | dialog.setContent(getString(R.string.loading_privacy_server)); |
| | | setStringDifferentColors(dialog.getContentTextView()); |
| | | dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | private void getAcceiptPolicyDialog() { |
| | | |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity); |
| | | confirmationCancelDialog.show(); |
| | | confirmationCancelDialog.isHideTitle(true); |
| | | confirmationCancelDialog.setContent(getString(R.string.loading_privacy_server)); |
| | | setStringDifferentColors(confirmationCancelDialog.getContentTextView(), true); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.loading_agree)); |
| | | confirmationCancelDialog.setCancel(getString(R.string.loading_on_agree)); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | |
| | | UserConfigManage.getInstance().setAcceiptPolicy(true); |
| | | viewBinding.homeLoginPrivacyCheckIv.setSelected(true); |
| | | dialog.dismiss(); |
| | | confirmationCancelDialog.dismiss(); |
| | | String account = viewBinding.homeLoginAccountEt.getText().toString().replace(" ", ""); |
| | | String password = viewBinding.homeLoginPasswordEt.getText().toString().replace(" ", ""); |
| | | loginAccount(account, password); |
| | | } |
| | | }); |
| | | dialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | UserConfigManage.getInstance().setAcceiptPolicy(false); |
| | | viewBinding.homeLoginPrivacyCheckIv.setSelected(false); |
| | | dialog.dismiss(); |
| | | confirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | if (s.length() > 0) { |
| | | if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.GONE) { |
| | | viewBinding.homeLoginClearContentsIv.setVisibility(View.VISIBLE); |
| | | } |
| | | } else { |
| | | if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.VISIBLE) { |
| | | viewBinding.homeLoginClearContentsIv.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | checkClearIconShowOrNot(s.toString()); |
| | | isLoginTextViewEnabled(); |
| | | } |
| | | }; |