我遇到了一个没有出现的进度对话框的问题,我不知道我的代码有什么问题。
我有一个EventBus的监听器,可以打开,更新或关闭进度对话框。我可以看到使用android调试器调用createDialog()
,updateProgress()
和closeDialog()
,但进度对话框不会显示。
请帮忙
private void createDialog(){
progressDialog = new ProgressDialog(this);
//progressDialog.vis
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setCancelable(false);
progressDialog.setMessage(getString(R.string.pager_wait_record));
progressDialog.show();
}
private void updateProgress(int total, int count){
progressDialog.setMax(total);
progressDialog.setProgress(count);
}
private void closeDialog(){
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageProgress(EBProgress event) {
Log.d(">>>>>>>", "progress");
switch (event.option){
case SHOW_DIALOG:
Log.d(">>>>>>>", "show dialog");
createDialog();
break;
case CLOSE_DIALOG:
Log.d(">>>>>>>", "close dialog");
closeDialog();
break;
case UPDATE_PROGRESS_DIALOG:
Log.d(">>>>>>>", "update dialog");
updateProgress(event.total, event.count);
break;
default:
break;
}
}