|
@@ -11,8 +11,11 @@ import android.widget.TextView;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+
|
|
|
|
|
+import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.di.components.DaggerPhoneComponent;
|
|
import com.sheep.gamegroup.di.components.DaggerPhoneComponent;
|
|
|
import com.sheep.gamegroup.di.modules.PhoneModule;
|
|
import com.sheep.gamegroup.di.modules.PhoneModule;
|
|
|
|
|
+import com.sheep.gamegroup.exception.ApiException;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.LoginEntity;
|
|
import com.sheep.gamegroup.model.entity.LoginEntity;
|
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
@@ -20,17 +23,15 @@ import com.sheep.gamegroup.presenter.PersonalCenterPresenter;
|
|
|
import com.sheep.gamegroup.presenter.PhoneContract;
|
|
import com.sheep.gamegroup.presenter.PhoneContract;
|
|
|
import com.sheep.gamegroup.presenter.PhonePresenter;
|
|
import com.sheep.gamegroup.presenter.PhonePresenter;
|
|
|
import com.sheep.gamegroup.util.ActivityManager;
|
|
import com.sheep.gamegroup.util.ActivityManager;
|
|
|
|
|
+import com.sheep.gamegroup.util.FastJsonUtils;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.MyDbManager;
|
|
import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.SelfCountDownTimer;
|
|
import com.sheep.gamegroup.util.SelfCountDownTimer;
|
|
|
-import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
|
|
-import com.sheep.jiuyan.samllsheep.Config;
|
|
|
|
|
|
|
+
|
|
|
|
|
+import com.sheep.gamegroup.util.XXTEA;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
-import com.sheep.jiuyan.samllsheep.base.BaseActivity;
|
|
|
|
|
-import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
-import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
|
|
|
|
import org.xutils.ex.DbException;
|
|
import org.xutils.ex.DbException;
|
|
|
|
|
|
|
@@ -57,15 +58,12 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
|
|
|
|
|
@Inject
|
|
@Inject
|
|
|
PhonePresenter phonePresenter;
|
|
PhonePresenter phonePresenter;
|
|
|
- @BindView(R.id.phone_tip_tv)
|
|
|
|
|
- TextView phoneTipTv;
|
|
|
|
|
|
|
|
|
|
private SelfCountDownTimer selfCountDownTimer;
|
|
private SelfCountDownTimer selfCountDownTimer;
|
|
|
private boolean canGetCaptchaPhone = true;
|
|
private boolean canGetCaptchaPhone = true;
|
|
|
|
|
|
|
|
private String etPhone;
|
|
private String etPhone;
|
|
|
private String etCode;
|
|
private String etCode;
|
|
|
- private boolean showNotice = false;//false:手机登录,true:绑定手机
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
protected int getLayoutId() {
|
|
@@ -75,16 +73,11 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
@Override
|
|
@Override
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
activity = this;
|
|
activity = this;
|
|
|
- showNotice = getIntent().getBooleanExtra("show_notice", false);
|
|
|
|
|
- TitleBarUtils
|
|
|
|
|
- .getInstance()
|
|
|
|
|
- .setTitle(this, "手机号登录")
|
|
|
|
|
- .setTitleFinish(this);
|
|
|
|
|
DaggerPhoneComponent.builder()
|
|
DaggerPhoneComponent.builder()
|
|
|
.netComponent(SheepApp.get(this).getNetComponent())
|
|
.netComponent(SheepApp.get(this).getNetComponent())
|
|
|
.phoneModule(new PhoneModule(this))
|
|
.phoneModule(new PhoneModule(this))
|
|
|
.build()
|
|
.build()
|
|
|
- .inject(this);
|
|
|
|
|
|
|
+ .inject(this);
|
|
|
// testData();
|
|
// testData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -113,22 +106,16 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void initData() {
|
|
public void initData() {
|
|
|
- if (!showNotice) {
|
|
|
|
|
- phoneTipTv.setVisibility(View.GONE);
|
|
|
|
|
- phoneTipTv.setVisibility(View.GONE);
|
|
|
|
|
- } else {
|
|
|
|
|
- phoneTipTv.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
// TODO: add setContentView(...) invocation
|
|
// TODO: add setContentView(...) invocation
|
|
|
- ButterKnife.bind(this);
|
|
|
|
|
-// phoneEtAccount.setText("17628083502");
|
|
|
|
|
-// phoneEtCode.setText("123456");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ phoneEtAccount.setText("17628083502");
|
|
|
|
|
+ phoneEtCode.setText("123456");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@OnClick({R.id.phone_et_account, R.id.phone_et_code, R.id.phone_btn_code, R.id.phone_sure_tv})
|
|
@OnClick({R.id.phone_et_account, R.id.phone_et_code, R.id.phone_btn_code, R.id.phone_sure_tv})
|
|
@@ -143,37 +130,31 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
getCaptcha();
|
|
getCaptcha();
|
|
|
break;
|
|
break;
|
|
|
case R.id.phone_sure_tv:
|
|
case R.id.phone_sure_tv:
|
|
|
- if(BuildConfig.DEBUG){
|
|
|
|
|
- goMain();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
etPhone = phoneEtAccount.getText().toString().trim();
|
|
etPhone = phoneEtAccount.getText().toString().trim();
|
|
|
etCode = phoneEtCode.getText().toString().trim();
|
|
etCode = phoneEtCode.getText().toString().trim();
|
|
|
loginByPhoneGaptcha();
|
|
loginByPhoneGaptcha();
|
|
|
-
|
|
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean checkPhoneInput() {
|
|
private boolean checkPhoneInput() {
|
|
|
if (TextUtils.isEmpty(etPhone)) {
|
|
if (TextUtils.isEmpty(etPhone)) {
|
|
|
- G.showToast(getString(R.string.input_your_phone));
|
|
|
|
|
|
|
+ showToast(getString(R.string.input_your_phone));
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
if (etPhone.toString().length() != 11) {
|
|
if (etPhone.toString().length() != 11) {
|
|
|
- G.showToast(getString(R.string.toast_warning_phone_number_size));
|
|
|
|
|
|
|
+ showToast(getString(R.string.toast_warning_phone_number_size));
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
private boolean checkCodeInput() {
|
|
private boolean checkCodeInput() {
|
|
|
if (TextUtils.isEmpty(etCode)) {
|
|
if (TextUtils.isEmpty(etCode)) {
|
|
|
- G.showToast(getString(R.string.input_your_captcha));
|
|
|
|
|
|
|
+ showToast(getString(R.string.input_your_captcha));
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
if (etCode.toString().length() != 6) {
|
|
if (etCode.toString().length() != 6) {
|
|
|
- G.showToast(getString(R.string.toast_warning_phone_captcha_image_code_size));
|
|
|
|
|
|
|
+ showToast(getString(R.string.toast_warning_phone_captcha_image_code_size));
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
@@ -182,12 +163,12 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
/**
|
|
/**
|
|
|
* 获取验证码
|
|
* 获取验证码
|
|
|
*/
|
|
*/
|
|
|
- private void getCaptcha() {
|
|
|
|
|
|
|
+ private void getCaptcha(){
|
|
|
|
|
|
|
|
if (!canGetCaptchaPhone) {
|
|
if (!canGetCaptchaPhone) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (!checkPhoneInput()) {
|
|
|
|
|
|
|
+ if(!checkPhoneInput()){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
selfCountDownTimer.reset();
|
|
selfCountDownTimer.reset();
|
|
@@ -195,15 +176,14 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
canGetCaptchaPhone = false;
|
|
canGetCaptchaPhone = false;
|
|
|
selfCountDownTimer.start();
|
|
selfCountDownTimer.start();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 登录
|
|
* 登录
|
|
|
*/
|
|
*/
|
|
|
- private void loginByPhoneGaptcha() {
|
|
|
|
|
- if (!checkPhoneInput()) {
|
|
|
|
|
|
|
+ private void loginByPhoneGaptcha(){
|
|
|
|
|
+ if(!checkPhoneInput()){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (!checkCodeInput()) {
|
|
|
|
|
|
|
+ if(!checkCodeInput()){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -220,47 +200,38 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
@Override
|
|
@Override
|
|
|
public void returnLogindata(Object o) {
|
|
public void returnLogindata(Object o) {
|
|
|
hideProgress();
|
|
hideProgress();
|
|
|
- if (o == null) {
|
|
|
|
|
|
|
+ if(o == null){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
BaseMessage baseMessage = (BaseMessage) o;
|
|
BaseMessage baseMessage = (BaseMessage) o;
|
|
|
// JSONObject a = JSON.parseObject(o.toString());
|
|
// JSONObject a = JSON.parseObject(o.toString());
|
|
|
- Log.e("------data", baseMessage.getData() + "");
|
|
|
|
|
- LoginEntity loginEty = JSONObject.parseObject(JSONObject.toJSONString(baseMessage.getData()), LoginEntity.class);
|
|
|
|
|
|
|
+ Log.e("------data",baseMessage.getData()+"");
|
|
|
|
|
+
|
|
|
|
|
+ LoginEntity loginEty = FastJsonUtils.toBean( JSONObject.toJSONString(baseMessage.getData()),LoginEntity.class);
|
|
|
SpUtils.login(activity, loginEty.getToken());
|
|
SpUtils.login(activity, loginEty.getToken());
|
|
|
try {
|
|
try {
|
|
|
MyDbManager.getInstance().saveOrUpdateUser(loginEty.getUser());
|
|
MyDbManager.getInstance().saveOrUpdateUser(loginEty.getUser());
|
|
|
UserEntity userEntity = MyDbManager.getInstance().dbFindUser();
|
|
UserEntity userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
- Log.e("------userEntity", userEntity.getNickname() + "|" + userEntity.getMobile() + "");
|
|
|
|
|
- G.showToast(userEntity.getNickname() + "|" + userEntity.getMobile());
|
|
|
|
|
|
|
+ Log.e("------userEntity",userEntity.getNickname()+"|"+userEntity.getMobile()+"");
|
|
|
|
|
+ showToast(userEntity.getNickname()+"|"+userEntity.getMobile());
|
|
|
} catch (DbException e) {
|
|
} catch (DbException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Jump2View.getInstance().goHomePageView(activity, null);
|
|
|
|
|
- ActivityManager.getInstance().endActivity(LoginAct.class);
|
|
|
|
|
|
|
+ Jump2View.getInstance().goPersonnalCenterView(activity, null);
|
|
|
finish();
|
|
finish();
|
|
|
Log.e("---login_-", o.toString());
|
|
Log.e("---login_-", o.toString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void loginFail(Object o) {
|
|
|
|
|
|
|
+ public void loginFail(ApiException o) {
|
|
|
hideProgress();
|
|
hideProgress();
|
|
|
- G.showToast("登录失败" + "");
|
|
|
|
|
-// testData();
|
|
|
|
|
|
|
+ showToast(o.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void goMain() {
|
|
|
|
|
- // TODO: 2018/3/22 测试界面,过后删除s
|
|
|
|
|
- SpUtils.login(getApplicationContext(), "12@1c421522bb7e44d3cd6a8d59a54df182");
|
|
|
|
|
-// startActivity(new Intent(this, ActMain.class));
|
|
|
|
|
- Jump2View.getInstance().goHomePageView(this, null);
|
|
|
|
|
- ActivityManager.getInstance().endActivity(LoginAct.class);
|
|
|
|
|
- finish();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- private void testData() {
|
|
|
|
|
- try {
|
|
|
|
|
|
|
+ private void testData(){
|
|
|
|
|
+ try{
|
|
|
String data = "{\n" +
|
|
String data = "{\n" +
|
|
|
" \"data\": {\n" +
|
|
" \"data\": {\n" +
|
|
|
" \"token\": \"12@38948cb4b6e74079615b154a80e3054b\",\n" +
|
|
" \"token\": \"12@38948cb4b6e74079615b154a80e3054b\",\n" +
|
|
@@ -290,14 +261,14 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
String showStr = "登录失败";
|
|
String showStr = "登录失败";
|
|
|
Log.e("---login_-", data);
|
|
Log.e("---login_-", data);
|
|
|
JSONObject a = JSON.parseObject(data);
|
|
JSONObject a = JSON.parseObject(data);
|
|
|
- Log.e("------data", a.get("data") + "");
|
|
|
|
|
|
|
+ Log.e("------data",a.get("data")+"");
|
|
|
LoginEntity loginEty = JSON.parseObject(a.get("data").toString(), LoginEntity.class);
|
|
LoginEntity loginEty = JSON.parseObject(a.get("data").toString(), LoginEntity.class);
|
|
|
SpUtils.login(activity, loginEty.getToken());
|
|
SpUtils.login(activity, loginEty.getToken());
|
|
|
try {
|
|
try {
|
|
|
MyDbManager.getInstance().saveOrUpdateUser(loginEty.getUser());
|
|
MyDbManager.getInstance().saveOrUpdateUser(loginEty.getUser());
|
|
|
UserEntity userEntity = MyDbManager.getInstance().dbFindUser();
|
|
UserEntity userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
- Log.e("------userEntity", userEntity.getNickname() + "|" + userEntity.getMobile() + "");
|
|
|
|
|
- G.showToast(userEntity.getNickname() + "|" + userEntity.getMobile());
|
|
|
|
|
|
|
+ Log.e("------userEntity",userEntity.getNickname()+"|"+userEntity.getMobile()+"");
|
|
|
|
|
+ showToast(userEntity.getNickname()+"|"+userEntity.getMobile());
|
|
|
} catch (DbException e) {
|
|
} catch (DbException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -312,7 +283,7 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
// Log.e("解密2--", XXTEA.bytes2HexStr(XXTEA.Encrypt(e1, XXTEA.KEY).getBytes("utf-8")));
|
|
// Log.e("解密2--", XXTEA.bytes2HexStr(XXTEA.Encrypt(e1, XXTEA.KEY).getBytes("utf-8")));
|
|
|
// Log.e("解密3--", XXTEA.Decrypt(s1, XXTEA.KEY));
|
|
// Log.e("解密3--", XXTEA.Decrypt(s1, XXTEA.KEY));
|
|
|
// Log.e("解密4--", XXTEA.Decrypt(s2, XXTEA.KEY));
|
|
// Log.e("解密4--", XXTEA.Decrypt(s2, XXTEA.KEY));
|
|
|
- } catch (Exception e) {
|
|
|
|
|
|
|
+ }catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|