正在查看: 自健身 v3.3.4 应用的 RegistActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 RegistActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
import butterknife.OnClick;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.CodeBean;
import com.mu.gymtrain.Bean.RegisterBean;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.FinalTools;
import com.mu.gymtrain.Utils.MessageUtils;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.StringUtil;
import com.mu.gymtrain.Utils.UrlConfig;
import com.tencent.open.SocialConstants;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
public class RegistActivity extends BaseActivity {
@BindView(R.id.bt_login)
Button btLogin;
@BindView(R.id.et_phone)
EditText etPhone;
@BindView(R.id.et_vercode)
EditText etVercode;
@BindView(R.id.llAgreement)
LinearLayout llAgreement;
@BindView(R.id.title_left)
ImageView titleLeft;
@BindView(R.id.tv_forget_vercode)
TextView tvForgetVercode;
private boolean result = true;
private int time = 60;
private boolean b = true;
public int getContentLayout() {
return R.layout.activity_regist;
}
public void initData() {
}
public void initView() {
}
@OnClick({R.id.tv_forget_vercode, R.id.bt_login, R.id.title_left, R.id.tvXY, R.id.tvLogin})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.bt_login:
showProgress();
if (StringUtil.phoneEnable(this.etPhone.getText().toString())) {
if (this.etVercode.getText().toString().length() == 6) {
if (!((CheckBox) findViewById(2131296406)).isChecked()) {
doudong(this.llAgreement);
showToast("请您阅读用户隐私协议并勾选");
dismissProgress();
break;
} else {
regist(new Subscriber<RegisterBean>() {
public void onCompleted() {
}
public void onError(Throwable e) {
RegistActivity.this.dismissProgress();
}
public void onNext(RegisterBean registerBean) {
RegistActivity.this.dismissProgress();
MessageUtils.alertLongMessageCENTER("注册成功");
PreferenceUtils.getInstance().saveString(FinalTools.TOKEN, registerBean.getApp_token());
RegistActivity.this.startActivity(new Intent(RegistActivity.this.mActivity, (Class<?>) HomeActivity.class));
RegistActivity.this.finish();
}
});
break;
}
} else {
dismissProgress();
MessageUtils.alertMessageCENTER("请输入正确的验证码");
break;
}
}
break;
case R.id.title_left:
finish();
break;
case R.id.tvLogin:
startActivity(new Intent((Context) this, (Class<?>) LoginActivity.class));
finish();
break;
case R.id.tvXY:
Intent intent = new Intent((Context) this, (Class<?>) WebViewActivity.class);
intent.putExtra(SocialConstants.PARAM_URL, UrlConfig.XY_URL);
intent.putExtra(FinalTools.INTENT_COMMON, getString(R.string.title_user_protocol));
startActivity(intent);
break;
case R.id.tv_forget_vercode:
if (this.etPhone.getText().toString().length() == 11) {
if (this.b) {
this.b = false;
showTime();
getCode(new Subscriber<CodeBean>() {
public void onCompleted() {
}
public void onError(Throwable e) {
MessageUtils.alertMessageCENTER(e.getMessage());
}
public void onNext(CodeBean codeBean) {
MessageUtils.alertMessageCENTER("验证码发送成功");
}
});
break;
}
} else {
MessageUtils.alertMessageCENTER("请输入正确的手机号");
break;
}
break;
}
}
public void doudong(View view) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "translationX", 0.0f, 60.0f, -60.0f, 0.0f);
ofFloat.setDuration(100L);
ofFloat.setRepeatCount(3);
ofFloat.start();
}
private void showTime() {
new Thread(new Runnable() {
@Override
public final void run() {
RegistActivity.this.lambda$showTime$0$RegistActivity();
}
}).start();
}
public void lambda$showTime$0$RegistActivity() {
while (this.result) {
this.time--;
try {
Thread.sleep(1000L);
this.tvForgetVercode.post(new Runnable() {
@Override
public void run() {
RegistActivity.this.tvForgetVercode.setText(RegistActivity.this.time + "s后重新获取");
RegistActivity.this.tvForgetVercode.setClickable(false);
RegistActivity.this.tvForgetVercode.setBackground(ContextCompat.getDrawable(RegistActivity.this, R.drawable.round_forget_vercode_gray));
}
});
if (this.time <= 1) {
this.result = false;
this.tvForgetVercode.post(new Runnable() {
@Override
public void run() {
RegistActivity.this.tvForgetVercode.setText("获取验证码");
RegistActivity.this.tvForgetVercode.setClickable(true);
RegistActivity.this.tvForgetVercode.setBackground(ContextCompat.getDrawable(RegistActivity.this, R.drawable.round_forget_vercode));
RegistActivity.this.b = true;
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
this.result = true;
this.time = 60;
}
private void getCode(Subscriber<CodeBean> subscriber) {
HttpHelper.getInstance().getRetrofitService(this, UrlConfig.Path.BASE_URL).code2regist(this.etPhone.getText().toString()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(subscriber);
}
private void regist(Subscriber<RegisterBean> subscriber) {
HttpHelper.getInstance().getRetrofitService(this, UrlConfig.Path.BASE_URL).register(this.etPhone.getText().toString(), this.etVercode.getText().toString(), "123").observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).map(new ResponseFunc()).subscribe(subscriber);
}
}