ankidroid/Anki-Android — pull request #57 by hssm (2013-06-06 15:34:34+00:00)
Title: Select correct deck after delete in fragmented mode.

Deleting a deck in fragmented mode will simply remove the fragment if the deck that was removed was the currently selected deck. This leaves us with an empty fragment, and a crash also happens if you tap the back button (I didn't bother finding out why).

This change solves two issues:
1 - If the currently selected deck is deleted, we ensure we don't leave an empty fragment after we are done deleting it. The next active deck is selected (libanki ensures there is always a selected deck internally). This also seems to fix the crash.

2 - If the deck we deleted was a sub-deck of the currently selected deck, the new fragment we end up loading will have updated counts, which are likely to have changed if we delete a subdeck.