首页 > 代码库 > xUtils - android工具库,大量更新:bug修复,缓存优化,GET请求加入lru缓存。

xUtils - android工具库,大量更新:bug修复,缓存优化,GET请求加入lru缓存。

感谢大家最近一段时间对xUtils的关注,和给我bug反馈,这也使我在xUtils的开发上更有热情。

昨天晚上熬夜到5点多,完成了缓存模块的整理和结构优化,今天在此基础上有完成了给http模块添加GET请求文本内容时实现LRU缓存的工作,现在可设置缓存默认过期时间和针对当前请求的过期时间。

最新的源码从这里获取:https://github.com/wyouflf/xUtils
标签: xUtils afinal

[1].[代码] GET请求缓存使用示例: 跳至 [1]

?
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
privatevoid testGet() {
        RequestParams params = newRequestParams();
        params.addQueryStringParameter("method","info");
        params.addQueryStringParameter("access_token",
                "3.1042851f652496c9362b1cd77d4f849b.2592000.1377530363.3590808424-248414");
 
        HttpUtils http = newHttpUtils();
        http.configCurrRequestExpiry(1000* 10);
        http.send(HttpRequest.HttpMethod.GET,
                "https://pcs.baidu.com/rest/2.0/pcs/quota",
                params,
                newRequestCallBack<String>() {
 
                    @Override
                    publicvoid onStart() {
                        testTextView.setText("conn...");
                    }
 
                    @Override
                    publicvoid onLoading(longtotal, longcurrent) {
                        testTextView.setText(current + "/"+ total);
                    }
 
                    @Override
                    publicvoid onSuccess(String result) {
                        testTextView.setText("response:"+ result);
                    }
 
 
                    @Override
                    publicvoid onFailure(Throwable error, String msg) {
                        testTextView.setText(msg);
                    }
                });
    }

xUtils - android工具库,大量更新:bug修复,缓存优化,GET请求加入lru缓存。