mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-28 20:40:17 +02:00
don't save playlists that weren't explicitly copied
fixed exception failed to convert playlist job cancelled
This commit is contained in:
parent
c275415a49
commit
4609a351dc
@ -104,7 +104,7 @@ class RemotePlaylistFragment : MainFragment() {
|
|||||||
val view = LayoutInflater.from(viewGroup.context).inflate(R.layout.list_playlist, viewGroup, false);
|
val view = LayoutInflater.from(viewGroup.context).inflate(R.layout.list_playlist, viewGroup, false);
|
||||||
val holder = VideoListEditorViewHolder(view, null);
|
val holder = VideoListEditorViewHolder(view, null);
|
||||||
holder.onClick.subscribe {
|
holder.onClick.subscribe {
|
||||||
showConvertConfirmationModal();
|
showConvertConfirmationModal(false);
|
||||||
};
|
};
|
||||||
return@InsertedViewAdapterWithLoader holder;
|
return@InsertedViewAdapterWithLoader holder;
|
||||||
}
|
}
|
||||||
@ -128,10 +128,10 @@ class RemotePlaylistFragment : MainFragment() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
buttonPlayAll.setOnClickListener {
|
buttonPlayAll.setOnClickListener {
|
||||||
showConvertConfirmationModal();
|
showConvertConfirmationModal(false);
|
||||||
};
|
};
|
||||||
buttonShuffle.setOnClickListener {
|
buttonShuffle.setOnClickListener {
|
||||||
showConvertConfirmationModal();
|
showConvertConfirmationModal(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
_taskLoadPlaylist = TaskHandler<String, IPlatformPlaylistDetails>(
|
_taskLoadPlaylist = TaskHandler<String, IPlatformPlaylistDetails>(
|
||||||
@ -253,48 +253,52 @@ class RemotePlaylistFragment : MainFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showConvertConfirmationModal() {
|
private fun showConvertConfirmationModal(savePlaylist: Boolean) {
|
||||||
val remotePlaylist = _remotePlaylist;
|
val remotePlaylist = _remotePlaylist
|
||||||
if (remotePlaylist == null) {
|
if (remotePlaylist == null) {
|
||||||
UIDialogs.toast(context.getString(R.string.please_wait_for_playlist_to_finish_loading));
|
UIDialogs.toast(context.getString(R.string.please_wait_for_playlist_to_finish_loading))
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val c = context ?: return;
|
val c = context ?: return
|
||||||
UIDialogs.showConfirmationDialog(c, "Conversion to local playlist is required for this action", {
|
UIDialogs.showConfirmationDialog(
|
||||||
setLoading(true);
|
c,
|
||||||
|
"Conversion to local playlist is required for this action",
|
||||||
|
{
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
UIDialogs.showDialogProgress(context) {
|
UIDialogs.showDialogProgress(context) {
|
||||||
it.setText("Converting playlist..");
|
it.setText("Converting playlist..")
|
||||||
it.setProgress(0f);
|
it.setProgress(0f)
|
||||||
|
|
||||||
_fragment.lifecycleScope.launch(Dispatchers.IO) {
|
_fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val playlist = remotePlaylist.toPlaylist() { progress ->
|
val playlist = remotePlaylist.toPlaylist { progress ->
|
||||||
_fragment.lifecycleScope.launch(Dispatchers.Main) {
|
_fragment.lifecycleScope.launch(Dispatchers.Main) {
|
||||||
it.setProgress(progress.toDouble() / remotePlaylist.videoCount);
|
it.setProgress(progress.toDouble() / remotePlaylist.videoCount)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
StatePlaylists.instance.playlistStore.save(playlist);
|
if (savePlaylist) {
|
||||||
|
StatePlaylists.instance.playlistStore.save(playlist)
|
||||||
|
}
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
_fragment.lifecycleScope.launch(Dispatchers.Main) {
|
||||||
UIDialogs.toast("Playlist converted");
|
UIDialogs.toast("Playlist converted")
|
||||||
it.dismiss();
|
it.dismiss()
|
||||||
_fragment.navigate<PlaylistFragment>(playlist);
|
_fragment.navigate<PlaylistFragment>(playlist)
|
||||||
|
}
|
||||||
|
} catch (ex: Throwable) {
|
||||||
|
UIDialogs.appToast("Failed to convert playlist.\n" + ex.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(ex: Throwable) {
|
|
||||||
UIDialogs.appToast("Failed to convert playlist.\n" + ex.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showConvertPlaylistButton() {
|
private fun showConvertPlaylistButton() {
|
||||||
_fragment.topBar?.assume<NavigationTopBarFragment>()?.setMenuItems(arrayListOf(Pair(R.drawable.ic_copy) {
|
_fragment.topBar?.assume<NavigationTopBarFragment>()?.setMenuItems(arrayListOf(Pair(R.drawable.ic_copy) {
|
||||||
showConvertConfirmationModal();
|
showConvertConfirmationModal(true);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user