Add toast when added to playlist.
This commit is contained in:
parent
ab654a08c4
commit
b0747658ae
|
@ -3,6 +3,7 @@ package com.github.apognu.otter.fragments
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.github.apognu.otter.R
|
import com.github.apognu.otter.R
|
||||||
|
@ -13,7 +14,9 @@ import com.google.gson.Gson
|
||||||
import kotlinx.android.synthetic.main.dialog_add_to_playlist.*
|
import kotlinx.android.synthetic.main.dialog_add_to_playlist.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
object AddToPlaylistDialog {
|
object AddToPlaylistDialog {
|
||||||
fun show(activity: Activity, lifecycleScope: CoroutineScope, track: Track) {
|
fun show(activity: Activity, lifecycleScope: CoroutineScope, track: Track) {
|
||||||
|
@ -40,6 +43,11 @@ object AddToPlaylistDialog {
|
||||||
lifecycleScope.launch(IO) {
|
lifecycleScope.launch(IO) {
|
||||||
repository.new(name)?.let { id ->
|
repository.new(name)?.let { id ->
|
||||||
repository.add(id, track)
|
repository.add(id, track)
|
||||||
|
|
||||||
|
withContext(Main) {
|
||||||
|
Toast.makeText(activity, activity.getString(R.string.playlist_added_to, name), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +56,9 @@ object AddToPlaylistDialog {
|
||||||
val adapter = PlaylistsAdapter(activity, object : PlaylistsAdapter.OnPlaylistClickListener {
|
val adapter = PlaylistsAdapter(activity, object : PlaylistsAdapter.OnPlaylistClickListener {
|
||||||
override fun onClick(holder: View?, playlist: Playlist) {
|
override fun onClick(holder: View?, playlist: Playlist) {
|
||||||
repository.add(playlist.id, track)
|
repository.add(playlist.id, track)
|
||||||
|
|
||||||
|
Toast.makeText(activity, activity.getString(R.string.playlist_added_to, playlist.name), Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -114,8 +114,9 @@
|
||||||
<item quantity="other">%1$d pistes • %2$s</item>
|
<item quantity="other">%1$d pistes • %2$s</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="playlist_add_to">Ajouter à une playlist</string>
|
<string name="playlist_add_to">Ajouter à une playlist</string>
|
||||||
<string name="playlist_add_to_new">Nouvelle playlist...</string>
|
<string name="playlist_add_to_new">Nouvelle playlist…</string>
|
||||||
<string name="playlist_add_to_create">Créer playlist</string>
|
<string name="playlist_add_to_create">Créer playlist</string>
|
||||||
|
<string name="playlist_added_to">Ajouté à la playlist %s</string>
|
||||||
<string name="filters">Filtres</string>
|
<string name="filters">Filtres</string>
|
||||||
<string name="fiters_all">Toute la musique</string>
|
<string name="fiters_all">Toute la musique</string>
|
||||||
<string name="filters_my_music">Ma musique</string>
|
<string name="filters_my_music">Ma musique</string>
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
<string name="playlist_add_to">Add to playlist</string>
|
<string name="playlist_add_to">Add to playlist</string>
|
||||||
<string name="playlist_add_to_new">New playlist…</string>
|
<string name="playlist_add_to_new">New playlist…</string>
|
||||||
<string name="playlist_add_to_create">Create playlist</string>
|
<string name="playlist_add_to_create">Create playlist</string>
|
||||||
|
<string name="playlist_added_to">Added to playlist %s</string>
|
||||||
<string name="filters">Filters</string>
|
<string name="filters">Filters</string>
|
||||||
<string name="fiters_all">All music</string>
|
<string name="fiters_all">All music</string>
|
||||||
<string name="filters_my_music">My music</string>
|
<string name="filters_my_music">My music</string>
|
||||||
|
|
Loading…
Reference in New Issue