android conatcts搜索时偶现列表刷不出来

本文详细解析了Java中加载目录分区的关键函数实现,包括强制加载与延迟加载的逻辑处理,以及如何根据不同目录ID选择合适的加载策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<pre name="code" class="java">关键函数:
511    private void startLoadingDirectoryPartition(int partitionIndex) {
512        DirectoryPartition partition = (DirectoryPartition)mAdapter.getPartition(partitionIndex);
513        partition.setStatus(DirectoryPartition.STATUS_LOADING);
514        long directoryId = partition.getDirectoryId();
515        if (mForceLoad) {
              //一直调用if语句,没有调用else,应该调用else就可以利用<pre name="code" class="java">                延时读取队列来修复
516            if (directoryId == Directory.DEFAULT) {
517                loadDirectoryPartition(partitionIndex, partition);
518            } else {
519                loadDirectoryPartitionDelayed(partitionIndex, partition);
520            }
521        } else {
522            Bundle args = new Bundle();
523            args.putLong(DIRECTORY_ID_ARG_KEY, directoryId);
524            getLoaderManager().initLoader(partitionIndex, args, this);
525        }
526    }


逻辑调用:
private static final int DIRECTORY_SEARCH_MESSAGE = 1;   private void loadDirectoryPartitionDelayed(int partitionIndex, DirectoryPartition partition) { mDelayedDirectorySearchHandler.removeMessages(DIRECTORY_SEARCH_MESSAGE, partition); Message msg = mDelayedDirectorySearchHandler.obtainMessage( DIRECTORY_SEARCH_MESSAGE, partitionIndex, 0, partition); mDelayedDirectorySearchHandler.sendMessageDelayed(msg, DIRECTORY_SEARCH_DELAY_MILLIS); }    private Handler mDelayedDirectorySearchHandler = new Handler() {        @Override        public void handleMessage(Message msg) {            if (msg.what == DIRECTORY_SEARCH_MESSAGE) {                loadDirectoryPartition(msg.arg1, (DirectoryPartition) msg.obj);            }        }    };





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值