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
cf5aad85
Commit
cf5aad85
authored
Jun 20, 2012
by
Alexandre Perraud
Committed by
Jean-Baptiste Kempf
Jun 20, 2012
Browse files
Delete song in contextMenuListener
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
ef083519
Changes
3
Hide whitespace changes
Inline
Side-by-side
vlc-android/res/values/strings.xml
View file @
cf5aad85
...
...
@@ -23,6 +23,8 @@
<string
name=
"append"
>
Append
</string>
<string
name=
"play_all"
>
Play all
</string>
<string
name=
"append_all"
>
Append all
</string>
<string
name=
"delete"
>
Delete
</string>
<string
name=
"confirm_delete"
>
Delete this file ?
</string>
<string
name=
"pause"
>
Pause
</string>
<string
name=
"close"
>
Close
</string>
<string
name=
"not_show_again"
>
"Don't show this message again."
</string>
...
...
vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserActivity.java
View file @
cf5aad85
...
...
@@ -20,6 +20,9 @@
package
org.videolan.vlc.gui.audio
;
import
java.io.File
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
...
...
@@ -33,6 +36,8 @@ import org.videolan.vlc.widget.FlingViewGroup;
import
org.videolan.vlc.widget.FlingViewGroup.ViewSwitchListener
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.os.Bundle
;
...
...
@@ -82,6 +87,7 @@ public class AudioBrowserActivity extends Activity implements ISortable {
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
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -173,6 +179,7 @@ public class AudioBrowserActivity extends Activity implements ISortable {
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
);
}
}
};
...
...
@@ -196,12 +203,38 @@ public class AudioBrowserActivity extends Activity implements ISortable {
childPosition
=
0
;
}
else
{
AdapterContextMenuInfo
info
=
(
AdapterContextMenuInfo
)
menuInfo
;
groupPosition
=
info
.
position
;
childPosition
=
0
;
}
if
(
id
==
MENU_DELETE
){
final
int
groupPositionDelete
=
groupPosition
;
AlertDialog
alertDialog
=
new
AlertDialog
.
Builder
(
this
.
getParent
())
.
setTitle
(
R
.
string
.
confirm_delete
)
.
setMessage
(
R
.
string
.
validation
)
.
setIcon
(
android
.
R
.
drawable
.
ic_dialog_alert
)
.
setPositiveButton
(
android
.
R
.
string
.
yes
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
List
<
String
>
adressMedia
=
mSongsAdapter
.
getLocation
(
groupPositionDelete
);
URI
adressMediaUri
=
null
;
try
{
adressMediaUri
=
new
URI
(
adressMedia
.
get
(
0
));
}
catch
(
URISyntaxException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
File
fileMedia
=
new
File
(
adressMediaUri
);
fileMedia
.
delete
();
mMediaLibrary
.
getMediaItems
().
remove
(
mSongsAdapter
.
getItem
(
groupPositionDelete
));
updateLists
();
}
})
.
setNegativeButton
(
android
.
R
.
string
.
cancel
,
null
).
create
();
alertDialog
.
show
();
return
true
;
}
if
(
play_all
)
{
startPosition
=
groupPosition
;
medias
=
mSongsAdapter
.
getLocations
();
...
...
vlc-android/src/org/videolan/vlc/gui/audio/AudioSongsListAdapter.java
View file @
cf5aad85
...
...
@@ -52,6 +52,12 @@ public class AudioSongsListAdapter extends ArrayAdapter<Media> {
super
.
add
(
m
);
}
@Override
public
void
remove
(
Media
m
)
{
mMediaList
.
remove
(
m
);
super
.
remove
(
m
);
}
@Override
public
void
clear
()
{
mMediaList
.
clear
();
...
...
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