[Android] Go back at browser root level on ND entry click
Geoffrey Métais
git at videolan.org
Wed Apr 27 15:21:44 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Apr 27 15:06:48 2016 +0200| [2fcd64a2c2ed297a8e66339370d970b77737f977] | committer: Geoffrey Métais
Go back at browser root level on ND entry click
> https://code.videolan.org/videolan/vlc-android/commit/2fcd64a2c2ed297a8e66339370d970b77737f977
---
.../src/org/videolan/vlc/gui/MainActivity.java | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 0a058aa..d6cc05b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -294,7 +294,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
//Deactivated for now
// createExtensionServiceConnection();
- cleatBackstackFromExtension();
+ clearBackstackFromClass(ExtensionBrowser.class);
}
@Override
@@ -862,13 +862,21 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
if (mExtensionServiceConnection != null)
mExtensionManagerService.disconnect();
- if(current == null || (item != null && mCurrentFragmentId == id)) { /* Already selected */
- if (mFocusedPrior != 0)
- requestFocusOnSearch();
+ if (current == null) {
mDrawerLayout.closeDrawer(mNavigationView);
return false;
}
+ if(mCurrentFragmentId == id) { /* Already selected */
+ // Go back at root level of current browser
+ if (current instanceof BaseBrowserFragment && !((BaseBrowserFragment) current).isRootDirectory()) {
+ clearBackstackFromClass(current.getClass());
+ } else {
+ mDrawerLayout.closeDrawer(mNavigationView);
+ return false;
+ }
+ }
+
String tag = getTag(id);
switch (id){
case R.id.nav_about:
@@ -908,11 +916,11 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
return true;
}
- private void cleatBackstackFromExtension() {
+ private void clearBackstackFromClass(Class clazz) {
FragmentManager fm = getSupportFragmentManager();
Fragment current = getSupportFragmentManager()
.findFragmentById(R.id.fragment_placeholder);
- while (current instanceof ExtensionBrowser) {
+ while (clazz.isInstance(current)) {
fm.popBackStackImmediate();
current = getSupportFragmentManager()
.findFragmentById(R.id.fragment_placeholder);
More information about the Android
mailing list