Search in sources :

Example 1 with CaptchaGetIt

use of com.example.verificationcodejavademo.model.CaptchaGetIt in project captcha by anji-plus.

the class BlockPuzzleDialog method loadCaptcha.

private void loadCaptcha() {
    Map<String, Object> params = new HashMap<>();
    params.put("captchaType", "blockPuzzle");
    JSONObject jsonObject = new JSONObject(params);
    RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
    RetrofitUtils.getServerApi().getAsync(body).compose(RxHelper.observableIO2Main(mContext)).subscribe(new BaseObserver<CaptchaGetIt>(mContext, true) {

        @Override
        public void onSuccess(CaptchaGetIt data) {
            baseImageBase64 = data.getOriginalImageBase64();
            slideImageBase64 = data.getJigsawImageBase64();
            token = data.getToken();
            key = data.getSecretKey();
            dragView.setUp(ImageUtil.base64ToBitmap(baseImageBase64), ImageUtil.base64ToBitmap(slideImageBase64));
            dragView.setSBUnMove(true);
            initEvent();
        }

        @Override
        public void onFailure(Throwable e, String errorMsg) {
            dragView.setSBUnMove(false);
            Toast.makeText(mContext, errorMsg, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : CaptchaGetIt(com.example.verificationcodejavademo.model.CaptchaGetIt) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONObject(org.json.JSONObject) RequestBody(okhttp3.RequestBody)

Aggregations

CaptchaGetIt (com.example.verificationcodejavademo.model.CaptchaGetIt)1 HashMap (java.util.HashMap)1 RequestBody (okhttp3.RequestBody)1 JSONObject (org.json.JSONObject)1