[Android] Network browser: prevent StackOverflowError

Geoffrey Métais git at videolan.org
Thu Mar 22 11:44:50 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 22 10:26:00 2018 +0100| [0df40ab01e50b6706f40258624874c8fd908a34b] | committer: Geoffrey Métais

Network browser: prevent StackOverflowError

> https://code.videolan.org/videolan/vlc-android/commit/0df40ab01e50b6706f40258624874c8fd908a34b
---

 .../videolan/vlc/gui/browser/NetworkBrowserFragment.java | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
index 8532dd1cf..2de029bb8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -132,22 +132,16 @@ public class NetworkBrowserFragment extends BaseBrowserFragment implements Exter
 
     protected boolean handleContextItemSelected(MenuItem item, final int position) {
         int id = item.getItemId();
-        if (! (mAdapter.getItem(position) instanceof MediaWrapper))
-            return super.onContextItemSelected(item);
+        if (!(mAdapter.getItem(position) instanceof MediaWrapper)) return false;
         final MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
-        MediaDatabase db;
         switch (id){
             case R.id.network_add_favorite:
-                db = MediaDatabase.getInstance();
-                db.addNetworkFavItem(mw.getUri(), mw.getTitle(), mw.getArtworkURL());
-                if (isRootDirectory())
-                    updateFavorites();
+                MediaDatabase.getInstance().addNetworkFavItem(mw.getUri(), mw.getTitle(), mw.getArtworkURL());
+                if (isRootDirectory()) updateFavorites();
                 return true;
             case R.id.network_remove_favorite:
-                db = MediaDatabase.getInstance();
-                db.deleteNetworkFav(mw.getUri());
-                if (isRootDirectory())
-                    updateFavorites();
+                MediaDatabase.getInstance().deleteNetworkFav(mw.getUri());
+                if (isRootDirectory()) updateFavorites();
                 return true;
             case R.id.network_edit_favorite:
                 showAddServerDialog(mw);



More information about the Android mailing list