[Android] Network browser: prevent StackOverflowError

Geoffrey Métais git at videolan.org
Fri Mar 30 16:51:18 CEST 2018


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

Network browser: prevent StackOverflowError

(cherry picked from commit 0df40ab01e50b6706f40258624874c8fd908a34b)

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

 .../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