|
@@ -23,13 +23,11 @@ import com.sheep.gamegroup.util.ActivityManager;
|
|
|
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.gamegroup.util.XXTEA;
|
|
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.Config;
|
|
|
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.base.BaseActivity;
|
|
|
-import com.sheep.jiuyan.samllsheep.page.LoginActivity;
|
|
|
|
|
-import com.sheep.jiuyan.samllsheep.page.MainActivity;
|
|
|
|
|
-import com.sheep.jiuyan.samllsheep.page.SplashActivity;
|
|
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
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 com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
@@ -59,12 +57,15 @@ 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() {
|
|
@@ -74,15 +75,16 @@ 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
|
|
TitleBarUtils
|
|
|
.getInstance()
|
|
.getInstance()
|
|
|
- .setTitle(this,"手机号登录")
|
|
|
|
|
|
|
+ .setTitle(this, "手机号登录")
|
|
|
.setTitleFinish(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();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -111,7 +113,13 @@ 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
|
|
@@ -135,14 +143,14 @@ 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();
|
|
|
- // TODO: 2018/3/22 测试界面,过后删除
|
|
|
|
|
-// SpUtils.login(getApplicationContext(), "12@1c421522bb7e44d3cd6a8d59a54df182");
|
|
|
|
|
-// startActivity(new Intent(this, ActMain.class));
|
|
|
|
|
-// Jump2View.getInstance().goHomePageView(this, null);
|
|
|
|
|
-// finish();
|
|
|
|
|
|
|
+
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -158,6 +166,7 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
}
|
|
}
|
|
|
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));
|
|
G.showToast(getString(R.string.input_your_captcha));
|
|
@@ -173,12 +182,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();
|
|
@@ -186,14 +195,15 @@ 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;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -210,19 +220,19 @@ 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()+"");
|
|
|
|
|
|
|
+ Log.e("------data", baseMessage.getData() + "");
|
|
|
LoginEntity loginEty = JSONObject.parseObject(JSONObject.toJSONString(baseMessage.getData()), LoginEntity.class);
|
|
LoginEntity loginEty = JSONObject.parseObject(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() + "");
|
|
|
|
|
+ G.showToast(userEntity.getNickname() + "|" + userEntity.getMobile());
|
|
|
} catch (DbException e) {
|
|
} catch (DbException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -241,12 +251,15 @@ public class PhoneAct extends BaseActivity implements PhoneContract.View {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void goMain() {
|
|
private void goMain() {
|
|
|
- Intent intent = new Intent(activity, PersonalCenterPresenter.class);
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
|
|
+ // TODO: 2018/3/22 测试界面,过后删除
|
|
|
|
|
+ SpUtils.login(getApplicationContext(), "12@1c421522bb7e44d3cd6a8d59a54df182");
|
|
|
|
|
+// startActivity(new Intent(this, ActMain.class));
|
|
|
|
|
+ Jump2View.getInstance().goHomePageView(this, null);
|
|
|
|
|
+ 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" +
|
|
@@ -276,14 +289,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() + "");
|
|
|
|
|
+ G.showToast(userEntity.getNickname() + "|" + userEntity.getMobile());
|
|
|
} catch (DbException e) {
|
|
} catch (DbException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -298,7 +311,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();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|