package com.highdatas.madeasy.patient.callback; import android.util.Log; import cn.wildfire.chat.kit.net.base.RawResultCallBack; import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; import cn.wildfire.chat.kit.utils.PrefUtils; import com.highdatas.madeasy.patient.util.UIUtils; import java.util.Date; /** * @author kimi * @description * @date 2020-12-31 16:16 */ public class OCRTokenCallBack extends RawResultCallBack { private static final String TAG = "OCRTokenCallBack"; @Override public void onUiSuccess(JSONObject jsonObject) { try { String access_token = jsonObject.getString("access_token"); long expires_in = jsonObject.getInteger("expires_in"); Date now = new Date(); long overdueTime = now.getTime() + expires_in; PrefUtils.setLong(UIUtils.getContext(), "OCROverdueTime", overdueTime); PrefUtils.setString(UIUtils.getContext(), "OCRToken", access_token); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onUiFailure(int code, String message) { Log.e(TAG, "onFailure: message" + message); } }