[Android] Do not handle Expandable ListView, we don't use it

Geoffrey Métais git at videolan.org
Fri May 15 16:59:24 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May 15 16:51:17 2015 +0200| [026161470879885b0f9af7f12c709eaa5081a40f] | committer: Geoffrey Métais

Do not handle Expandable ListView, we don't use it

This fixes context popup menu in AudioAlbumsSongsFragment

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

 .../vlc/gui/audio/AudioAlbumsSongsFragment.java    |   23 ++++---------
 .../vlc/gui/audio/AudioBrowserFragment.java        |   34 ++++++++------------
 2 files changed, 19 insertions(+), 38 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 367f7a4..418790f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -219,30 +219,19 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
     }
 
     private boolean handleContextItemSelected(MenuItem item, int position) {
-        ContextMenuInfo menuInfo = item.getMenuInfo();
-        if (menuInfo == null)
-            return false;
 
         int startPosition;
-        int groupPosition;
         List<MediaWrapper> medias;
         int id = item.getItemId();
 
         boolean useAllItems = id == R.id.audio_list_browser_play_all;
         boolean append = id == R.id.audio_list_browser_append;
 
-        if (menuInfo instanceof ExpandableListContextMenuInfo) {
-            ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
-            groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
-        }
-        else
-            groupPosition = position;
-
         if (id == R.id.audio_list_browser_delete) {
             AlertDialog alertDialog = CommonDialogs.deleteMedia(
                     getActivity(),
-                    mSongsAdapter.getMedias(groupPosition).get(0).getLocation(),
-                    new VLCRunnable(mSongsAdapter.getItem(groupPosition)) {
+                    mSongsAdapter.getMedias(position).get(0).getLocation(),
+                    new VLCRunnable(mSongsAdapter.getItem(position)) {
                         @Override
                         public void run(Object o) {
                             AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
@@ -258,23 +247,23 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
         }
 
         if (id == R.id.audio_list_browser_set_song) {
-            AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
+            AudioUtil.setRingtone(mSongsAdapter.getItem(position).mMediaList.get(0), getActivity());
             return true;
         }
 
         if (useAllItems) {
             medias = new ArrayList<MediaWrapper>();
-            startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
+            startPosition = mSongsAdapter.getListWithPosition(medias, position);
         }
         else {
             startPosition = 0;
             switch (mViewPager.getCurrentItem())
             {
                 case MODE_ALBUM: // albums
-                    medias = mAlbumsAdapter.getMedias(groupPosition);
+                    medias = mAlbumsAdapter.getMedias(position);
                     break;
                 case MODE_SONG: // songs
-                    medias = mSongsAdapter.getMedias(groupPosition);
+                    medias = mSongsAdapter.getMedias(position);
                     break;
                 default:
                     return true;
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 22a4313..18a73da 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -407,10 +407,8 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
     }
 
     private boolean handleContextItemSelected(MenuItem item, int position) {
-        ContextMenuInfo menuInfo = item.getMenuInfo();
 
         int startPosition;
-        int groupPosition;
         int mode = mViewPager.getCurrentItem();
         List<MediaWrapper> medias;
         int id = item.getItemId();
@@ -418,12 +416,6 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
         boolean useAllItems = id == R.id.audio_list_browser_play_all;
         boolean append = id == R.id.audio_list_browser_append;
 
-        if (menuInfo instanceof ExpandableListContextMenuInfo) {
-            ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
-            groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
-        } else
-            groupPosition = position;
-
         if (id == R.id.audio_list_browser_delete) {
             AudioBrowserListAdapter adapter;
             if (mode == MODE_SONG){
@@ -432,13 +424,13 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
                 adapter = mPlaylistAdapter;
             } else
                 return false;
-            List<MediaWrapper> mediaList = adapter.getMedias(groupPosition);
-            if (adapter.getCount() <= groupPosition || mediaList == null || mediaList.isEmpty())
+            List<MediaWrapper> mediaList = adapter.getMedias(position);
+            if (adapter.getCount() <= position || mediaList == null || mediaList.isEmpty())
                 return false;
             AlertDialog alertDialog = CommonDialogs.deletePlaylist(
                     getActivity(),
-                    adapter.getItem(groupPosition).mTitle,
-                    new VLCRunnable(adapter.getItem(groupPosition)) {
+                    adapter.getItem(position).mTitle,
+                    new VLCRunnable(adapter.getItem(position)) {
                         @Override
                         public void run(Object o) {
                             AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
@@ -458,17 +450,17 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
         }
 
         if (id == R.id.audio_list_browser_set_song) {
-            if (mSongsAdapter.getCount() <= groupPosition)
+            if (mSongsAdapter.getCount() <= position)
                 return false;
-            AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
+            AudioUtil.setRingtone(mSongsAdapter.getItem(position).mMediaList.get(0), getActivity());
             return true;
         }
 
         if (useAllItems) {
-            if (mSongsAdapter.getCount() <= groupPosition)
+            if (mSongsAdapter.getCount() <= position)
                 return false;
             medias = new ArrayList<MediaWrapper>();
-            startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
+            startPosition = mSongsAdapter.getListWithPosition(medias, position);
         } else {
             startPosition = 0;
             AudioBrowserListAdapter adapter = null;
@@ -486,11 +478,11 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
                     adapter = mGenresAdapter;
                     break;
                 case MODE_PLAYLIST: //For file playlist, we browse tracks with mediabrowser, and add them in callbacks onMediaAdded and onBrowseEnd
-                    medias = mPlaylistAdapter.getMedias(groupPosition);
-                    if (medias.size() == 1 && mPlaylistAdapter.getMedias(groupPosition).get(0).getType() == MediaWrapper.TYPE_PLAYLIST) {
+                    medias = mPlaylistAdapter.getMedias(position);
+                    if (medias.size() == 1 && mPlaylistAdapter.getMedias(position).get(0).getType() == MediaWrapper.TYPE_PLAYLIST) {
                         if (mMediaBrowser == null)
                             mMediaBrowser = new MediaBrowser(VLCInstance.get(), this);
-                        mMediaBrowser.browse(mPlaylistAdapter.getMedias(groupPosition).get(0).getLocation());
+                        mMediaBrowser.browse(mPlaylistAdapter.getMedias(position).get(0).getLocation());
                         return true;
                     } else
                         adapter = mPlaylistAdapter;
@@ -498,9 +490,9 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
                 default:
                     return false;
             }
-            if (groupPosition >= adapter.getCount())
+            if (position >= adapter.getCount())
                 return false;
-            medias = adapter.getMedias(groupPosition);
+            medias = adapter.getMedias(position);
         }
 
         if (append)



More information about the Android mailing list