The problem is that you're creating new ProgressDialogs, over and over again, and losing the reference to the old ones.
Since I'm not seeing pDialog
declared anywhere within your AsyncTask
, I'm guessing its external. On the other hand, you are obviously creating multiple AsyncTasks to deal with multiple images. This means that you are running multiple times the code:
pDialog = new ProgressDialog(mContext);
Each time, losing the older ProgressDialog.
Suggested solution:
Add a counter, along with the pDialog:
private static ProgressDialog pDialog;
private static int pDialogCounter = 0;
Then change onPreExecute()
to:
protected void onPreExecute(){
super.onPreExecute();
if(pDialog == null) {
pDialog = new ProgressDialog(mContext);
pDialog.setMessage("Loading Playlist...");
pDialog.show();
}
++pDialogCounter;
}
and change onPostExecute()
to:
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
...
if(--pDialogCounter == 0) {
pDialog.dismiss();
pDialog = null;
}
}
This way, you will be creating the dialog only if it didn't exist, and dismissing it only if you have no more AsyncTasks running.