ec784bcc2c42b4a6b7c0bd66e97190aba72e035c.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package eVVM.apk.ui.My;
  2. import android.graphics.Color;
  3. import android.os.Bundle;
  4. import android.text.SpannableStringBuilder;
  5. import android.text.Spanned;
  6. import android.text.TextUtils;
  7. import android.text.style.ForegroundColorSpan;
  8. import android.widget.Button;
  9. import android.widget.CheckBox;
  10. import android.widget.CompoundButton;
  11. import android.widget.ImageView;
  12. import android.widget.TextView;
  13. import com.hjq.dialog.ToastDialog;
  14. import butterknife.BindView;
  15. import butterknife.ButterKnife;
  16. import butterknife.OnClick;
  17. import eVVM.apk.R;
  18. import eVVM.apk.common.MyActivity;
  19. import eVVM.apk.helper.SPUtils;
  20. import eVVM.apk.mvp.MvpActivity;
  21. import eVVM.apk.ui.My.examine.ExamineContract;
  22. import eVVM.apk.ui.My.examine.ExaminePresenter;
  23. import eVVM.apk.ui.bean.VerificationCodeBean;
  24. public class ExamineActivity extends MvpActivity<ExaminePresenter> implements ExamineContract.View {
  25. @BindView(R.id.examine_iv)
  26. ImageView examineIv;
  27. @BindView(R.id.examine_tv)
  28. TextView examineTv;
  29. @BindView(R.id.examine_cb_agree)
  30. CheckBox examineCbAgree;
  31. @BindView(R.id.examine_tv_protocol)
  32. TextView examineTvProtocol;
  33. @BindView(R.id.examine_btn_true)
  34. Button examineBtnTrue;
  35. @Override
  36. protected int getLayoutId() {
  37. return R.layout.activity_examine;
  38. }
  39. @Override
  40. protected int getTitleId() {
  41. return 0;
  42. }
  43. @Override
  44. protected void initView() {
  45. //设置用户协议
  46. toProtocol();
  47. examineBtnTrue.setEnabled(false);
  48. //设置 button的状态
  49. getBtnStact();
  50. }
  51. private void toProtocol() {
  52. SpannableStringBuilder builder = new SpannableStringBuilder(examineTvProtocol.getText().toString());
  53. ForegroundColorSpan blueSpan = new ForegroundColorSpan(Color.BLUE);
  54. //UnderlineSpan lineSpan = new UnderlineSpan();
  55. // builder.setSpan(lineSpan,8,16, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //下划线
  56. builder.setSpan(blueSpan, 9, 15, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //字体颜色
  57. examineTvProtocol.setText(builder);
  58. }
  59. private void getBtnStact() {
  60. examineCbAgree.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  61. @Override
  62. public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
  63. if (b) {
  64. examineBtnTrue.setEnabled(true);
  65. } else {
  66. //forgetBtnLogin.setClickable(false);
  67. examineBtnTrue.setEnabled(false);
  68. }
  69. }
  70. });
  71. }
  72. @Override
  73. protected void initData() {
  74. }
  75. @OnClick(R.id.examine_btn_true)
  76. public void onViewClicked() {
  77. String user_id = (String) SPUtils.get("USER_ID", "");
  78. getPresenter().agreeProtocol(user_id + "");
  79. }
  80. @Override
  81. protected ExaminePresenter createPresenter() {
  82. return new ExaminePresenter();
  83. }
  84. @Override
  85. public void agreeError(String msg) {
  86. toast(msg);
  87. }
  88. @Override
  89. public void agreeSuccess(VerificationCodeBean data) {
  90. new ToastDialog.Builder(this)
  91. .setType(ToastDialog.Type.FINISH)
  92. .setMessage("完成")
  93. .show();
  94. postDelayed(new Runnable() {
  95. @Override
  96. public void run() {
  97. toast("认证成功,请进行登录");
  98. finish();
  99. }
  100. }, 500);
  101. }
  102. }