[Android] Fix close warning not shown in browsers
Geoffrey Métais
git at videolan.org
Fri Jan 12 10:59:19 CET 2018
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jan 12 10:43:44 2018 +0100| [c5ef488c36e6b5032cf954d421e08a1fc21d9869] | committer: Geoffrey Métais
Fix close warning not shown in browsers
(cherry picked from commit 18739166e0285a92de8f4e363d6932d03a22da3f)
> https://code.videolan.org/videolan/vlc-android/commit/c5ef488c36e6b5032cf954d421e08a1fc21d9869
---
.../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java | 9 ++++-----
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 3 +--
.../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 9 ++++-----
3 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index 9c71f95c5..d4ef84dc5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -199,11 +199,10 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
switch (item.getItemId()) {
case android.R.id.home:
// Current fragment loaded
- Fragment current = getCurrentFragment();
- if (current instanceof StorageBrowserFragment)
- ((StorageBrowserFragment) current).goBack();
- else
- finish();
+ final Fragment current = getCurrentFragment();
+ if (current instanceof StorageBrowserFragment && ((StorageBrowserFragment) current).goBack())
+ return true;
+ finish();
return true;
default:
return super.onOptionsItemSelected(item);
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 5d85a52e0..07bbea76a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -347,8 +347,7 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
// If it's the directory view, a "backpressed" action shows a parent.
final Fragment fragment = getCurrentFragment();
- if (fragment instanceof BaseBrowserFragment){
- ((BaseBrowserFragment)fragment).goBack();
+ if (fragment instanceof BaseBrowserFragment && ((BaseBrowserFragment)fragment).goBack()){
return;
} else if (fragment instanceof ExtensionBrowser) {
((ExtensionBrowser) fragment).goBack();
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 537ce8e78..9ec7c26b7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -276,15 +276,14 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
return mCurrentMedia != null ? mrl : null;
}
- public void goBack(){
+ public boolean goBack(){
final FragmentActivity activity = getActivity();
- if (activity == null)
- return;
+ if (activity == null) return false;
if (!mRoot) {
if (!activity.getSupportFragmentManager().popBackStackImmediate() && activity instanceof MainActivity)
((MainActivity)activity).showFragment(this instanceof NetworkBrowserFragment ? R.id.nav_network : R.id.nav_directories);
- } else
- activity.finish();
+ }
+ return !mRoot;
}
public void browse(MediaWrapper media, int position, boolean save) {
More information about the Android
mailing list