111111111111转化为十进制_快速椭圆曲线素数证明算法

111111111111转化为十进制_快速椭圆曲线素数证明算法publicclassAppextendsApplication{privatestaticAppapp;privateDaoMasterdaoMaster;privateDaoSessiondaoSession;@Ov

111111111111转化为十进制_快速椭圆曲线素数证明算法"


public class App extends Application{

    private static App app;
    private DaoMaster daoMaster;
    private DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        app = App.this;
        Fresco.initialize(this);
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "users", null);
        SQLiteDatabase db = helper.getWritableDatabase();
        daoMaster = new DaoMaster(db);
        daoSession = daoMaster.newSession();
    }
    public static App getInstance(){
        if (null == app){
            synchronized (App.class){
                if (null == app){
                    app = new App();
                }
            }
        }
        return app;
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}

 

 

 


public class OKHttpUtils {
    public static OKHttpUtils instance;
    public OkHttpClient okHttpClient;

    public OKHttpUtils(){
        if (null == instance){
            synchronized (OkHttpClient.class){
                if (null == instance){
                    okHttpClient = new OkHttpClient.Builder()
                            .addInterceptor(new LoggingInterceptor())
                            .build();
                }
            }
        }
    }

    public static OKHttpUtils getInstance() {
        if (null == instance){
            synchronized (OKHttpUtils.class){
                if (null == instance){
                    instance = new OKHttpUtils();
                }
            }
        }
        return instance;
    }

    public void get(String urlString, Callback callback){
        Request request = new Request.Builder().url(urlString).build();
        okHttpClient.newCall(request).enqueue(callback);
    }
    public void post(String urlString, FormBody formBody,Callback callback){
        Request request = new Request.Builder().url(urlString).method("POST",formBody).build();
        okHttpClient.newCall(request).enqueue(callback);
    }

    class LoggingInterceptor implements Interceptor {

        @Override
        public Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            String method = request.method();
            Log.d("LoggingInterceptor", method);
            Response response = chain.proceed(request);
            return response;
        }
    }
}

 

 


public class IModelImpl implements ICorter.IModel {
    private static final String URL = "https://gank.io/api/data/%E7%A6%8F%E5%88%A9/10/1";
    @Override
    public void requestMsg(final onCallBack onCallBack) {
        final UserDao userDao = App.getInstance().getDaoSession().getUserDao();
        List<User> users = userDao.loadAll();
        if (users.size() > 0 ){
            onCallBack.requestData(users);
            return;
        }
        OKHttpUtils.getInstance().get(URL, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                onCallBack.requestData(null);
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String responseMsg = response.body().string();
                Gson gson = new Gson();
                UserBean userBean = gson.fromJson(responseMsg, UserBean.class);
                List<UserBean.ResultsBean> results = userBean.getResults();
                List<User> userList = new ArrayList<>();
                for (int i = 0; i < results.size() ; i++) {
                    String desc = results.get(i).getDesc();
                    String url = results.get(i).getUrl();
                    User user = new User();
                    user.setImgUrl(url);
                    user.setTitle(desc);
                    userList.add(user);
                }
                onCallBack.requestData(userList);
                userDao.insertInTx(userList);
            }
        });
    }
}

今天的文章111111111111转化为十进制_快速椭圆曲线素数证明算法分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/72038.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注