mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Prevent dup queue items, handle toast more centrally
This commit is contained in:
parent
f224cd1ca5
commit
23ca4addf9
4 changed files with 20 additions and 5 deletions
|
@ -207,8 +207,6 @@ class ChannelFragment : MainFragment() {
|
|||
adapter.onAddToQueueClicked.subscribe { content ->
|
||||
if(content is IPlatformVideo) {
|
||||
StatePlayer.instance.addToQueue(content);
|
||||
val name = if (content.name.length > 20) (content.name.subSequence(0, 20).toString() + "...") else content.name;
|
||||
UIDialogs.toast(context, "Queued [$name]", false);
|
||||
}
|
||||
}
|
||||
adapter.onUrlClicked.subscribe { url ->
|
||||
|
|
|
@ -79,8 +79,6 @@ abstract class ContentFeedView<TFragment> : FeedView<TFragment, IPlatformContent
|
|||
adapter.onAddToQueueClicked.subscribe(this) {
|
||||
if(it is IPlatformVideo) {
|
||||
StatePlayer.instance.addToQueue(it);
|
||||
val name = if (it.name.length > 20) (it.name.subSequence(0, 20).toString() + "...") else it.name;
|
||||
UIDialogs.toast(context, context.getString(R.string.queued) + " [$name]", false);
|
||||
}
|
||||
};
|
||||
adapter.onLongPress.subscribe(this) {
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.futo.platformplayer.states
|
|||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.futo.platformplayer.R
|
||||
import com.futo.platformplayer.UIDialogs
|
||||
import com.futo.platformplayer.api.media.models.playlists.IPlatformPlaylist
|
||||
import com.futo.platformplayer.api.media.models.playlists.IPlatformPlaylistDetails
|
||||
import com.futo.platformplayer.api.media.models.video.IPlatformVideo
|
||||
|
@ -268,7 +270,12 @@ class StatePlayer {
|
|||
setQueueWithPosition(videos, _queueType, index, withFocus);
|
||||
}
|
||||
fun addToQueue(video: IPlatformVideo) {
|
||||
var didAdd = false;
|
||||
synchronized(_queue) {
|
||||
if(_queue.any { it.url == video.url }) {
|
||||
return@synchronized;
|
||||
}
|
||||
|
||||
if(_queue.isEmpty()) {
|
||||
setQueueType(TYPE_QUEUE);
|
||||
currentVideo?.let {
|
||||
|
@ -284,8 +291,19 @@ class StatePlayer {
|
|||
if (_queuePosition < 0) {
|
||||
_queuePosition = 0;
|
||||
}
|
||||
didAdd = true;
|
||||
}
|
||||
onQueueChanged.emit(true);
|
||||
if(didAdd) {
|
||||
onQueueChanged.emit(true);
|
||||
StateApp.instance.contextOrNull?.let { context ->
|
||||
val name = if (video.name.length > 20) (video.name.subSequence(0, 20).toString() + "...") else video.name;
|
||||
UIDialogs.toast(context, context.getString(R.string.queued) + " [$name]", false);
|
||||
}
|
||||
}
|
||||
else
|
||||
StateApp.instance.contextOrNull?.let { context ->
|
||||
UIDialogs.toast(context, context.getString(R.string.already_queued), false);
|
||||
}
|
||||
}
|
||||
fun insertToQueue(video: IPlatformVideo, playNow: Boolean = false) {
|
||||
synchronized(_queue) {
|
||||
|
|
|
@ -537,6 +537,7 @@
|
|||
<string name="play_feed_as_queue">Play Feed as Queue</string>
|
||||
<string name="play_entire_feed">Play entire feed</string>
|
||||
<string name="queued">Queued</string>
|
||||
<string name="already_queued">Already queued</string>
|
||||
<string name="used">Used</string>
|
||||
<string name="available">Available</string>
|
||||
<string name="failed_to_load_next_page">Failed to load next page</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue