use of com.example.verificationcodejavademo.model.WordCaptchaGetIt in project captcha by anji-plus.
the class WordCaptchaDialog method loadCaptcha.
private void loadCaptcha() {
bottomTitle.setText("数据加载中......");
bottomTitle.setTextColor(Color.BLACK);
Map<String, Object> params = new HashMap<>();
params.put("captchaType", "clickWord");
JSONObject jsonObject = new JSONObject(params);
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
Log.i("wuyan", "body:" + jsonObject);
RetrofitUtils.getServerApi().getWordCaptchaAsync(body).compose(RxHelper.observableIO2Main(mContext)).subscribe(new BaseObserver<WordCaptchaGetIt>(mContext, true) {
@Override
public void onSuccess(WordCaptchaGetIt data) {
baseImageBase64 = data.getOriginalImageBase64();
token = data.getToken();
key = data.getSecretKey();
String wordStr = "";
int j = 0;
for (int i = 0; i < data.getWordList().size(); i++) {
j++;
wordStr += data.getWordList().get(i);
if (j < data.getWordList().size()) {
wordStr += ",";
}
}
wordView.setSize(data.getWordList().size());
bottomTitle.setText("请依此点击【" + wordStr + "】");
bottomTitle.setTextColor(Color.BLACK);
wordView.setUp(ImageUtil.base64ToBitmap(baseImageBase64));
initEvent();
}
@Override
public void onFailure(Throwable e, String errorMsg) {
bottomTitle.setText("加载失败,请刷新");
bottomTitle.setTextColor(Color.RED);
wordView.setSize(-1);
Toast.makeText(mContext, errorMsg, Toast.LENGTH_SHORT).show();
}
});
}
Aggregations