Я получаю исключение нулевого указателя при отмене диалогового окна хода выполнения в асинхронной задаче ... это мой код.остановите задачу, если пользователь нажал кнопку «Назад».
@Override
protected void onPreExecute() {
showDialog(DIALOG_PROGRESS);
Calendar calendar = null;
switch (day) {
case SAT:
calendar = DateUtil.getSaturdayDate();
break;
case SUN:
calendar = DateUtil.getSundayDate();
break;
case MON:
calendar = DateUtil.getMondayDate();
break;
case TUE:
calendar = DateUtil.getTuesdayDate();
break;
case WED:
calendar = DateUtil.getWednesdayDate();
break;
case THU:
calendar = DateUtil.getThursdayDate();
break;
case FRI:
calendar = DateUtil.getFridayDate();
break;
default:
break;
}
if(calendar != null) {
generatedLink = WeeklyScheduleBean.generatePath( DateUtil.getDay(calendar),
DateUtil.getMonth(calendar),
DateUtil.getYear(calendar) );
} else {
// get the schedule of today
Calendar current_day = DateUtil.getCurrentTime();
generatedLink = WeeklyScheduleBean.generatePath( DateUtil.getDay(current_day),
DateUtil.getMonth(current_day),
DateUtil.getYear(current_day) );
}
}
@Override
protected Boolean doInBackground(Void... params) {
feedParser = new WeeklyScheduleParser(generatedLink);
list = new ArrayList<WeeklyScheduleBean>();
try {
list = feedParser.parse();
} catch (Exception e) {
e.printStackTrace();
return false;
}
if(list.size() > 0)
return true;
else
return false;
}
@Override
protected void onPostExecute(Boolean result) {
if(progressDialog.isShowing()){
if(result) {
weeklyScheduleScreen.removeDialog(DIALOG_PROGRESS);
adapter = new WeeklyAdapter(cxt, R.layout.time_text_list, R.id.title_text, list);
lv.setAdapter(adapter);
}
else {
DialogUtil.CreateDialog("", "Could not retreive the feeds",false,WeeklyScheduleScreen.this);
weeklyScheduleScreen.removeDialog(DIALOG_PROGRESS);
}
}
}
}