use of com.example.verificationcodejavademo.model.Point 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();
}
});
}
use of com.example.verificationcodejavademo.model.Point in project captcha by anji-plus.
the class WordImageView method onTouchEvent.
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
size--;
Point point = new Point();
point.setX(DisplayUtil.px2dip(getContext(), event.getX()));
point.setY(DisplayUtil.px2dip(getContext(), event.getY()));
mList.add(point);
if (size > 0) {
// 添加小圆点
addTextView(event);
} else if (size == 0) {
addTextView(event);
if (wordListenner != null) {
wordListenner.onWord(new Gson().toJson(mList));
}
}
}
return true;
}
Aggregations