[Android] Fix backstack navigation

Geoffrey Métais git at videolan.org
Mon Dec 5 17:37:20 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec  5 17:36:59 2016 +0100| [e1d347e0948f81c798cee9256d70dac4b6cc1241] | committer: Geoffrey Métais

Fix backstack navigation

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

 .../videolan/vlc/gui/browser/BaseBrowserFragment.java  |  4 ++--
 .../vlc/gui/browser/NetworkBrowserFragment.java        | 18 ++++++------------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index fd21839..721b50e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -252,7 +252,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
         next.setArguments(args);
         ft.replace(R.id.fragment_placeholder, next, media.getLocation());
         if (save)
-            ft.addToBackStack(mMrl);
+            ft.addToBackStack(media.getLocation());
         ft.commit();
     }
 
@@ -571,7 +571,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
         mCurrentParsedPosition = 0;
         MediaLibraryItem item;
         MediaWrapper mw;
-        while (mCurrentParsedPosition <mAdapter.getItemCount()){
+        while (mCurrentParsedPosition < mAdapter.getItemCount()) {
             item = mAdapter.getItem(mCurrentParsedPosition);
             if (item.getItemType() == MediaLibraryItem.TYPE_STORAGE) {
                 mw = new MediaWrapper(((Storage) item).getUri());
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 e3df9ba..106b8dc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -33,10 +33,8 @@ import android.os.Bundle;
 import android.support.design.widget.FloatingActionButton;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
-import android.view.LayoutInflater;
 import android.view.MenuItem;
 import android.view.View;
-import android.view.ViewGroup;
 
 import org.videolan.medialibrary.media.DummyItem;
 import org.videolan.medialibrary.media.MediaWrapper;
@@ -64,13 +62,6 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
         if (mMrl == null)
             mMrl = ROOT;
         mRoot = ROOT.equals(mMrl);
-        skipRefresh = !mAdapter.isEmpty();
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        View v = super.onCreateView(inflater, container, savedInstanceState);
-        return v;
     }
 
     public void onStart(){
@@ -78,7 +69,10 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
 
         //Handle network connection state
         IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
+        mSkipRefresh = !mAdapter.isEmpty();
         getActivity().registerReceiver(networkReceiver, filter);
+        if (mSkipRefresh)
+            parseSubDirectories();
         if (mRoot) {
             mFAB = (FloatingActionButton) getActivity().findViewById(R.id.fab);
             mFAB.setImageResource(R.drawable.ic_fab_add);
@@ -263,7 +257,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
         dialog.show(fm, "fragment_add_server");
     }
 
-    private boolean skipRefresh = false;
+    private boolean mSkipRefresh = false;
     private final BroadcastReceiver networkReceiver = new BroadcastReceiver() {
         boolean connected = true;
         @Override
@@ -280,8 +274,8 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
                             return; //block consecutive calls when disconnected
                     } else
                         connected = true;
-                    if (skipRefresh)
-                        skipRefresh = false;
+                    if (mSkipRefresh)
+                        mSkipRefresh = false;
                     else
                         refresh();
                 }



More information about the Android mailing list