[Android] Option menu: do not display the sorting item if the current fragment cannot be sorted
Adrien Maglo
git at videolan.org
Fri Dec 6 16:16:25 CET 2013
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Dec 6 16:16:13 2013 +0100| [fb62aed11d7d4e16bb0e4a27da9196a4fcd5ce32] | committer: Adrien Maglo
Option menu: do not display the sorting item if the current fragment cannot be sorted
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=fb62aed11d7d4e16bb0e4a27da9196a4fcd5ce32
---
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index efc51b4..28868e8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -473,6 +473,17 @@ public class MainActivity extends SherlockFragmentActivity {
}
@Override
+ public boolean onPrepareOptionsMenu (Menu menu) {
+ Fragment current = getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder);
+ // Disable the sort option if we can't use it on the current fragment.
+ if (current == null || !(current instanceof ISortable)) {
+ menu.findItem(R.id.ml_menu_sortby).setEnabled(false);
+ menu.findItem(R.id.ml_menu_sortby).setVisible(false);
+ }
+ return true;
+ }
+
+ @Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
changeMenuOffset();
More information about the Android
mailing list