每个RecyclerView项目中的Android自定义进度条会降低UI的速度

时间:2017-09-13 08:04:49

标签: android listview android-recyclerview android-progressbar

每个recyclerview项目中的

自定义进度条在进度开始时挂起UI如何在不挂起或停止或放慢UI的情况下平滑进度?

我使用intentservice下载媒体和广播接收器来更新UI。

private BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        int percentDownloaded = intent.getIntExtra(CacheDownloadService.BROADCAST_PAYLOAD_DOWNLOAD_PERCENT, -1);
        String downloadingUrl = intent.getStringExtra(CacheDownloadService.BROADCAST_PAYLOAD_DOWNLOAD_URI);


        if (getListView() != null) {
            if (getListView().getAdapter() != null && getListView().getAdapter() instanceof ListAdapter) {
                ListAdapter listAdapter = (ListAdapter) getListView().getAdapter();
                listAdapter.updateTrackDownloadProgress(downloadingUrl, percentDownloaded);
                listAdapter.notifyDataSetChanged();
            }
        }
    }
};

enter image description here

0 个答案:

没有答案