|
|
@@ -1,16 +1,31 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
import android.support.v7.widget.AppCompatEditText;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
+import com.sheep.gamegroup.di.components.DaggerPhoneComponent;
|
|
|
+import com.sheep.gamegroup.di.modules.PhoneModule;
|
|
|
+import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
+import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
+import com.sheep.gamegroup.presenter.PhoneContract;
|
|
|
+import com.sheep.gamegroup.presenter.PhonePresenter;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
+import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
+import org.xutils.ex.DbException;
|
|
|
+
|
|
|
+import javax.inject.Inject;
|
|
|
+
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
import butterknife.OnClick;
|
|
|
@@ -19,7 +34,7 @@ import butterknife.OnClick;
|
|
|
* Created by ljy on 2018/3/27.
|
|
|
*/
|
|
|
|
|
|
-public class ChangeTelAct extends BaseActivity {
|
|
|
+public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
@BindView(R.id.tel_tv)
|
|
|
TextView telTv;
|
|
|
@BindView(R.id.change_sure_tv)
|
|
|
@@ -32,13 +47,46 @@ public class ChangeTelAct extends BaseActivity {
|
|
|
AppCompatEditText phoneEtAccount;
|
|
|
@BindView(R.id.phone_et_code)
|
|
|
AppCompatEditText phoneEtCode;
|
|
|
+ @BindView(R.id.phone_et_code_old)
|
|
|
+ AppCompatEditText phone_et_code_old;
|
|
|
@BindView(R.id.phone_btn_code)
|
|
|
TextView phoneBtnCode;
|
|
|
+ @BindView(R.id.phone_btn_code_old)
|
|
|
+ TextView phone_btn_code_old;
|
|
|
+ @BindView(R.id.phone_tip_tv)
|
|
|
+ TextView phone_tip_tv;
|
|
|
@BindView(R.id.phone_sure_tv)
|
|
|
TextView phoneSureTv;
|
|
|
@BindView(R.id.change_phone_layout)
|
|
|
LinearLayout changePhoneLayout;
|
|
|
|
|
|
+ @Inject
|
|
|
+ PhonePresenter presenter;
|
|
|
+
|
|
|
+ private final int CHANGGE_CLICK = 0;//切换手机按钮点击后
|
|
|
+ private final int OLD_PHONE_CLICK = 1;//旧手机获取验证码后
|
|
|
+
|
|
|
+ private int oldOrNew; //1,绑定过 0,未绑定过
|
|
|
+
|
|
|
+ private String hitStr = "请输入手机号";
|
|
|
+ private String noticeStr = "绑定手机号";
|
|
|
+ UserEntity userEntity = null;
|
|
|
+
|
|
|
+ Handler handler = new Handler(){
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ super.handleMessage(msg);
|
|
|
+ switch (msg.what){
|
|
|
+ case CHANGGE_CLICK://
|
|
|
+ refreshData();
|
|
|
+ break;
|
|
|
+ case OLD_PHONE_CLICK://
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.changge_tel_layout;
|
|
|
@@ -47,10 +95,30 @@ public class ChangeTelAct extends BaseActivity {
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
ButterKnife.bind(this);
|
|
|
- TitleBarUtils.getInstance()
|
|
|
- .setTitle(this, "绑定手机号")
|
|
|
- .setTitleFinish(this);
|
|
|
|
|
|
+// DaggerPhoneComponent.builder()
|
|
|
+// .netComponent(SheepApp.get(this).getNetComponent())
|
|
|
+// .phoneModule(new PhoneModule(this))
|
|
|
+// .build()
|
|
|
+// .inject(this);
|
|
|
+ oldOrNew = 0;
|
|
|
+ try {
|
|
|
+ userEntity = MyDbManager.getInstance()
|
|
|
+ .dbFindUser();
|
|
|
+ } catch (DbException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if(userEntity != null && !TextUtils.isEmpty(userEntity.getMobile())){//提示
|
|
|
+
|
|
|
+ TitleBarUtils.getInstance()
|
|
|
+ .setTitle(this, noticeStr)
|
|
|
+ .setTitleFinish(this);
|
|
|
+ showChangeLayout.setVisibility(View.VISIBLE);
|
|
|
+ changePhoneLayout.setVisibility(View.GONE);
|
|
|
+ telTv.setText(userEntity.getMobile()+"");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ refreshData();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -61,16 +129,31 @@ public class ChangeTelAct extends BaseActivity {
|
|
|
@Override
|
|
|
public void initData() {
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- // TODO: add setContentView(...) invocation
|
|
|
- ButterKnife.bind(this);
|
|
|
+ /**
|
|
|
+ * refresh
|
|
|
+ */
|
|
|
+ public void refreshData(){
|
|
|
+ showChangeLayout.setVisibility(View.GONE);
|
|
|
+ changePhoneLayout.setVisibility(View.VISIBLE);
|
|
|
+ if(oldOrNew == 1){
|
|
|
+ hitStr = "请输入原手机号码";
|
|
|
+ noticeStr = "验证原手机";
|
|
|
+ phoneEtAccount.setHint(hitStr+"");
|
|
|
+ phoneEtAccount.setText(userEntity.getMobile()+"");
|
|
|
+ }else{
|
|
|
+ hitStr = "请输入原手机号码";
|
|
|
+ noticeStr = "更换手机号";
|
|
|
+ phoneEtAccount.setHint(hitStr+"");
|
|
|
+ }
|
|
|
+ TitleBarUtils.getInstance()
|
|
|
+ .setTitle(this, noticeStr)
|
|
|
+ .setTitleFinish(this);
|
|
|
}
|
|
|
|
|
|
- @OnClick({R.id.change_sure_tv, R.id.phone_btn_code, R.id.phone_sure_tv, R.id.sure_change_tv})
|
|
|
+ @OnClick({R.id.change_sure_tv, R.id.phone_btn_code, R.id.phone_sure_tv, R.id.sure_change_tv, R.id.phone_btn_code_old})
|
|
|
public void onViewClicked(View view) {
|
|
|
switch (view.getId()) {
|
|
|
case R.id.change_sure_tv:
|
|
|
@@ -80,8 +163,69 @@ public class ChangeTelAct extends BaseActivity {
|
|
|
case R.id.phone_sure_tv:
|
|
|
break;
|
|
|
case R.id.sure_change_tv:
|
|
|
- Jump2View.getInstance().goPhoneLoginView(ChangeTelAct.this, 1);
|
|
|
+ oldOrNew = 1;
|
|
|
+ handler.sendEmptyMessage(CHANGGE_CLICK);
|
|
|
+ if(!checkCodeInput(phone_et_code_old.getText().toString() +"")){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// Jump2View.getInstance().goPhoneLoginView(ChangeTelAct.this, 1);
|
|
|
+ break;
|
|
|
+ case R.id.phone_btn_code_old://旧手机获取验证码
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void returnGaptcha(Object o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void gaptchaFail(BaseMessage o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void returnLogindata(Object o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void loginFail(BaseMessage o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changeTelSuccess(BaseMessage o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changeTelFail(BaseMessage o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private boolean checkPhoneInput(String etPhone) {
|
|
|
+ if (TextUtils.isEmpty(etPhone)) {
|
|
|
+ showToast(getString(R.string.input_your_phone));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (etPhone.toString().length() != 11) {
|
|
|
+ showToast(getString(R.string.toast_warning_phone_number_size));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ private boolean checkCodeInput(String etCode) {
|
|
|
+ if (TextUtils.isEmpty(etCode)) {
|
|
|
+ showToast(getString(R.string.input_your_captcha));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (etCode.toString().length() != 6) {
|
|
|
+ showToast(getString(R.string.toast_warning_phone_captcha_image_code_size));
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|