android - CursorLoader and setUpdateThrottle
2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
推荐:深入源码解析Android中Loader、AsyncTaskLoader、CursorLoader、LoaderManager
如果对Loader、AsyncTaskLoader、CursorLoader、LoaderManager等概念不明白或不知道如何使用Loader机制,可参见博文Android中Loader及LoaderManager的使用(附源
I'm building an application that leverages a CursorLoader, CursorTreeAdapter and LoaderManager to display information backed by a ContentProvider / SQLite database.
I'm inserting new rows in to the database in rapid succession (around every ~500 milliseconds) and would like to throttle the refresh of the list so it does't jump all over the place when I insert data.
Looking through the documentation there's a function on AsyncTaskLoader (which CursorLoader inherits from) - setUpdateThrottle
public void setUpdateThrottle (long delayMS)
Added in API level 11 Set amount to throttle updates by. This is the minimum time from when the last loadInBackground() call has completed until a new load is scheduled.
Parameters delayMS Amount of delay, in milliseconds.
推荐:Android Loader(三) 结合CursorLoader分析Loader相关源码
Android Loader(二) CursorLoader Android Loader(四) 自定义Loader从网络中获取文本数据 首先从加载数据的过程开始分析。 初始化Loader的方法是:getLoaderMana
Unfortunately, setting this to something like 5000 milliseconds doesn't seem to slow the reloads of the CursorTreeAdapter.
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
...
CursorLoader cl = new CursorLoader(getActivity(),
NotesContract.Notes.CONTENT_URI,
projection,
selection,
selectionArgs,
null);
// setUpdateThrottle Doesn't seem to change anything
cl.setUpdateThrottle(5000);
return cl;
}
Any ideas on how to use this throttle function?
If this isn't the right way to use it, do you have any ideas on the best way to batch redraws using CursorLoader, CursorTreeAdapter and LoaderManager?
android sqlite android-cursor android-cursorloader android-loadermanager|
this question asked May 29 '15 at 22:55 Michael 310 2 9
|
Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.
原文: http://www.jb51.net/article/37767.htm http://write.blog.csdn.net/posteditref=toolbar android CursorLoader用法介绍 工作内容集中到Contact模块
原文: http://www.jb51.net/article/37767.htm http://write.blog.csdn.net/posteditref=toolbar android CursorLoader用法介绍 工作内容集中到Contact模块
相关阅读排行
- 1Android Https相关完全解析 当OkHttp遇到Https
- 2Android APK反编译详解(附图)
- 3[置顶] Android APK反编译就这么简单 详解(附图)
- 4Android Fragment 真正的完全解析(上)
- 5Android RecyclerView 使用完全解析 体验艺术般的控件