albrechtjan / workload-android

The Android App for the TU Dresden Physik Workload Website
https://survey.zqa.tu-dresden.de
GNU Affero General Public License v3.0
0 stars 0 forks source link

Do not call updateMembers() on adapter when Activity is paused #24

Open KonstantinSchubert opened 8 years ago

KonstantinSchubert commented 8 years ago

At the moment, we register a content observer in the MyBaseAdapter which calls updateMembers() every time the SurveyContentProvider reports a change. This also happens when the activity belonging to the adapter is paused. This is extremely wasteful, especially since we are doing this on the UI thread.

Instead, we should unregister the content observer when the activity pauses (onPause()). It might be a good idea to move the content observer to the base activity and pass it to the MyBaseAdapter in the adapters constructor.

When the activity resumes, (onResume()) we should register the observer again and then call updateMembers() (in a separate thread if possible).

The only disadvantage of this approach is that a flicker might be observable when the UI updates after the updateMembers() method completes.

But with the current implementation, we expect UI freezes 10x the duration of the flicker duration every time the database changes.