ITKeyword,专注技术干货聚合推荐

注册 | 登录

android - CursorLoader and setUpdateThrottle

itPublisher 分享于

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.

推荐:android CursorLoader用法介绍

原文:  http://www.jb51.net/article/37767.htm http://write.blog.csdn.net/posteditref=toolbar android CursorLoader用法介绍 工作内容集中到Contact模块


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。