use of com.example.verificationcodejavademo.model.CaptchaCheckIt in project captcha by anji-plus.
the class WordCaptchaDialog method checkCaptcha.
private void checkCaptcha(String cryptedStr) {
Map<String, Object> params = new HashMap<>();
params.put("captchaType", "clickWord");
params.put("token", token);
params.put("pointJson", AESUtil.encode(cryptedStr, key));
JSONObject jsonObject = new JSONObject(params);
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
Log.i("wuyan", "body:" + jsonObject);
RetrofitUtils.getServerApi().checkAsync(body).compose(RxHelper.observableIO2Main(mContext)).subscribe(new BaseObserver<CaptchaCheckIt>(mContext, false) {
@Override
public void onSuccess(CaptchaCheckIt data) {
bottomTitle.setText("验证成功");
bottomTitle.setTextColor(Color.GREEN);
wordView.ok();
handler.postDelayed(new Runnable() {
@Override
public void run() {
loadCaptcha();
dismiss();
}
}, 1000);
if (mOnResultsListener != null) {
String result = token + "---" + cryptedStr;
mOnResultsListener.onResultsClick(AESUtil.encode(result, key));
}
}
@Override
public void onFailure(Throwable e, String errorMsg) {
bottomTitle.setText("验证失败");
bottomTitle.setTextColor(Color.RED);
wordView.fail();
handler.postDelayed(new Runnable() {
@Override
public void run() {
// 刷新验证码
loadCaptcha();
}
}, 1000);
}
});
}
use of com.example.verificationcodejavademo.model.CaptchaCheckIt in project captcha by anji-plus.
the class BlockPuzzleDialog method checkCaptcha.
private void checkCaptcha(double sliderXMoved) {
Point point = new Point();
point.setY(5.0);
point.setX(sliderXMoved);
String pointStr = new Gson().toJson(point);
Map<String, Object> params = new HashMap<>();
params.put("captchaType", "blockPuzzle");
params.put("token", token);
params.put("pointJson", AESUtil.encode(pointStr, key));
JSONObject jsonObject = new JSONObject(params);
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
RetrofitUtils.getServerApi().checkAsync(body).compose(RxHelper.observableIO2Main(mContext)).subscribe(new BaseObserver<CaptchaCheckIt>(mContext, false) {
@Override
public void onSuccess(CaptchaCheckIt data) {
dragView.ok();
loadCaptcha();
handler.postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
}
}, 1500);
if (mOnResultsListener != null) {
String result = token + "---" + pointStr;
mOnResultsListener.onResultsClick(AESUtil.encode(result, key));
}
}
@Override
public void onFailure(Throwable e, String errorMsg) {
dragView.fail();
// 刷新验证码
loadCaptcha();
}
});
}
Aggregations