thecosmicfrog / LuasataGlance

Android Wear and mobile app providing real-time tram stop information for Dublin's Luas light rail service.
https://play.google.com/store/apps/details?id=org.thecosmicfrog.luasataglance
GNU General Public License v3.0
21 stars 5 forks source link

App occasionally crashes when screen is rotated many times in a short space of time #6

Closed thecosmicfrog closed 9 years ago

thecosmicfrog commented 9 years ago

When Luas at a Glance is open and the handheld device is rotated several times in a short space of time (causing the Activity to redraw many times), the app occasionally crashes.

thecosmicfrog commented 9 years ago

This is related to the use of Fragments and is due to the LuasTimesFragment not yet being added to the MainActivity, causing the UI manipulation code in onPostExecute() and setIsLoading() to throw IllegalStateException.

Below is a StackOverflow link outlining the same problem: http://stackoverflow.com/questions/25908626/illegalstateexception-fragment-not-attached-to-activity-when-finish-asynctask

The solution is to add a simple check using if (isAdded()) {} around any UI manipulation code in the Fragment.

thecosmicfrog commented 9 years ago

Fixed in a310859f8f13c9d22552d7da21e392bb5a67ed69 and 0a484e56fe1999b6a6349fcc9019827cae27266b. Closing.