PageRenderTime 4184ms CodeModel.GetById 47ms RepoModel.GetById 4ms app.codeStats 0ms

/src/com/sinonetwork/zhonghua/EditUserPhone.java

https://gitlab.com/zwp/Zhonghua
Java | 163 lines | 74 code | 13 blank | 76 comment | 1 complexity | 658bdf05fc0710d941425a676bd22bf3 MD5 | raw file
  1. package com.sinonetwork.zhonghua;
  2. import java.util.Timer;
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.util.Log;
  6. import android.view.View;
  7. import android.widget.EditText;
  8. import android.widget.ImageView;
  9. import android.widget.TextView;
  10. import android.widget.Toast;
  11. import com.alibaba.fastjson.JSONObject;
  12. import com.lidroid.xutils.exception.HttpException;
  13. import com.lidroid.xutils.http.ResponseInfo;
  14. import com.lidroid.xutils.http.callback.RequestCallBack;
  15. import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
  16. import com.sinonetwork.zhonghua.model.ZHAccount;
  17. import com.sinonetwork.zhonghua.utils.HttpHelp;
  18. import com.sinonetwork.zhonghua.utils.URLAddress;
  19. import com.sinonetwork.zhonghua.utils.ZhAccountPrefUtil;
  20. public class EditUserPhone extends Activity {
  21. private ImageView back;
  22. private TextView title;
  23. private EditText user_phone;
  24. // private EditText edVerifyCode;
  25. // private Button btnVerifyCode;
  26. // private int randomCode;
  27. // private int seconds = 5;
  28. // private Timer timer;
  29. // private Handler handler = new Handler() {
  30. // public void handleMessage(android.os.Message msg) {
  31. // String content = (String) msg.obj;
  32. // btnVerifyCode.setText(content);
  33. // if (content.equals("获取验证码")) {
  34. // btnVerifyCode.setEnabled(true);
  35. // timer.cancel();
  36. // }
  37. // };
  38. // };
  39. @Override
  40. protected void onCreate(Bundle savedInstanceState) {
  41. // TODO Auto-generated method stub
  42. super.onCreate(savedInstanceState);
  43. setContentView(R.layout.activity_edituser_phone);
  44. initView();
  45. }
  46. private void initView() {
  47. // TODO Auto-generated method stub
  48. back = (ImageView) this.findViewById(R.id.back);
  49. title = (TextView) this.findViewById(R.id.top_title_textview);
  50. user_phone = (EditText) findViewById(R.id.edituser_password_et1);
  51. // edVerifyCode = (EditText) findViewById(R.id.ed_verifyCode);
  52. // btnVerifyCode = (Button) findViewById(R.id.btn_verify);
  53. title.setText("修改用户手机号");
  54. back.setOnClickListener(new View.OnClickListener() {
  55. @Override
  56. public void onClick(View v) {
  57. EditUserPhone.this.finish();
  58. }
  59. });
  60. // btnVerifyCode.setOnClickListener(new View.OnClickListener() {
  61. //
  62. // @Override
  63. // public void onClick(View v) {
  64. // Random random = new Random();
  65. // randomCode = random.nextInt(8999) + 1000;
  66. // String tel = ZhAccountPrefUtil.getZHAccount(EditUserPhone.this)
  67. // .getTelephone();
  68. // Toast.makeText(EditUserPhone.this, "验证码获取成功,没有收到60s后请重试", 2000)
  69. // .show();
  70. // btnVerifyCode.setEnabled(false);
  71. // timer = new Timer();
  72. // TimerTask task = new TimerTask() {
  73. //
  74. // @Override
  75. // public void run() {
  76. // Message msg = new Message();
  77. // if (seconds != 0) {
  78. // msg.obj = "请在" + seconds-- + "秒后重试";
  79. // } else {
  80. // seconds = 60;
  81. // msg.obj = "获取验证码";
  82. // }
  83. // handler.sendMessage(msg);
  84. // }
  85. // };
  86. // timer.schedule(task, 0, 1000);
  87. // RequestParams params = new RequestParams();
  88. // params.addBodyParameter("phone", tel);
  89. // params.addBodyParameter("message", randomCode + "");
  90. //
  91. // HttpHelp.getInstance().send(HttpMethod.POST,
  92. // URLAddress.SendMessage, params,
  93. // new RequestCallBack<String>() {
  94. //
  95. // @Override
  96. // public void onFailure(HttpException arg0,
  97. // String arg1) {
  98. //
  99. // }
  100. //
  101. // @Override
  102. // public void onSuccess(ResponseInfo<String> arg0) {
  103. //
  104. // }
  105. // });
  106. //
  107. // }
  108. // });
  109. }
  110. public void name(View v) {
  111. if (!user_phone
  112. .getText()
  113. .toString()
  114. .matches(
  115. "^((13[0-9])|(15[^4,\\D])|(18[0,0-9])|(14[0-9])|(17[0-9]))\\d{8}$")) {
  116. Toast.makeText(EditUserPhone.this, "请输入正规手机号!", 2000).show();
  117. return;
  118. }
  119. // if (!edVerifyCode.getText().toString().equals(randomCode + "")) {
  120. // Toast.makeText(EditUserPhone.this, "请输入正确地验证码!", 2000).show();
  121. // return;
  122. // }
  123. // 获取当前登入用户的信息
  124. ZHAccount currentAccount = ZhAccountPrefUtil
  125. .getZHAccount(EditUserPhone.this.getApplicationContext());
  126. Log.i("gxx", "获取到的登入用户的信息:" + currentAccount.getUserName());
  127. // 发送修改密码的url
  128. HttpHelp.getInstance().send(
  129. HttpMethod.GET,
  130. URLAddress.changeInfoPhone(currentAccount.getUserName(),
  131. user_phone.getText().toString(), ""),
  132. new RequestCallBack<String>() {
  133. @Override
  134. public void onFailure(HttpException arg0, String arg1) {
  135. // TODO Auto-generated method stub
  136. Toast.makeText(EditUserPhone.this, "修改失败!",
  137. Toast.LENGTH_LONG).show();
  138. }
  139. @Override
  140. public void onSuccess(ResponseInfo<String> arg0) {
  141. // TODO Auto-generated method stub
  142. JSONObject result = JSONObject.parseObject(arg0.result);
  143. Toast.makeText(EditUserPhone.this,
  144. result.getString("resultData"),
  145. Toast.LENGTH_LONG).show();
  146. EditUserPhone.this.finish();
  147. }
  148. });
  149. }
  150. }