[Android] Don't crash if there are no subdirectories or they are inaccessible

Edward Wang git at videolan.org
Tue Jun 19 23:24:34 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Tue Jun 19 17:23:38 2012 -0400| [c0437e6db8c2c747d4e058a0bb93c149d6ea4551] | committer: Edward Wang

Don't crash if there are no subdirectories or they are inaccessible

Close #6979

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=c0437e6db8c2c747d4e058a0bb93c149d6ea4551
---

 vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
index b482555..218309f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
@@ -90,6 +90,12 @@ public class BrowserActivity extends ListActivity {
         mAdapter.clear();
         mCurrentDir = file;
         File[] files = file.listFiles(new DirFilter());
+        /* If no sub-directories or I/O error don't crash */
+        if(files == null || files.length < 1) {
+            Util.toaster(this, R.string.nosubdirectory);
+            this.finish();
+            return;
+        }
         for (int i = 0; i < files.length; i++) {
             mAdapter.add(files[i]);
         }



More information about the Android mailing list