[Android] Don't crash if updateList is received before view is loaded
Edward Wang
git at videolan.org
Sat Jun 23 16:58:30 CEST 2012
android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Jun 23 10:58:21 2012 -0400| [991ffc03eae1d170a2547aa5e0a39c5899dab618] | committer: Edward Wang
Don't crash if updateList is received before view is loaded
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=991ffc03eae1d170a2547aa5e0a39c5899dab618
---
.../src/org/videolan/vlc/gui/audio/AudioListFragment.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
index 9dc92e2..59a5d6b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
@@ -270,7 +270,13 @@ public class AudioListFragment extends SherlockListFragment {
mSongsAdapter.add(media);
}
mSongsAdapter.setCurrentIndex(currentIndex);
- getListView().setSelection(currentIndex);
+ try {
+ getListView().setSelection(currentIndex);
+ } catch(IllegalStateException e) {
+ /* Happens if updateList() message is received before onCreateView()
+ * finishes. Nothing we can do here...
+ */
+ }
mSongsAdapter.notifyDataSetChanged();
}
More information about the Android
mailing list