|
@@ -1,6 +1,8 @@
|
|
|
package com.sheep.gamegroup.module.login.fragments;
|
|
package com.sheep.gamegroup.module.login.fragments;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import android.graphics.Bitmap;
|
|
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.design.widget.Snackbar;
|
|
import android.support.design.widget.Snackbar;
|
|
@@ -10,6 +12,7 @@ import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.text.method.HideReturnsTransformationMethod;
|
|
import android.text.method.HideReturnsTransformationMethod;
|
|
|
import android.text.method.PasswordTransformationMethod;
|
|
import android.text.method.PasswordTransformationMethod;
|
|
|
|
|
+import android.util.Base64;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
@@ -76,6 +79,14 @@ public class SignInFgt extends AbsLoginFgt {
|
|
|
ImageView accountMenuBtn;
|
|
ImageView accountMenuBtn;
|
|
|
@BindView(R.id.show_hide_pwd_btn)
|
|
@BindView(R.id.show_hide_pwd_btn)
|
|
|
ImageView showHidePwdBtn;
|
|
ImageView showHidePwdBtn;
|
|
|
|
|
+ @BindView(R.id.verify_box)
|
|
|
|
|
+ TextView verifyBox;
|
|
|
|
|
+ @BindView(R.id.captcha_code_view)
|
|
|
|
|
+ ImageView verifyImageView;
|
|
|
|
|
+ @BindView(R.id.captcha_seperator)
|
|
|
|
|
+ View verifySeperator;
|
|
|
|
|
+
|
|
|
|
|
+ private String captchaId;
|
|
|
|
|
|
|
|
public SignInFgt() {
|
|
public SignInFgt() {
|
|
|
// Required empty public constructor
|
|
// Required empty public constructor
|
|
@@ -155,6 +166,10 @@ public class SignInFgt extends AbsLoginFgt {
|
|
|
jsonObject.put("user_name", userNameBox.getText().toString().trim());
|
|
jsonObject.put("user_name", userNameBox.getText().toString().trim());
|
|
|
jsonObject.put("password", passwordBox.getText().toString().trim());
|
|
jsonObject.put("password", passwordBox.getText().toString().trim());
|
|
|
jsonObject.put("invitation_code", ChannelContent.getInstance().getChannel_name());
|
|
jsonObject.put("invitation_code", ChannelContent.getInstance().getChannel_name());
|
|
|
|
|
+ if (!TextUtils.isEmpty(captchaId)) {
|
|
|
|
|
+ jsonObject.put("captcha_id", captchaId);
|
|
|
|
|
+ jsonObject.put("captcha_code", verifyBox.getText().toString().trim());
|
|
|
|
|
+ }
|
|
|
PreferenceUtils.setPrefString(SheepApp.getInstance(), UMConfigUtils.LOGIN_TYPE, UMConfigUtils.Source.SHEEP);
|
|
PreferenceUtils.setPrefString(SheepApp.getInstance(), UMConfigUtils.LOGIN_TYPE, UMConfigUtils.Source.SHEEP);
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().loginByUserName(jsonObject)
|
|
SheepApp.getInstance().getNetComponent().getApiService().loginByUserName(jsonObject)
|
|
|
.subscribeOn(Schedulers.io())
|
|
.subscribeOn(Schedulers.io())
|
|
@@ -164,6 +179,9 @@ public class SignInFgt extends AbsLoginFgt {
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
hideProgress();
|
|
hideProgress();
|
|
|
G.shortToast(baseMessage);
|
|
G.shortToast(baseMessage);
|
|
|
|
|
+ if (baseMessage.getCode() == 400000004 || baseMessage.getCode() == 400000005) {
|
|
|
|
|
+ getCaptchaImage();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -190,6 +208,35 @@ public class SignInFgt extends AbsLoginFgt {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @OnClick(R.id.captcha_code_view)
|
|
|
|
|
+ public void getCaptchaImage() {
|
|
|
|
|
+ verifyBox.setVisibility(View.VISIBLE);
|
|
|
|
|
+ verifyImageView.setVisibility(View.VISIBLE);
|
|
|
|
|
+ verifySeperator.setVisibility(View.VISIBLE);
|
|
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getImgCaptcha()
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ JSONObject json = JSONObject.parseObject(baseMessage.getData().toString());
|
|
|
|
|
+ captchaId = json.getString("captcha_id");
|
|
|
|
|
+ String blob = json.getString("captcha_blob");
|
|
|
|
|
+ blob = blob.substring(22);
|
|
|
|
|
+ byte[] decodedString = Base64.decode(blob, Base64.DEFAULT);
|
|
|
|
|
+ Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
|
|
|
|
|
+ verifyImageView.setImageBitmap(decodedByte);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ G.shortToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private boolean validatePhoneCaptcha() {
|
|
private boolean validatePhoneCaptcha() {
|
|
|
String etCode = captchaBox.getText().toString().trim();
|
|
String etCode = captchaBox.getText().toString().trim();
|
|
|
if (TextUtils.isEmpty(etCode)) {
|
|
if (TextUtils.isEmpty(etCode)) {
|