An AsyncTask is executed on click:
List list = new Vector();
private OnClickListener click = new OnClickL
You can store reference to AsyncTask
in member variable. So your code would look like this:
List list = new Vector();
DownloadFilesTask downloadTask = null;
private OnClickListener click = new OnClickListener() {
public void onClick(View view) {
list.clear();
if((dft.getStatus().toString()).equals("RUNNING")) dft.cancel(true);
currentCategory = catigoriesHolder.indexOfChild(view);
if(downloadTask == null){
downloadTask = new DownloadFilesTask();
downloadTask.execute(rssFeedURL[currentCategory]);
} else {
//show warning here
}
}
}
Of course, you'll need to set downloadTask
to null
in onPostExecute()
for this to work.
As an added benefit you now can cancel outstanding task if Activity is being destroyed:
@Override
onDestroy() {
if(downloadTask != null) {
downloadTask.cancel();
}
}
Which you should do anyway.