[Android] Browse back with arrow

Geoffrey Métais git at videolan.org
Tue May 12 14:40:52 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 12 14:31:27 2015 +0200| [4212b0208381516927e25f83ac041ac11208e371] | committer: Geoffrey Métais

Browse back with arrow

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=4212b0208381516927e25f83ac041ac11208e371
---

 .../videolan/vlc/gui/AudioPlayerContainerActivity.java    |    5 +++--
 .../src/org/videolan/vlc/gui/SecondaryActivity.java       |   13 +++++++++++--
 .../org/videolan/vlc/gui/browser/BaseBrowserFragment.java |    9 +++++----
 .../org/videolan/vlc/gui/browser/FileBrowserFragment.java |    2 --
 4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index 1f4f6f2..e68f635 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -51,6 +51,7 @@ public class AudioPlayerContainerActivity extends AppCompatActivity {
     public static final String ACTION_SHOW_PLAYER = "org.videolan.vlc.gui.ShowPlayer";
 
     protected ActionBar mActionBar;
+    protected Toolbar mToolbar;
     protected AudioPlayer mAudioPlayer;
     protected AudioServiceController mAudioController;
     protected SlidingPaneLayout mSlidingPane;
@@ -71,8 +72,8 @@ public class AudioPlayerContainerActivity extends AppCompatActivity {
 
         mRootContainer = (ViewGroup) ((ViewGroup) this
                 .findViewById(android.R.id.content)).getChildAt(0);
-        Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
-        setSupportActionBar(toolbar);
+        mToolbar = (Toolbar) findViewById(R.id.main_toolbar);
+        setSupportActionBar(mToolbar);
         mActionBar = getSupportActionBar();
 
         mSlidingPane = (SlidingPaneLayout) findViewById(R.id.pane);
diff --git a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
index 2edc6d5..094b260 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
@@ -27,6 +27,7 @@ import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.View;
 
 import org.videolan.vlc.MediaLibrary;
 import org.videolan.vlc.MediaWrapper;
@@ -43,7 +44,7 @@ import org.videolan.vlc.interfaces.ISortable;
 import java.util.ArrayList;
 
 public class SecondaryActivity extends AudioPlayerContainerActivity {
-    public final static String TAG = "VLC/EqualizerFragment";
+    public final static String TAG = "VLC/SecondaryActivity";
 
     public static final String ALBUMS_SONGS = "albumsSongs";
     public static final String ALBUM = "album";
@@ -62,6 +63,14 @@ public class SecondaryActivity extends AudioPlayerContainerActivity {
 
         initAudioPlayerContainerActivity();
         mActionBar.setDisplayHomeAsUpEnabled(true);
+        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Fragment current = getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder);
+                if (current instanceof StorageBrowserFragment)
+                    ((StorageBrowserFragment) current).goBack();
+            }
+        });
 
         if (getSupportFragmentManager().getFragments() == null) {
             String fragmentId = getIntent().getStringExtra("fragment");
@@ -85,7 +94,7 @@ public class SecondaryActivity extends AudioPlayerContainerActivity {
     @Override
     protected void onPause() {
         if (isFinishing())
-            overridePendingTransition(0,0);
+            overridePendingTransition(0, 0);
         super.onPause();
     }
 
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 26e7ff8..02b4051 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -57,7 +57,6 @@ import org.videolan.vlc.gui.CommonDialogs;
 import org.videolan.vlc.gui.DividerItemDecoration;
 import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.gui.SidebarAdapter;
-import org.videolan.vlc.gui.audio.MediaComparators;
 import org.videolan.vlc.gui.video.VideoPlayerActivity;
 import org.videolan.vlc.interfaces.IRefreshable;
 import org.videolan.vlc.util.Util;
@@ -70,7 +69,6 @@ import org.videolan.vlc.widget.SwipeRefreshLayout;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 
 
 public abstract class BaseBrowserFragment extends MediaBrowserFragment implements IRefreshable, MediaBrowser.EventListener, SwipeRefreshLayout.OnRefreshListener {
@@ -91,7 +89,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
     public String mMrl;
     protected MediaWrapper mCurrentMedia;
     protected int mSavedPosition = -1, mFavorites = 0;
-    protected boolean mRoot;
+    public boolean mRoot;
     protected LibVLC mLibVLC;
 
     private SparseArray<ArrayList<MediaWrapper>> mMediaLists = new SparseArray<ArrayList<MediaWrapper>>();
@@ -181,7 +179,10 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
     }
 
     public void goBack(){
-        getActivity().getSupportFragmentManager().popBackStack();
+        if (!mRoot)
+            getActivity().getSupportFragmentManager().popBackStack();
+        else
+            getActivity().finish();
     }
 
     public void browse (MediaWrapper media, int position){
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
index f519a16..06ea047 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
@@ -29,7 +29,6 @@ import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Bundle;
-import android.os.Environment;
 import android.support.v4.app.Fragment;
 import android.support.v7.app.AlertDialog;
 import android.support.v7.widget.AppCompatEditText;
@@ -46,7 +45,6 @@ import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.R;
 import org.videolan.vlc.util.AndroidDevices;
 import org.videolan.vlc.util.CustomDirectories;
-import org.videolan.vlc.util.Strings;
 
 import java.io.File;
 



More information about the Android mailing list