[Android] Hide clear option when streams history is empty

Geoffrey Métais git at videolan.org
Thu Mar 12 17:38:53 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 12 17:38:18 2015 +0100| [fd22c7ad75039ad3d150cbd1262a6a01ee3fc7be] | committer: Geoffrey Métais

Hide clear option when streams history is empty

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

 vlc-android/src/org/videolan/vlc/gui/MRLPanelFragment.java |    6 ++++++
 vlc-android/src/org/videolan/vlc/gui/MainActivity.java     |    3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MRLPanelFragment.java b/vlc-android/src/org/videolan/vlc/gui/MRLPanelFragment.java
index dba607f..1336142 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MRLPanelFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MRLPanelFragment.java
@@ -96,6 +96,7 @@ public class MRLPanelFragment extends Fragment implements View.OnKeyListener, Te
             Util.openStream(getActivity(), mEditText.getText().toString().trim());
             MediaDatabase.getInstance().addMrlhistoryItem(mEditText.getText().toString().trim());
             updateHistory();
+            getActivity().supportInvalidateOptionsMenu();
             mEditText.getText().clear();
             return true;
         }
@@ -105,6 +106,7 @@ public class MRLPanelFragment extends Fragment implements View.OnKeyListener, Te
     public void clearHistory(){
         MediaDatabase.getInstance().clearMrlHistory();
         updateHistory();
+        getActivity().supportInvalidateOptionsMenu();
     }
 
     @Override
@@ -120,4 +122,8 @@ public class MRLPanelFragment extends Fragment implements View.OnKeyListener, Te
         main.setMenuFocusDown(idIsEmpty, R.id.mrl_list);
         main.setSearchAsFocusDown(idIsEmpty, parent, R.id.mrl_list);
     }
+
+    public boolean isEmpty(){
+        return mAdapter.isEmpty();
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 3035358..0c94470 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -579,7 +579,8 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
         }
         else
             menu.findItem(R.id.ml_menu_save).setVisible(false);
-        menu.findItem(R.id.ml_menu_clean).setVisible(SidebarEntry.ID_MRL.equals(mCurrentFragment));
+        if (current instanceof MRLPanelFragment)
+            menu.findItem(R.id.ml_menu_clean).setVisible(!((MRLPanelFragment) current).isEmpty());
         menu.findItem(R.id.ml_menu_last_playlist).setVisible(SidebarEntry.ID_AUDIO.equals(mCurrentFragment));
 
 



More information about the Android mailing list