移除阿里云短信SDK
This commit is contained in:
parent
af750aaf8c
commit
a177e6ebf7
|
|
@ -100,11 +100,11 @@ dependencies {
|
|||
//定位
|
||||
// implementation files('libs/Android_2DMap_V2.4.0.jar')
|
||||
//地图
|
||||
implementation files('libs/MobCommons-2016.1012.1447.jar')
|
||||
implementation files('libs/MobTools-2016.1012.1447.jar')
|
||||
// implementation files('libs/MobCommons-2016.1012.1447.jar')
|
||||
// implementation files('libs/MobTools-2016.1012.1447.jar')
|
||||
|
||||
//MOB短信平台
|
||||
implementation name: 'SMSSDK-2.1.2', ext: 'aar'
|
||||
// implementation name: 'SMSSDK-2.1.2', ext: 'aar'
|
||||
|
||||
//自动滚动ViewPager
|
||||
implementation 'com.jude:rollviewpager:1.4.5'
|
||||
|
|
|
|||
|
|
@ -26,21 +26,16 @@ import com.ifish.geewe.DeviceCamera;
|
|||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.Commons.NetWork;
|
||||
import com.ifish.utils.Commons.Text;
|
||||
import com.ifish.utils.HttpListener;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.MD5Util;
|
||||
import com.ifish.utils.SPUtil;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import cn.smssdk.EventHandler;
|
||||
import cn.smssdk.SMSSDK;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
public class BindPhoneActivity extends BaseActivity {
|
||||
|
|
@ -54,7 +49,7 @@ public class BindPhoneActivity extends BaseActivity {
|
|||
private Timer timer;// 定时器,用于更新下载进度
|
||||
private TimerTask task;// 定时器执行的任务
|
||||
private final String UnknownHostException = "UnknownHostException";
|
||||
EventHandler eh = null;
|
||||
// EventHandler eh = null;
|
||||
private TextView tv_country;
|
||||
private CountryCode countryCode;
|
||||
private TextView tv_smstype, tv_msgcode;
|
||||
|
|
@ -115,95 +110,95 @@ public class BindPhoneActivity extends BaseActivity {
|
|||
private void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
timer = new Timer();
|
||||
eh = new EventHandler() {
|
||||
@Override
|
||||
public void afterEvent(int event, int result, Object data) {
|
||||
Message msg = new Message();
|
||||
msg.arg1 = event;
|
||||
msg.arg2 = result;
|
||||
msg.obj = data;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
SMSSDK.registerEventHandler(eh);
|
||||
// eh = new EventHandler() {
|
||||
// @Override
|
||||
// public void afterEvent(int event, int result, Object data) {
|
||||
// Message msg = new Message();
|
||||
// msg.arg1 = event;
|
||||
// msg.arg2 = result;
|
||||
// msg.obj = data;
|
||||
// mHandler.sendMessage(msg);
|
||||
// }
|
||||
// };
|
||||
// SMSSDK.registerEventHandler(eh);
|
||||
}
|
||||
|
||||
Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
int event = msg.arg1;
|
||||
int result = msg.arg2;
|
||||
Object data = msg.obj;
|
||||
if (result == SMSSDK.RESULT_COMPLETE) {
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
//提交验证码成功
|
||||
wxlogin();
|
||||
} else if (event == SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE || event == SMSSDK.EVENT_GET_VERIFICATION_CODE) {
|
||||
ToastUtil.show(getApplicationContext(), "语音验证码已发送 注意接听手机来电");
|
||||
}
|
||||
} else {
|
||||
dismissProgressDialog();
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
|
||||
//提交验证码失败
|
||||
if (data != null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
} else {
|
||||
//获取验证码失败
|
||||
if (data != null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
// Handler mHandler = new Handler() {
|
||||
// public void handleMessage(Message msg) {
|
||||
// super.handleMessage(msg);
|
||||
// int event = msg.arg1;
|
||||
// int result = msg.arg2;
|
||||
// Object data = msg.obj;
|
||||
// if (result == SMSSDK.RESULT_COMPLETE) {
|
||||
// if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
// //提交验证码成功
|
||||
// wxlogin();
|
||||
// } else if (event == SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE || event == SMSSDK.EVENT_GET_VERIFICATION_CODE) {
|
||||
// ToastUtil.show(getApplicationContext(), "语音验证码已发送 注意接听手机来电");
|
||||
// }
|
||||
// } else {
|
||||
// dismissProgressDialog();
|
||||
// if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
|
||||
// //提交验证码失败
|
||||
// if (data != null) {
|
||||
// if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
// ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// int status = 0;
|
||||
// try {
|
||||
// ((Throwable) data).printStackTrace();
|
||||
// Throwable throwable = (Throwable) data;
|
||||
// JSONObject object = new JSONObject(throwable.getMessage());
|
||||
// String des = object.optString("detail");
|
||||
// status = object.optInt("status");
|
||||
// if (!TextUtils.isEmpty(des)) {
|
||||
// ToastUtil.show(getApplicationContext(), des);
|
||||
// return;
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
// }
|
||||
// } else {
|
||||
// //获取验证码失败
|
||||
// if (data != null) {
|
||||
// if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
// ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
// //获取验证码失败
|
||||
// task.cancel();
|
||||
// tv_code.setClickable(true);
|
||||
// tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// int status = 0;
|
||||
// try {
|
||||
// ((Throwable) data).printStackTrace();
|
||||
// Throwable throwable = (Throwable) data;
|
||||
// JSONObject object = new JSONObject(throwable.getMessage());
|
||||
// String des = object.optString("detail");
|
||||
// status = object.optInt("status");
|
||||
// if (!TextUtils.isEmpty(des)) {
|
||||
// ToastUtil.show(getApplicationContext(), des);
|
||||
// //获取验证码失败
|
||||
// task.cancel();
|
||||
// tv_code.setClickable(true);
|
||||
// tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// return;
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
private int result;
|
||||
private User loginUser;
|
||||
private SPUtil sp;
|
||||
|
|
@ -420,7 +415,7 @@ public class BindPhoneActivity extends BaseActivity {
|
|||
private void initView() {
|
||||
act = this;
|
||||
time = new TimeCount(60000, 1000);
|
||||
tv_code = (TextView) findViewById(R.id.tv_code);
|
||||
// tv_code = (TextView) findViewById(R.id.tv_code);
|
||||
et_phone = (EditText) findViewById(R.id.et_phone);
|
||||
et_psw = (EditText) findViewById(R.id.et_psw);
|
||||
et_messge = (EditText) findViewById(R.id.et_messge);
|
||||
|
|
@ -430,7 +425,7 @@ public class BindPhoneActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
private void initListener() {
|
||||
findViewById(R.id.tv_code).setOnClickListener(this);
|
||||
// findViewById(R.id.tv_code).setOnClickListener(this);
|
||||
findViewById(R.id.bt_submit).setOnClickListener(this);
|
||||
findViewById(R.id.rl_country).setOnClickListener(this);
|
||||
tv_smstype.setOnClickListener(this);
|
||||
|
|
@ -443,46 +438,46 @@ public class BindPhoneActivity extends BaseActivity {
|
|||
* @author Jacky dada
|
||||
* @date 2015-9-6 下午8:15:45
|
||||
*/
|
||||
private void startTime() {
|
||||
CURRENTDELAYTIME = DELAYTIME;
|
||||
task = new TimerTask() {
|
||||
// private void startTime() {
|
||||
// CURRENTDELAYTIME = DELAYTIME;
|
||||
// task = new TimerTask() {
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
// UIHandler.sendEmptyMessage(7);
|
||||
// }
|
||||
// };
|
||||
// timer.schedule(task, 0, 1000);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
UIHandler.sendEmptyMessage(7);
|
||||
}
|
||||
};
|
||||
timer.schedule(task, 0, 1000);
|
||||
}
|
||||
|
||||
Handler UIHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case 7:
|
||||
if (CURRENTDELAYTIME <= 0) {
|
||||
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
} else {
|
||||
CURRENTDELAYTIME--;
|
||||
tv_code.setText(CURRENTDELAYTIME + "\"");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
// Handler UIHandler = new Handler() {
|
||||
// public void handleMessage(Message msg) {
|
||||
// switch (msg.what) {
|
||||
// case 7:
|
||||
// if (CURRENTDELAYTIME <= 0) {
|
||||
//
|
||||
// task.cancel();
|
||||
// tv_code.setClickable(true);
|
||||
// tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// } else {
|
||||
// CURRENTDELAYTIME--;
|
||||
// tv_code.setText(CURRENTDELAYTIME + "\"");
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ;
|
||||
// };
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
SMSSDK.unregisterEventHandler(eh);
|
||||
// SMSSDK.unregisterEventHandler(eh);
|
||||
EventBus.getDefault().unregister(this);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
|
|
@ -493,43 +488,43 @@ public class BindPhoneActivity extends BaseActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
Handler codeHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
/**
|
||||
* 1:获取成功
|
||||
0:获取失败
|
||||
-2:该用户还未注册
|
||||
*/
|
||||
dismissProgressDialog();
|
||||
switch (msg.what) {
|
||||
case NetWork.Success:
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
ToastUtil.show(getApplicationContext(), "短信验证码发送成功");
|
||||
break;
|
||||
case NetWork.Fail:
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
break;
|
||||
case NetWork.NotRegistered:
|
||||
ToastUtil.show(getApplicationContext(), "用户尚未注册");
|
||||
et_phone.setText("");
|
||||
break;
|
||||
case NetWork.ERROR:
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
break;
|
||||
case NetWork.Unknown:
|
||||
ToastUtil.show(getApplicationContext(), Text.Unknown);
|
||||
break;
|
||||
|
||||
default:
|
||||
ToastUtil.show(getApplicationContext(), Text.ServerException);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
// Handler codeHandler = new Handler() {
|
||||
// public void handleMessage(Message msg) {
|
||||
// /**
|
||||
// * 1:获取成功
|
||||
// 0:获取失败
|
||||
// -2:该用户还未注册
|
||||
// */
|
||||
// dismissProgressDialog();
|
||||
// switch (msg.what) {
|
||||
// case NetWork.Success:
|
||||
// tv_code.setClickable(false);
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// tv_code.setText("60\"");
|
||||
// startTime();
|
||||
// ToastUtil.show(getApplicationContext(), "短信验证码发送成功");
|
||||
// break;
|
||||
// case NetWork.Fail:
|
||||
// ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
// break;
|
||||
// case NetWork.NotRegistered:
|
||||
// ToastUtil.show(getApplicationContext(), "用户尚未注册");
|
||||
// et_phone.setText("");
|
||||
// break;
|
||||
// case NetWork.ERROR:
|
||||
// ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
// break;
|
||||
// case NetWork.Unknown:
|
||||
// ToastUtil.show(getApplicationContext(), Text.Unknown);
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// ToastUtil.show(getApplicationContext(), Text.ServerException);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -549,22 +544,22 @@ public class BindPhoneActivity extends BaseActivity {
|
|||
// 点击事件
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.tv_code: {//注册验证码
|
||||
if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (countryCode == null) {
|
||||
countryCode = new CountryCode("86", "中国");
|
||||
}
|
||||
SMSSDK.getVoiceVerifyCode(countryCode.countryCode, et_phone.getText().toString());
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
break;
|
||||
}
|
||||
// case R.id.tv_code: {//注册验证码
|
||||
// if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
// ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
// return;
|
||||
// }
|
||||
// if (countryCode == null) {
|
||||
// countryCode = new CountryCode("86", "中国");
|
||||
// }
|
||||
// SMSSDK.getVoiceVerifyCode(countryCode.countryCode, et_phone.getText().toString());
|
||||
// tv_code.setClickable(false);
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// tv_code.setText("60\"");
|
||||
// startTime();
|
||||
// break;
|
||||
// }
|
||||
case R.id.bt_submit: {
|
||||
if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package com.ifish.activity;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
|
@ -15,392 +13,212 @@ import com.ifish.basebean.CountryCode;
|
|||
import com.ifish.baseclass.BaseActivity;
|
||||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.Commons;
|
||||
import com.ifish.utils.Commons.NetWork;
|
||||
import com.ifish.utils.Commons.Text;
|
||||
import com.ifish.utils.HttpListener;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import com.lidroid.xutils.util.LogUtils;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import cn.smssdk.EventHandler;
|
||||
import cn.smssdk.SMSSDK;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: ChangePhoneNumActivity
|
||||
* @Description: 换手机号
|
||||
* @author Jacky dada
|
||||
* @date 2015-9-14 下午2:38:12
|
||||
* @author Jacky dada
|
||||
* @ClassName: ChangePhoneNumActivity
|
||||
* @Description: 换手机号
|
||||
* @date 2015-9-14 下午2:38:12
|
||||
*/
|
||||
public class ChangePhoneNumActivity extends BaseActivity {
|
||||
private EditText et_messge;
|
||||
private TextView tv_code,tv_phonenum;
|
||||
private HttpManager hm=HttpManager.getInstance();
|
||||
private int CURRENTDELAYTIME;
|
||||
private final int DELAYTIME = 60;//60S倒数
|
||||
private Timer timer;// 定时器,用于更新下载进度
|
||||
private TimerTask task;// 定时器执行的任务
|
||||
EventHandler eh=null;
|
||||
private final String UnknownHostException="UnknownHostException";
|
||||
private int disableColor = drawable.tvcode_press_noright_shape;
|
||||
private int ebleColor = drawable.login_bt_noright_shape;
|
||||
private CountryCode countryCode;
|
||||
private TextView tv_country;
|
||||
private TextView tv_msgcode;
|
||||
private TimeCount time;
|
||||
private EditText et_messge;
|
||||
private TextView tv_code, tv_phonenum;
|
||||
private HttpManager hm = HttpManager.getInstance();
|
||||
private int CURRENTDELAYTIME;
|
||||
private final int DELAYTIME = 60;//60S倒数
|
||||
private Timer timer;// 定时器,用于更新下载进度
|
||||
private TimerTask task;// 定时器执行的任务
|
||||
// EventHandler eh=null;
|
||||
private final String UnknownHostException = "UnknownHostException";
|
||||
private int disableColor = drawable.tvcode_press_noright_shape;
|
||||
private int ebleColor = drawable.login_bt_noright_shape;
|
||||
private CountryCode countryCode;
|
||||
private TextView tv_country;
|
||||
private TextView tv_msgcode;
|
||||
private TimeCount time;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.changephonenum_activity);
|
||||
initTitle("更换手机号");
|
||||
initView();
|
||||
initListener();
|
||||
init();
|
||||
}
|
||||
private void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
timer = new Timer();
|
||||
String phonenum = Commons.PHONE_NUM;
|
||||
if (!TextUtils.isEmpty(phonenum)) {
|
||||
if (phonenum.length()==11) {
|
||||
String substring1 = phonenum.substring(0, 3);
|
||||
String substring2 = phonenum.substring(7, 11);
|
||||
tv_phonenum.setText(substring1+"****"+substring2);
|
||||
}else{
|
||||
tv_phonenum.setText(Commons.PHONE_NUM);
|
||||
}
|
||||
}
|
||||
eh=new EventHandler() {
|
||||
@Override
|
||||
public void afterEvent(int event, int result, Object data) {
|
||||
Message msg = new Message();
|
||||
msg.arg1 = event;
|
||||
msg.arg2 = result;
|
||||
msg.obj = data;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
SMSSDK.registerEventHandler(eh);
|
||||
}
|
||||
public static final int EVENT_SUBMIT_VERIFICATION_CODE = 3;
|
||||
public static final int RESULT_COMPLETE = -1;
|
||||
|
||||
Handler mHandler = new Handler(){
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
int event = msg.arg1;
|
||||
int result = msg.arg2;
|
||||
Object data = msg.obj;
|
||||
if (result == SMSSDK.RESULT_COMPLETE) {
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
//提交验证码成功
|
||||
startActivity(ResetPhoneNumActivity.class);
|
||||
AnimationUtil.startAnimation(ChangePhoneNumActivity.this);
|
||||
finish();
|
||||
}else if (event ==SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE){
|
||||
ToastUtil.show(getApplicationContext(), "语音验证码已发送 注意接听手机来电");
|
||||
}
|
||||
} else {
|
||||
dismissProgressDialog();
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
|
||||
//提交验证码失败
|
||||
if (data!=null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
}else {
|
||||
//获取验证码失败
|
||||
if (data!=null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.changephonenum_activity);
|
||||
initTitle("更换手机号");
|
||||
initView();
|
||||
initListener();
|
||||
init();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
private void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
timer = new Timer();
|
||||
String phonenum = Commons.PHONE_NUM;
|
||||
LogUtils.d("ifish LHD 当前的手机号: " + phonenum);
|
||||
if (!TextUtils.isEmpty(phonenum)) {
|
||||
if (phonenum.length() == 11) {
|
||||
String substring1 = phonenum.substring(0, 3);
|
||||
String substring2 = phonenum.substring(7, 11);
|
||||
tv_phonenum.setText(substring1 + "****" + substring2);
|
||||
} else {
|
||||
tv_phonenum.setText(Commons.PHONE_NUM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tv_code = (TextView) findViewById(R.id.tv_code);
|
||||
tv_phonenum = (TextView) findViewById(R.id.tv_phonenum);
|
||||
et_messge = (EditText) findViewById(R.id.et_messge);
|
||||
tv_country=findMyViewById(R.id.tv_country);
|
||||
tv_msgcode = (TextView) findViewById(R.id.tv_msgcode);
|
||||
time = new TimeCount(60000, 1000);
|
||||
}
|
||||
private void initListener() {
|
||||
findViewById(R.id.tv_code).setOnClickListener(this);
|
||||
findViewById(R.id.bt_submit).setOnClickListener(this);
|
||||
findViewById(R.id.rl_bg).setOnClickListener(this);
|
||||
findViewById(R.id.rl_country).setOnClickListener(this);
|
||||
tv_msgcode.setOnClickListener(this);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @Description: 60S短信倒数
|
||||
* @author Jacky dada
|
||||
* @param
|
||||
* @date 2015-9-6 下午8:15:45
|
||||
*/
|
||||
private void startTime() {
|
||||
CURRENTDELAYTIME = DELAYTIME;
|
||||
task = new TimerTask() {
|
||||
private void initView() {
|
||||
tv_code = (TextView) findViewById(R.id.tv_code);
|
||||
tv_phonenum = (TextView) findViewById(R.id.tv_phonenum);
|
||||
et_messge = (EditText) findViewById(R.id.et_messge);
|
||||
tv_country = findMyViewById(R.id.tv_country);
|
||||
tv_msgcode = (TextView) findViewById(R.id.tv_msgcode);
|
||||
time = new TimeCount(60000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
UIHandler.sendEmptyMessage(7);
|
||||
}
|
||||
};
|
||||
timer.schedule(task,0,1000);
|
||||
}
|
||||
Handler UIHandler = new Handler(){
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
switch (msg.what) {
|
||||
case 7:
|
||||
if(CURRENTDELAYTIME<=0){
|
||||
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
}else{
|
||||
CURRENTDELAYTIME--;
|
||||
tv_code.setText(CURRENTDELAYTIME+"\"");
|
||||
}
|
||||
break;
|
||||
private void initListener() {
|
||||
findViewById(R.id.tv_code).setOnClickListener(this);
|
||||
findViewById(R.id.bt_submit).setOnClickListener(this);
|
||||
findViewById(R.id.rl_bg).setOnClickListener(this);
|
||||
findViewById(R.id.rl_country).setOnClickListener(this);
|
||||
tv_msgcode.setOnClickListener(this);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
SMSSDK.unregisterEventHandler(eh);
|
||||
EventBus.getDefault().unregister(this);
|
||||
if(task != null){
|
||||
task.cancel();
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
task = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
Handler codeHandler = new Handler(){
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
/**
|
||||
* 1:获取成功
|
||||
0:获取失败
|
||||
-2:该用户还未注册
|
||||
*/
|
||||
dismissProgressDialog();
|
||||
switch (msg.what) {
|
||||
case NetWork.Success:
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
ToastUtil.show(getApplicationContext(), "短信验证码发送成功");
|
||||
break;
|
||||
case NetWork.Fail:
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
break;
|
||||
case NetWork.NotRegistered:
|
||||
ToastUtil.show(getApplicationContext(), "该用户还未注册");
|
||||
break;
|
||||
case NetWork.ERROR:
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
break;
|
||||
case NetWork.Unknown:
|
||||
ToastUtil.show(getApplicationContext(), Text.Unknown);
|
||||
break;
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
task = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
default:
|
||||
ToastUtil.show(getApplicationContext(), Text.ServerException);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 国家/地区发生改变
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void onEventMainThread(CountryCode event) {
|
||||
if (tv_country != null) {
|
||||
tv_country.setText(event.country + " +" + event.countryCode);
|
||||
}
|
||||
countryCode = event;
|
||||
}
|
||||
|
||||
private String smsCode;
|
||||
|
||||
/**
|
||||
* 国家/地区发生改变
|
||||
* @param event
|
||||
*/
|
||||
public void onEventMainThread(CountryCode event) {
|
||||
if (tv_country != null) {
|
||||
tv_country.setText(event.country+" +"+event.countryCode);
|
||||
}
|
||||
countryCode=event;
|
||||
}
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 点击事件
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.rl_bg:
|
||||
hideKeyboard();
|
||||
break;
|
||||
case R.id.tv_msgcode: {
|
||||
if (countryCode == null) {
|
||||
countryCode = new CountryCode("86", "中国");
|
||||
}
|
||||
hm.getForgetPSWCode(new HttpListener<BaseBean<String>>() {
|
||||
@Override
|
||||
public void success(BaseBean<String> baseBean) {
|
||||
if (baseBean.result == 201) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(getApplicationContext(), "手机号已被注册 请直接登录");
|
||||
}
|
||||
});
|
||||
} else if (baseBean.result == 100) {
|
||||
smsCode = baseBean.data;
|
||||
time.start();
|
||||
} else {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(getApplicationContext(), "发送短信失败 请重新获取");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private String smsCode;
|
||||
@Override
|
||||
public void error(Exception e, String msg) {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 点击事件
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.rl_bg:
|
||||
hideKeyboard();
|
||||
break;
|
||||
case R.id.tv_code: {
|
||||
if (countryCode == null) {
|
||||
countryCode=new CountryCode("86","中国");
|
||||
}
|
||||
SMSSDK.getVoiceVerifyCode(countryCode.countryCode, Commons.PHONE_NUM);
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case R.id.tv_msgcode: {
|
||||
if (countryCode == null) {
|
||||
countryCode=new CountryCode("86","中国");
|
||||
}
|
||||
hm.getForgetPSWCode(new HttpListener<BaseBean<String>>() {
|
||||
@Override
|
||||
public void success(BaseBean<String> baseBean) {
|
||||
if (baseBean.result == 201) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(getApplicationContext(), "手机号已被注册 请直接登录");
|
||||
}
|
||||
});
|
||||
} else if (baseBean.result == 100) {
|
||||
smsCode = baseBean.data;
|
||||
time.start();
|
||||
} else {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(getApplicationContext(), "发送短信失败 请重新获取");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void finish() {
|
||||
|
||||
@Override
|
||||
public void error(Exception e, String msg) {
|
||||
}
|
||||
}, Commons.PHONE_NUM);
|
||||
break;
|
||||
}
|
||||
case R.id.bt_submit:
|
||||
if (et_messge.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
ToastUtil.show(getApplicationContext(), "请输入短信验证码");
|
||||
return;
|
||||
}
|
||||
if (countryCode == null) {
|
||||
countryCode = new CountryCode("86", "中国");
|
||||
}
|
||||
|
||||
}
|
||||
if (smsCode == null) {
|
||||
ToastUtil.show(getApplicationContext(), "请先获取短信码");
|
||||
return;
|
||||
}
|
||||
if (et_messge.getText().toString().equals(smsCode)) {
|
||||
//提交验证码成功
|
||||
startActivity(ResetPhoneNumActivity.class);
|
||||
AnimationUtil.startAnimation(ChangePhoneNumActivity.this);
|
||||
finish();
|
||||
} else {
|
||||
ToastUtil.show(getApplicationContext(), "请输入正确的短信验证码");
|
||||
dismissProgressDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
break;
|
||||
case R.id.rl_country: {//国家代码
|
||||
startActivity(CountryListActivity.class);
|
||||
AnimationUtil.startAnimation(ChangePhoneNumActivity.this);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}, Commons.PHONE_NUM);
|
||||
break;
|
||||
}
|
||||
case R.id.bt_submit:
|
||||
if (et_messge.getText().toString().replaceAll(" ","").length()==0) {
|
||||
ToastUtil.show(getApplicationContext(), "请输入短信验证码");
|
||||
return;
|
||||
}
|
||||
if (countryCode == null) {
|
||||
countryCode=new CountryCode("86","中国");
|
||||
}
|
||||
// SMSSDK.submitVerificationCode(countryCode.countryCode, Commons.PHONE_NUM, et_messge.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (smsCode == null) {
|
||||
ToastUtil.show(getApplicationContext(), "请先获取短信码");
|
||||
return;
|
||||
}
|
||||
if (et_messge.getText().toString().equals(smsCode)) {
|
||||
Message msg = new Message();
|
||||
msg.arg1 = SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE;
|
||||
msg.arg2 = SMSSDK.RESULT_COMPLETE;
|
||||
mHandler.sendMessage(msg);
|
||||
} else {
|
||||
ToastUtil.show(getApplicationContext(), "请输入正确的短信验证码");
|
||||
dismissProgressDialog();
|
||||
}
|
||||
class TimeCount extends CountDownTimer {
|
||||
|
||||
break;
|
||||
case R.id.rl_country: {//国家代码
|
||||
startActivity(CountryListActivity.class);
|
||||
AnimationUtil.startAnimation(ChangePhoneNumActivity.this);
|
||||
break;
|
||||
}
|
||||
public TimeCount(long millisInFuture, long countDownInterval) {
|
||||
super(millisInFuture, countDownInterval);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
tv_msgcode.setClickable(false);
|
||||
tv_msgcode.setText(millisUntilFinished / 1000 + "\"");
|
||||
tv_msgcode.setBackgroundDrawable(tv_msgcode
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
}
|
||||
|
||||
class TimeCount extends CountDownTimer {
|
||||
|
||||
public TimeCount(long millisInFuture, long countDownInterval) {
|
||||
super(millisInFuture, countDownInterval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
tv_msgcode.setClickable(false);
|
||||
tv_msgcode.setText(millisUntilFinished / 1000 + "\"");
|
||||
tv_msgcode.setBackgroundDrawable(tv_msgcode
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
tv_msgcode.setText("短信验证码");
|
||||
tv_msgcode.setClickable(true);
|
||||
tv_msgcode.setBackgroundDrawable(tv_msgcode
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFinish() {
|
||||
tv_msgcode.setText("短信验证码");
|
||||
tv_msgcode.setClickable(true);
|
||||
tv_msgcode.setBackgroundDrawable(tv_msgcode
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import android.app.Activity;
|
|||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
|
@ -15,19 +13,13 @@ import com.ifish.basebean.BaseBean;
|
|||
import com.ifish.basebean.CountryCode;
|
||||
import com.ifish.baseclass.BaseActivity;
|
||||
import com.ifish.utils.AnimationUtil;
|
||||
import com.ifish.utils.Commons.NetWork;
|
||||
import com.ifish.utils.Commons.Text;
|
||||
import com.ifish.utils.HttpListener;
|
||||
import com.ifish.utils.HttpManager;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import cn.smssdk.EventHandler;
|
||||
import cn.smssdk.SMSSDK;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +39,7 @@ public class ForgetPSWActivity extends BaseActivity {
|
|||
private Timer timer;// 定时器,用于更新下载进度
|
||||
private TimerTask task;// 定时器执行的任务
|
||||
private final String UnknownHostException = "UnknownHostException";
|
||||
EventHandler eh = null;
|
||||
// EventHandler eh = null;
|
||||
private TextView tv_country;
|
||||
private CountryCode countryCode;
|
||||
private TextView tv_smstype, tv_msgcode;
|
||||
|
|
@ -93,99 +85,99 @@ public class ForgetPSWActivity extends BaseActivity {
|
|||
private void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
timer = new Timer();
|
||||
eh = new EventHandler() {
|
||||
@Override
|
||||
public void afterEvent(int event, int result, Object data) {
|
||||
Message msg = new Message();
|
||||
msg.arg1 = event;
|
||||
msg.arg2 = result;
|
||||
msg.obj = data;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
SMSSDK.registerEventHandler(eh);
|
||||
// eh = new EventHandler() {
|
||||
// @Override
|
||||
// public void afterEvent(int event, int result, Object data) {
|
||||
// Message msg = new Message();
|
||||
// msg.arg1 = event;
|
||||
// msg.arg2 = result;
|
||||
// msg.obj = data;
|
||||
// mHandler.sendMessage(msg);
|
||||
// }
|
||||
// };
|
||||
// SMSSDK.registerEventHandler(eh);
|
||||
}
|
||||
|
||||
Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
int event = msg.arg1;
|
||||
int result = msg.arg2;
|
||||
Object data = msg.obj;
|
||||
if (result == SMSSDK.RESULT_COMPLETE) {
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
//提交验证码成功
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("phonenum", et_phone.getText().toString());
|
||||
startActivity(ResetPSWActivity.class, bundle);
|
||||
AnimationUtil.startAnimation(ForgetPSWActivity.this);
|
||||
finish();
|
||||
} else if (event == SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE) {
|
||||
ToastUtil.show(getApplicationContext(), "语音验证码已发送 注意接听手机来电");
|
||||
}
|
||||
} else {
|
||||
dismissProgressDialog();
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
|
||||
//提交验证码失败
|
||||
if (data != null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
} else {
|
||||
//获取验证码失败
|
||||
if (data != null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
// Handler mHandler = new Handler() {
|
||||
// public void handleMessage(Message msg) {
|
||||
// super.handleMessage(msg);
|
||||
// int event = msg.arg1;
|
||||
// int result = msg.arg2;
|
||||
// Object data = msg.obj;
|
||||
// if (result == SMSSDK.RESULT_COMPLETE) {
|
||||
// if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
// //提交验证码成功
|
||||
// Bundle bundle = new Bundle();
|
||||
// bundle.putString("phonenum", et_phone.getText().toString());
|
||||
// startActivity(ResetPSWActivity.class, bundle);
|
||||
// AnimationUtil.startAnimation(ForgetPSWActivity.this);
|
||||
// finish();
|
||||
// } else if (event == SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE) {
|
||||
// ToastUtil.show(getApplicationContext(), "语音验证码已发送 注意接听手机来电");
|
||||
// }
|
||||
// } else {
|
||||
// dismissProgressDialog();
|
||||
// if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
|
||||
// //提交验证码失败
|
||||
// if (data != null) {
|
||||
// if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
// ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// int status = 0;
|
||||
// try {
|
||||
// ((Throwable) data).printStackTrace();
|
||||
// Throwable throwable = (Throwable) data;
|
||||
// JSONObject object = new JSONObject(throwable.getMessage());
|
||||
// String des = object.optString("detail");
|
||||
// status = object.optInt("status");
|
||||
// if (!TextUtils.isEmpty(des)) {
|
||||
// ToastUtil.show(getApplicationContext(), des);
|
||||
// return;
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
// }
|
||||
// } else {
|
||||
// //获取验证码失败
|
||||
// if (data != null) {
|
||||
// if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
// ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
// //获取验证码失败
|
||||
// task.cancel();
|
||||
// tv_code.setClickable(true);
|
||||
// tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// int status = 0;
|
||||
// try {
|
||||
// ((Throwable) data).printStackTrace();
|
||||
// Throwable throwable = (Throwable) data;
|
||||
// JSONObject object = new JSONObject(throwable.getMessage());
|
||||
// String des = object.optString("detail");
|
||||
// status = object.optInt("status");
|
||||
// if (!TextUtils.isEmpty(des)) {
|
||||
// ToastUtil.show(getApplicationContext(), des);
|
||||
// //获取验证码失败
|
||||
// task.cancel();
|
||||
// tv_code.setClickable(true);
|
||||
// tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// return;
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
private void initView() {
|
||||
|
|
@ -252,7 +244,7 @@ public class ForgetPSWActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
SMSSDK.unregisterEventHandler(eh);
|
||||
// SMSSDK.unregisterEventHandler(eh);
|
||||
EventBus.getDefault().unregister(this);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
|
|
@ -263,43 +255,43 @@ public class ForgetPSWActivity extends BaseActivity {
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
Handler codeHandler = new Handler() {
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
/**
|
||||
* 1:获取成功
|
||||
0:获取失败
|
||||
-2:该用户还未注册
|
||||
*/
|
||||
dismissProgressDialog();
|
||||
switch (msg.what) {
|
||||
case NetWork.Success:
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
ToastUtil.show(getApplicationContext(), "短信验证码发送成功");
|
||||
break;
|
||||
case NetWork.Fail:
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
break;
|
||||
case NetWork.NotRegistered:
|
||||
ToastUtil.show(getApplicationContext(), "用户尚未注册");
|
||||
et_phone.setText("");
|
||||
break;
|
||||
case NetWork.ERROR:
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
break;
|
||||
case NetWork.Unknown:
|
||||
ToastUtil.show(getApplicationContext(), Text.Unknown);
|
||||
break;
|
||||
|
||||
default:
|
||||
ToastUtil.show(getApplicationContext(), Text.ServerException);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
// Handler codeHandler = new Handler() {
|
||||
// public void handleMessage(android.os.Message msg) {
|
||||
// /**
|
||||
// * 1:获取成功
|
||||
// 0:获取失败
|
||||
// -2:该用户还未注册
|
||||
// */
|
||||
// dismissProgressDialog();
|
||||
// switch (msg.what) {
|
||||
// case NetWork.Success:
|
||||
// tv_code.setClickable(false);
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// tv_code.setText("60\"");
|
||||
// startTime();
|
||||
// ToastUtil.show(getApplicationContext(), "短信验证码发送成功");
|
||||
// break;
|
||||
// case NetWork.Fail:
|
||||
// ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
// break;
|
||||
// case NetWork.NotRegistered:
|
||||
// ToastUtil.show(getApplicationContext(), "用户尚未注册");
|
||||
// et_phone.setText("");
|
||||
// break;
|
||||
// case NetWork.ERROR:
|
||||
// ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
// break;
|
||||
// case NetWork.Unknown:
|
||||
// ToastUtil.show(getApplicationContext(), Text.Unknown);
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// ToastUtil.show(getApplicationContext(), Text.ServerException);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -319,22 +311,22 @@ public class ForgetPSWActivity extends BaseActivity {
|
|||
// 点击事件
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.tv_code: {//注册验证码
|
||||
if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (countryCode == null) {
|
||||
countryCode = new CountryCode("86", "中国");
|
||||
}
|
||||
SMSSDK.getVoiceVerifyCode(countryCode.countryCode, et_phone.getText().toString());
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
break;
|
||||
}
|
||||
// case R.id.tv_code: {//注册验证码
|
||||
// if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
// ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
// return;
|
||||
// }
|
||||
// if (countryCode == null) {
|
||||
// countryCode = new CountryCode("86", "中国");
|
||||
// }
|
||||
// SMSSDK.getVoiceVerifyCode(countryCode.countryCode, et_phone.getText().toString());
|
||||
// tv_code.setClickable(false);
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// tv_code.setText("60\"");
|
||||
// startTime();
|
||||
// break;
|
||||
// }
|
||||
case R.id.bt_submit: {
|
||||
if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ import java.util.List;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import cn.smssdk.EventHandler;
|
||||
import cn.smssdk.SMSSDK;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
|
|
@ -78,7 +76,7 @@ public class RegisteredActivity extends BaseActivityNotAnim {
|
|||
private User loginUser;
|
||||
private SPUtil sp;
|
||||
private ConfigUtil cp;
|
||||
EventHandler eh = null;
|
||||
// EventHandler eh = null;
|
||||
private final String UnknownHostException = "UnknownHostException";
|
||||
private CountryCode countryCode;
|
||||
private TimeCount time;
|
||||
|
|
@ -152,99 +150,10 @@ public class RegisteredActivity extends BaseActivityNotAnim {
|
|||
cp = ConfigUtil.getInstance(RegisteredActivity.this);
|
||||
toast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
|
||||
timer = new Timer();
|
||||
eh = new EventHandler() {
|
||||
@Override
|
||||
public void afterEvent(int event, int result, Object data) {
|
||||
Message msg = new Message();
|
||||
msg.arg1 = event;
|
||||
msg.arg2 = result;
|
||||
msg.obj = data;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
SMSSDK.registerEventHandler(eh);
|
||||
EventBus.getDefault().register(this);
|
||||
showSmsCode();
|
||||
}
|
||||
|
||||
Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
int event = msg.arg1;
|
||||
int result = msg.arg2;
|
||||
Object data = msg.obj;
|
||||
if (result == SMSSDK.RESULT_COMPLETE) {
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
//提交验证码成功 - 去注册
|
||||
doRegistered();
|
||||
} else if (event == SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE) {
|
||||
ToastUtil.show(getApplicationContext(), "语音验证码已发送 注意接听手机来电");
|
||||
}
|
||||
} else {
|
||||
dismissProgressDialog();
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
|
||||
//提交验证码失败
|
||||
if (data != null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
} else {
|
||||
//获取验证码失败
|
||||
if (data != null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public void initListener() {
|
||||
findViewById(R.id.tv_code).setOnClickListener(this);
|
||||
findViewById(R.id.tv_msgcode).setOnClickListener(this);
|
||||
|
|
@ -255,48 +164,6 @@ public class RegisteredActivity extends BaseActivityNotAnim {
|
|||
tv_changesmscode.setOnClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param
|
||||
* @Description: 60S短信倒数
|
||||
* @author Jacky dada
|
||||
* @date 2015-9-6 下午8:15:45
|
||||
*/
|
||||
private void startTime() {
|
||||
CURRENTDELAYTIME = DELAYTIME;
|
||||
task = new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
UIHandler.sendEmptyMessage(7);
|
||||
}
|
||||
};
|
||||
timer.schedule(task, 0, 1000);
|
||||
}
|
||||
|
||||
Handler UIHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case 7:
|
||||
if (CURRENTDELAYTIME <= 0) {
|
||||
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
} else {
|
||||
CURRENTDELAYTIME--;
|
||||
tv_code.setText(CURRENTDELAYTIME + "\"");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
Handler loginHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
/**
|
||||
|
|
@ -402,7 +269,7 @@ public class RegisteredActivity extends BaseActivityNotAnim {
|
|||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
SMSSDK.unregisterEventHandler(eh);
|
||||
// SMSSDK.unregisterEventHandler(eh);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
timer.cancel();
|
||||
|
|
@ -474,31 +341,25 @@ public class RegisteredActivity extends BaseActivityNotAnim {
|
|||
} else {
|
||||
ToastUtil.show(getApplicationContext(), "请输入正确的短信验证码");
|
||||
}
|
||||
} else {
|
||||
showProgressDialog();
|
||||
if (countryCode == null) {
|
||||
countryCode = new CountryCode("86", "中国");
|
||||
}
|
||||
SMSSDK.submitVerificationCode(countryCode.countryCode, et_phone.getText().toString(), et_messge.getText().toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.tv_code: {//注册验证码
|
||||
if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (countryCode == null) {
|
||||
countryCode = new CountryCode("86", "中国");
|
||||
}
|
||||
SMSSDK.getVoiceVerifyCode(countryCode.countryCode, et_phone.getText().toString());
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
break;
|
||||
}
|
||||
// case R.id.tv_code: {//注册验证码
|
||||
// if (et_phone.getText().toString().replaceAll(" ", "").length() == 0) {
|
||||
// ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
// return;
|
||||
// }
|
||||
// if (countryCode == null) {
|
||||
// countryCode = new CountryCode("86", "中国");
|
||||
// }
|
||||
// SMSSDK.getVoiceVerifyCode(countryCode.countryCode, et_phone.getText().toString());
|
||||
// tv_code.setClickable(false);
|
||||
// tv_code.setBackgroundDrawable(tv_code
|
||||
// .isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
// tv_code.setText("60\"");
|
||||
// startTime();
|
||||
// break;
|
||||
// }
|
||||
case R.id.tv_msgcode: {
|
||||
hm.getSecurityCode(new HttpListener<BaseBean<String>>() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.ifish.activity;
|
||||
|
||||
import static com.ifish.activity.ChangePhoneNumActivity.EVENT_SUBMIT_VERIFICATION_CODE;
|
||||
import static com.ifish.activity.ChangePhoneNumActivity.RESULT_COMPLETE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
|
@ -25,13 +27,9 @@ import com.ifish.utils.HttpManager;
|
|||
import com.ifish.utils.SPUtil;
|
||||
import com.ifish.utils.ToastUtil;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import cn.smssdk.EventHandler;
|
||||
import cn.smssdk.SMSSDK;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
|
|
@ -51,7 +49,6 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
private TimerTask task;// 定时器执行的任务
|
||||
private int result;
|
||||
private SPUtil sp;
|
||||
EventHandler eh=null;
|
||||
private final String UnknownHostException="UnknownHostException";
|
||||
private int disableColor = drawable.tvcode_press_noright_shape;
|
||||
private int ebleColor = drawable.login_bt_noright_shape;
|
||||
|
|
@ -74,17 +71,6 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
private void init() {
|
||||
EventBus.getDefault().register(this);
|
||||
timer = new Timer();
|
||||
eh=new EventHandler() {
|
||||
@Override
|
||||
public void afterEvent(int event, int result, Object data) {
|
||||
Message msg = new Message();
|
||||
msg.arg1 = event;
|
||||
msg.arg2 = result;
|
||||
msg.obj = data;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
};
|
||||
SMSSDK.registerEventHandler(eh);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -94,8 +80,8 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
int event = msg.arg1;
|
||||
int result = msg.arg2;
|
||||
Object data = msg.obj;
|
||||
if (result == SMSSDK.RESULT_COMPLETE) {
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
if (result == RESULT_COMPLETE) {
|
||||
if (event == EVENT_SUBMIT_VERIFICATION_CODE) {//提交验证码成功
|
||||
//提交验证码成功
|
||||
try {
|
||||
hm.updateUser(new HttpListener<BaseBean<User>>() {
|
||||
|
|
@ -111,75 +97,13 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public void error(Exception e, String msg) {
|
||||
ResetPhoneNumActivity.this.result=NetWork.ERROR;
|
||||
ResetPhoneNumActivity.this.result= Commons.NetWork.ERROR;
|
||||
}
|
||||
}, Commons.USER.getUserId(), null, et_phone.getText().toString(), null, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else if (event ==SMSSDK.EVENT_GET_VOICE_VERIFICATION_CODE){
|
||||
ToastUtil.show(getApplicationContext(), "语音验证码已发送 注意接听手机来电");
|
||||
}
|
||||
} else {
|
||||
dismissProgressDialog();
|
||||
if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
|
||||
//提交验证码失败
|
||||
if (data!=null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
}else {
|
||||
//获取验证码失败
|
||||
if (data!=null) {
|
||||
if (data.toString().contains(UnknownHostException)) {//没有网络
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int status = 0;
|
||||
try {
|
||||
((Throwable) data).printStackTrace();
|
||||
Throwable throwable = (Throwable) data;
|
||||
JSONObject object = new JSONObject(throwable.getMessage());
|
||||
String des = object.optString("detail");
|
||||
status = object.optInt("status");
|
||||
if (!TextUtils.isEmpty(des)) {
|
||||
ToastUtil.show(getApplicationContext(), des);
|
||||
//获取验证码失败
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -224,50 +148,9 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
findViewById(R.id.rl_country).setOnClickListener(this);
|
||||
findViewById(R.id.tv_msgcode).setOnClickListener(this);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @Description: 60S短信倒数
|
||||
* @author Jacky dada
|
||||
* @param
|
||||
* @date 2015-9-6 下午8:15:45
|
||||
*/
|
||||
private void startTime() {
|
||||
CURRENTDELAYTIME = DELAYTIME;
|
||||
task = new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
UIHandler.sendEmptyMessage(7);
|
||||
}
|
||||
};
|
||||
timer.schedule(task,0,1000);
|
||||
}
|
||||
Handler UIHandler = new Handler(){
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
switch (msg.what) {
|
||||
case 7:
|
||||
if(CURRENTDELAYTIME<=0){
|
||||
|
||||
task.cancel();
|
||||
tv_code.setClickable(true);
|
||||
tv_code.setText(getResources().getString(R.string.voice_code));
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
}else{
|
||||
CURRENTDELAYTIME--;
|
||||
tv_code.setText(CURRENTDELAYTIME+"\"");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
SMSSDK.unregisterEventHandler(eh);
|
||||
if(task != null){
|
||||
task.cancel();
|
||||
timer.cancel();
|
||||
|
|
@ -276,42 +159,7 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
Handler codeHandler = new Handler(){
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
/**
|
||||
* 1:获取成功
|
||||
0:获取失败
|
||||
-2:该用户还未注册
|
||||
*/
|
||||
dismissProgressDialog();
|
||||
switch (msg.what) {
|
||||
case NetWork.Success:
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
ToastUtil.show(getApplicationContext(), "短信验证码发送成功");
|
||||
break;
|
||||
case NetWork.Fail:
|
||||
ToastUtil.show(getApplicationContext(), "获取失败");
|
||||
break;
|
||||
case NetWork.RepeatMobile:
|
||||
ToastUtil.show(getApplicationContext(), "该手机号已被使用");
|
||||
break;
|
||||
case NetWork.ERROR:
|
||||
ToastUtil.show(getApplicationContext(), Text.ERROR);
|
||||
break;
|
||||
case NetWork.Unknown:
|
||||
ToastUtil.show(getApplicationContext(), Text.Unknown);
|
||||
break;
|
||||
|
||||
default:
|
||||
ToastUtil.show(getApplicationContext(), Text.ServerException);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
Handler submintHandler = new Handler(){
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
|
||||
|
|
@ -373,23 +221,6 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
case R.id.rl_bg:
|
||||
hideKeyboard();
|
||||
break;
|
||||
case R.id.tv_code: {
|
||||
if(et_phone.getText().toString().replaceAll(" ","").length()==0){
|
||||
ToastUtil.show(getApplicationContext(), "请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (countryCode == null) {
|
||||
countryCode=new CountryCode("86","中国");
|
||||
}
|
||||
SMSSDK.getVoiceVerifyCode(countryCode.countryCode, et_phone.getText().toString());
|
||||
tv_code.setClickable(false);
|
||||
tv_code.setBackgroundDrawable(tv_code
|
||||
.isClickable() ? getResources().getDrawable(ebleColor) : getResources().getDrawable(disableColor));
|
||||
tv_code.setText("60\"");
|
||||
startTime();
|
||||
break;
|
||||
}
|
||||
|
||||
case R.id.tv_msgcode: {
|
||||
hm.getSecurityCode(new HttpListener<BaseBean<String>>() {
|
||||
@Override
|
||||
|
|
@ -447,14 +278,13 @@ public class ResetPhoneNumActivity extends BaseActivity {
|
|||
if (et_messge.getText().toString().equals(smsCode)) {
|
||||
showProgressDialog();
|
||||
Message msg = new Message();
|
||||
msg.arg1 = SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE;
|
||||
msg.arg2 = SMSSDK.RESULT_COMPLETE;
|
||||
msg.arg1 = EVENT_SUBMIT_VERIFICATION_CODE;
|
||||
msg.arg2 = RESULT_COMPLETE;
|
||||
mHandler.sendMessage(msg);
|
||||
} else {
|
||||
ToastUtil.show(getApplicationContext(), "请输入正确的短信验证码");
|
||||
dismissProgressDialog();
|
||||
}
|
||||
// SMSSDK.submitVerificationCode(countryCode.countryCode, et_phone.getText().toString(), et_messge.getText().toString());
|
||||
break;
|
||||
|
||||
case R.id.rl_country: {//国家代码
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ import com.tendcloud.tenddata.TCAgent;
|
|||
import com.umeng.socialize.Config;
|
||||
import com.umeng.socialize.PlatformConfig;
|
||||
|
||||
import cn.smssdk.SMSSDK;
|
||||
|
||||
/**
|
||||
* @author Jacky dada
|
||||
* @ClassName: BaseApplication
|
||||
|
|
@ -60,7 +58,7 @@ public class BaseApplication extends MultiDexApplication {
|
|||
initTalkingDataSDK();
|
||||
// initLocationSDK();
|
||||
initShareSDK();
|
||||
initSMSSDK();
|
||||
// initSMSSDK();
|
||||
// initAlibcTradeSDK();
|
||||
initalipushSDK();
|
||||
P2PSpecial.getInstance().init(app, APPID, APPToken, APPVersion);
|
||||
|
|
@ -127,9 +125,9 @@ public class BaseApplication extends MultiDexApplication {
|
|||
HuaWeiRegister.register(this);
|
||||
}
|
||||
|
||||
private void initSMSSDK() {//初始化MOB短信 SDK
|
||||
SMSSDK.initSDK(this, "18c495ec6c718", "7db27e28ff94227f246ae7ef5ad3fb92");
|
||||
}
|
||||
// private void initSMSSDK() {//初始化MOB短信 SDK
|
||||
// SMSSDK.initSDK(this, "18c495ec6c718", "7db27e28ff94227f246ae7ef5ad3fb92");
|
||||
// }
|
||||
|
||||
//talkingdata应用留存统计
|
||||
private void initTalkingDataSDK() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue