IOS
hefeixia
2021-02-18 49f3c1374873f73dbde2983ca0fcf1fb10bfedbf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
    }
}