Search in sources :

Example 6 with Callback

use of com.okhttplib.callback.Callback in project OkHttp3 by MrZhousf.

the class MainActivity method forceNetwork.

/**
     * 仅网络请求
     */
private void forceNetwork() {
    OkHttpUtil.Builder().setCacheType(CacheType.FORCE_NETWORK).build(this).doGetAsync(HttpInfo.Builder().setUrl(url).build(), new Callback() {

        @Override
        public void onSuccess(HttpInfo info) throws IOException {
            String result = info.getRetDetail();
            resultTV.setText("FORCE_NETWORK:" + result);
            setFromCacheTV(info);
        }

        @Override
        public void onFailure(HttpInfo info) throws IOException {
            resultTV.setText("FORCE_NETWORK:" + info.getRetDetail());
        }
    });
    needDeleteCache(true);
}
Also used : HttpInfo(com.okhttplib.HttpInfo) Callback(com.okhttplib.callback.Callback) IOException(java.io.IOException)

Aggregations

HttpInfo (com.okhttplib.HttpInfo)6 Callback (com.okhttplib.callback.Callback)6 IOException (java.io.IOException)6 Gson (com.google.gson.Gson)1 TimeAndDate (com.okhttp3.bean.TimeAndDate)1