Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Casanowow Life for love
VLC-Android
Commits
b67c57d4
Commit
b67c57d4
authored
Jun 23, 2012
by
Ludovic Fauvet
Browse files
Rework the context menu handling in the audio fragments
parent
13158a8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
vlc-android/res/menu/audio_list_browser.xml
0 → 100644
View file @
b67c57d4
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:id=
"@+id/audio_list_browser_play"
android:title=
"@string/play"
/>
<item
android:id=
"@+id/audio_list_browser_append"
android:title=
"@string/append"
/>
<group
android:id=
"@+id/songs_view_only"
>
<item
android:id=
"@+id/audio_list_browser_play_all"
android:title=
"@string/play_all"
/>
<item
android:id=
"@+id/audio_list_browser_append_all"
android:title=
"@string/append_all"
/>
<item
android:id=
"@+id/audio_list_browser_delete"
android:title=
"@string/delete"
/>
</group>
</menu>
\ No newline at end of file
vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
View file @
b67c57d4
...
...
@@ -47,11 +47,10 @@ import android.support.v4.app.FragmentTransaction;
import
android.view.ContextMenu
;
import
android.view.ContextMenu.ContextMenuInfo
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.Menu
Inflater
;
import
android.view.MenuItem
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View.OnCreateContextMenuListener
;
import
android.view.View.OnTouchListener
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
...
...
@@ -92,12 +91,6 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
public
final
static
int
MODE_SONG
=
2
;
public
final
static
int
MODE_GENRE
=
3
;
public
final
static
int
MENU_PLAY
=
Menu
.
FIRST
;
public
final
static
int
MENU_APPEND
=
Menu
.
FIRST
+
1
;
public
final
static
int
MENU_PLAY_ALL
=
Menu
.
FIRST
+
2
;
public
final
static
int
MENU_APPEND_ALL
=
Menu
.
FIRST
+
3
;
public
final
static
int
MENU_DELETE
=
Menu
.
FIRST
+
4
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -149,10 +142,10 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
albumList
.
setOnChildClickListener
(
playlistChildListener
);
genreList
.
setOnChildClickListener
(
playlistChildListener
);
songsList
.
setOnCreateContextMenuListener
(
contextMenuListener
);
artistList
.
setOnCreateContextMenuListener
(
contextMenuListener
);
albumList
.
setOnCreateContextMenuListener
(
contextMenuListener
);
gen
re
L
ist
.
setOnCreateContextMenuListener
(
contextMenuListener
);
registerForContextMenu
(
songsList
);
registerForContextMenu
(
artistList
);
registerForContextMenu
(
albumList
);
re
g
ist
erForContextMenu
(
genreList
);
return
v
;
}
...
...
@@ -225,20 +218,6 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
}
};
OnCreateContextMenuListener
contextMenuListener
=
new
OnCreateContextMenuListener
()
{
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenuInfo
menuInfo
)
{
menu
.
add
(
Menu
.
NONE
,
MENU_PLAY
,
Menu
.
NONE
,
R
.
string
.
play
);
menu
.
add
(
Menu
.
NONE
,
MENU_APPEND
,
Menu
.
NONE
,
R
.
string
.
append
);
if
(
v
.
getId
()
==
R
.
id
.
songs_list
)
{
menu
.
add
(
Menu
.
NONE
,
MENU_PLAY_ALL
,
Menu
.
NONE
,
R
.
string
.
play_all
);
menu
.
add
(
Menu
.
NONE
,
MENU_APPEND_ALL
,
Menu
.
NONE
,
R
.
string
.
append_all
);
menu
.
add
(
Menu
.
NONE
,
MENU_DELETE
,
Menu
.
NONE
,
R
.
string
.
delete
);
}
}
};
public
void
deleteMedia
(
final
List
<
String
>
addressMedia
,
final
Media
aMedia
)
{
AlertDialog
alertDialog
=
new
AlertDialog
.
Builder
(
getActivity
())
.
setTitle
(
R
.
string
.
confirm_delete
)
...
...
@@ -265,6 +244,15 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
alertDialog
.
show
();
}
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenuInfo
menuInfo
)
{
MenuInflater
inflater
=
getActivity
().
getMenuInflater
();
inflater
.
inflate
(
R
.
menu
.
audio_list_browser
,
menu
);
if
(
v
.
getId
()
!=
R
.
id
.
songs_list
)
menu
.
setGroupEnabled
(
R
.
id
.
songs_view_only
,
false
);
}
@Override
public
boolean
onContextItemSelected
(
MenuItem
item
)
{
int
startPosition
;
...
...
@@ -273,8 +261,10 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
List
<
String
>
medias
;
int
id
=
item
.
getItemId
();
boolean
useAllItems
=
id
==
MENU_PLAY_ALL
||
id
==
MENU_APPEND_ALL
;
boolean
append
=
id
==
MENU_APPEND
||
id
==
MENU_APPEND_ALL
;
boolean
useAllItems
=
(
id
==
R
.
id
.
audio_list_browser_play_all
||
id
==
R
.
id
.
audio_list_browser_append_all
);
boolean
append
=
(
id
==
R
.
id
.
audio_list_browser_append
||
id
==
R
.
id
.
audio_list_browser_append_all
);
ContextMenuInfo
menuInfo
=
item
.
getMenuInfo
();
if
(
ExpandableListContextMenuInfo
.
class
.
isInstance
(
menuInfo
))
{
...
...
@@ -290,7 +280,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
childPosition
=
0
;
}
if
(
id
==
MENU_DELETE
)
{
if
(
id
==
R
.
id
.
audio_list_browser_delete
)
{
deleteMedia
(
mSongsAdapter
.
getLocation
(
groupPosition
),
mSongsAdapter
.
getItem
(
groupPosition
));
return
true
;
}
...
...
vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
View file @
b67c57d4
...
...
@@ -41,11 +41,10 @@ import android.os.Message;
import
android.view.ContextMenu
;
import
android.view.ContextMenu.ContextMenuInfo
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.Menu
Inflater
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.View.OnCreateContextMenuListener
;
import
android.widget.AdapterView.AdapterContextMenuInfo
;
import
android.widget.ListView
;
import
android.widget.TextView
;
...
...
@@ -87,17 +86,14 @@ public class AudioListFragment extends SherlockListFragment {
public
void
onViewCreated
(
View
view
,
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
getListView
().
setOnCreateContextMenuListener
(
contextMenuListener
);
updateList
();
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
audio_list
,
container
,
false
);
mTitle
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
title
);
registerForContextMenu
(
getListView
());
return
v
;
}
...
...
@@ -123,18 +119,6 @@ public class AudioListFragment extends SherlockListFragment {
super
.
onListItemClick
(
l
,
v
,
position
,
id
);
}
OnCreateContextMenuListener
contextMenuListener
=
new
OnCreateContextMenuListener
()
{
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenuInfo
menuInfo
)
{
menu
.
add
(
Menu
.
NONE
,
AudioBrowserFragment
.
MENU_PLAY
,
Menu
.
NONE
,
R
.
string
.
play
);
menu
.
add
(
Menu
.
NONE
,
AudioBrowserFragment
.
MENU_APPEND
,
Menu
.
NONE
,
R
.
string
.
append
);
menu
.
add
(
Menu
.
NONE
,
AudioBrowserFragment
.
MENU_PLAY_ALL
,
Menu
.
NONE
,
R
.
string
.
play_all
);
menu
.
add
(
Menu
.
NONE
,
AudioBrowserFragment
.
MENU_APPEND_ALL
,
Menu
.
NONE
,
R
.
string
.
append_all
);
menu
.
add
(
Menu
.
NONE
,
AudioBrowserFragment
.
MENU_DELETE
,
Menu
.
NONE
,
R
.
string
.
delete
);
}
};
public
void
deleteMedia
(
final
List
<
String
>
addressMedia
,
final
Media
aMedia
)
{
AlertDialog
alertDialog
=
new
AlertDialog
.
Builder
(
getActivity
())
.
setTitle
(
R
.
string
.
confirm_delete
)
...
...
@@ -160,6 +144,12 @@ public class AudioListFragment extends SherlockListFragment {
alertDialog
.
show
();
}
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenuInfo
menuInfo
)
{
MenuInflater
inflater
=
getActivity
().
getMenuInflater
();
inflater
.
inflate
(
R
.
menu
.
audio_list_browser
,
menu
);
}
@Override
public
boolean
onContextItemSelected
(
MenuItem
item
)
{
AdapterContextMenuInfo
menuInfo
=
(
AdapterContextMenuInfo
)
item
.
getMenuInfo
();
...
...
@@ -167,10 +157,12 @@ public class AudioListFragment extends SherlockListFragment {
List
<
String
>
medias
;
int
id
=
item
.
getItemId
();
boolean
useAllItems
=
id
==
AudioBrowserFragment
.
MENU_PLAY_ALL
||
id
==
AudioBrowserFragment
.
MENU_APPEND_ALL
;
boolean
append
=
id
==
AudioBrowserFragment
.
MENU_APPEND
||
id
==
AudioBrowserFragment
.
MENU_APPEND_ALL
;
boolean
useAllItems
=
(
id
==
R
.
id
.
audio_list_browser_play_all
||
id
==
R
.
id
.
audio_list_browser_append_all
);
boolean
append
=
(
id
==
R
.
id
.
audio_list_browser_append
||
id
==
R
.
id
.
audio_list_browser_append_all
);
if
(
id
==
AudioBrowserFragment
.
MENU_DELETE
)
{
if
(
id
==
R
.
id
.
audio_list_browser_delete
)
{
deleteMedia
(
mSongsAdapter
.
getLocation
(
menuInfo
.
position
),
mSongsAdapter
.
getItem
(
menuInfo
.
position
));
return
true
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment