ankidroid/Anki-Android — pull request #543 by timrae (2014-10-15 06:13:49+00:00)
Title: Fix showing of dialog fragments from async tasks

This is a fairly big change which is made to fix some crashes which are occurring from showing `DialogFragment`s in the `onPostExecute()` methods of `AsyncTask`s. For example see [this crash report](http://ankidroid-triage.appspot.com/view_crash?crash_id=5051538837864448).

I have fixed the crashes in a futureproof way, by providing a new class `AsyncDialogFragment` which inherits from `DialogFragment`, and provides some additional machinery which allows us to show a message in the notification bar if the `Activity` which the `AsyncTask` was launched from has been stopped. I have also set it up so that in general we correctly show the `AsyncDialogFragment` once the `Activity` has been resumed again, unless this is not needed.

There is also a convenience method `showSimpleMessageDialog`, which can be used to show a message to the user in an `AsyncTask`-safe way.