自定义进度条在进度开始时挂起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();
}
}
}
};