|
|
@@ -6,6 +6,7 @@ import android.text.TextUtils;
|
|
|
import android.text.method.HideReturnsTransformationMethod;
|
|
|
import android.text.method.PasswordTransformationMethod;
|
|
|
import android.view.View;
|
|
|
+import android.widget.CheckBox;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
|
|
|
|
@@ -16,6 +17,7 @@ import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.module.login.controller.LoginController;
|
|
|
import com.sheep.gamegroup.util.ChannelContent;
|
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
|
+import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.PreferenceUtils;
|
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.gamegroup.util.UMConfigUtils;
|
|
|
@@ -43,6 +45,14 @@ public class SignUpFgt extends BaseFragment {
|
|
|
EditText passwordBox;
|
|
|
@BindView(R.id.show_hide_pwd_btn)
|
|
|
ImageView showHidePwdBtn;
|
|
|
+ @BindView(R.id.password_box2)
|
|
|
+ EditText passwordBox2;
|
|
|
+ @BindView(R.id.show_hide_pwd_btn2)
|
|
|
+ ImageView showHidePwdBtn2;
|
|
|
+
|
|
|
+ //用户协议
|
|
|
+ @BindView(R.id.tel_agreement_cb)
|
|
|
+ CheckBox tel_agreement_cb;
|
|
|
|
|
|
public SignUpFgt() {
|
|
|
// Required empty public constructor
|
|
|
@@ -77,9 +87,23 @@ public class SignUpFgt extends BaseFragment {
|
|
|
}
|
|
|
passwordBox.setSelection(passwordBox.getText().toString().length());
|
|
|
}
|
|
|
+ @OnClick(R.id.show_hide_pwd_btn2)
|
|
|
+ public void doShowHidePwd2(View v) {
|
|
|
+ showHidePwdBtn2.setSelected(!showHidePwdBtn2.isSelected());
|
|
|
+ showHidePwdBtn2.setImageResource(showHidePwdBtn2.isSelected() ? R.mipmap.pwd_show : R.mipmap.pwd_hide);
|
|
|
+ if (showHidePwdBtn2.isSelected()) {
|
|
|
+ //如果选中,显示密码
|
|
|
+ passwordBox2.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
|
|
|
+ } else {
|
|
|
+ //否则隐藏密码
|
|
|
+ passwordBox2.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
|
|
+ }
|
|
|
+ passwordBox2.setSelection(passwordBox2.getText().toString().length());
|
|
|
+ }
|
|
|
|
|
|
@OnClick(R.id.register_btn)
|
|
|
public void doRegister(View v) {
|
|
|
+ if(checkAgreement()) return;
|
|
|
if (!validate()) return;
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("user_name", userNameBox.getText().toString().trim());
|
|
|
@@ -109,7 +133,7 @@ public class SignUpFgt extends BaseFragment {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (loginEty != null) {
|
|
|
- SpUtils.saveToken(getActivity(), loginEty.getToken());
|
|
|
+ SpUtils.saveToken(SheepApp.getInstance(), loginEty.getToken());
|
|
|
DataUtil.getInstance().initUserEntity(loginEty.getUser());
|
|
|
mController.whenLoginSuccess(LoginController.PLATFORM_ACCOUNT, loginEty);
|
|
|
}
|
|
|
@@ -120,6 +144,7 @@ public class SignUpFgt extends BaseFragment {
|
|
|
private boolean validate() {
|
|
|
String username = userNameBox.getText().toString().trim();
|
|
|
String password = passwordBox.getText().toString().trim();
|
|
|
+ String password2 = passwordBox2.getText().toString().trim();
|
|
|
if (TextUtils.isEmpty(username)) {
|
|
|
G.shortToast("请输入用户名");
|
|
|
return false;
|
|
|
@@ -128,6 +153,10 @@ public class SignUpFgt extends BaseFragment {
|
|
|
G.shortToast("请输入密码");
|
|
|
return false;
|
|
|
}
|
|
|
+ if (TextUtils.isEmpty(password2)) {
|
|
|
+ G.shortToast("请确认密码");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
if (!StringUtils.isUserName(username)) {
|
|
|
G.shortToast("用户名只能包含英文、数字、._-@符号,长度4-20");
|
|
|
return false;
|
|
|
@@ -136,7 +165,24 @@ public class SignUpFgt extends BaseFragment {
|
|
|
G.shortToast("密码只能包含英文、数字、_.-@$!*%符号,长度6-16");
|
|
|
return false;
|
|
|
}
|
|
|
+ if (!TextUtils.equals(password, password2)) {
|
|
|
+ G.shortToast("两次输入的密码不相同");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @OnClick(R.id.tel_agreement_tv)
|
|
|
+ public void showAgreement(View v) {
|
|
|
+ Jump2View.getInstance().tryShowAgreement(SheepApp.getInstance().getCurrentActivity(), G::showToast);
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查是否同意用户协议
|
|
|
+ protected boolean checkAgreement() {
|
|
|
+ if(tel_agreement_cb.isChecked()){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ G.showToast("温馨提示:您必须同意用户协议才能继续体验小绵羊APP!");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|