@@ -60,7 +60,7 @@ data class LongPressAction(
6060 val type : Type ,
6161 @MainThread
6262 val action : suspend (context: Context ) -> Unit ,
63- val enabled : (isPlayerRunning: Boolean ) -> Boolean = { true },
63+ val enabled : (isPlayerRunning: Boolean ) -> Boolean = { true }
6464) {
6565 enum class Type (
6666 /* *
@@ -69,7 +69,7 @@ data class LongPressAction(
6969 */
7070 val id : Int ,
7171 @StringRes val label : Int ,
72- val icon : ImageVector ,
72+ val icon : ImageVector
7373 ) {
7474 Enqueue (0 , R .string.enqueue, Icons .Default .AddToQueue ),
7575 EnqueueNext (1 , R .string.enqueue_next_stream, Icons .Default .QueuePlayNext ),
@@ -92,15 +92,15 @@ data class LongPressAction(
9292 UnsetPlaylistThumbnail (18 , R .string.unset_playlist_thumbnail, Icons .Default .HideImage ),
9393 Unsubscribe (19 , R .string.unsubscribe, Icons .Default .Delete ),
9494 ShowDetails (20 , R .string.play_queue_stream_detail, Icons .Default .Info ),
95- Remove (21 , R .string.play_queue_remove, Icons .Default .Delete ),
95+ Remove (21 , R .string.play_queue_remove, Icons .Default .Delete )
9696 ;
9797
9898 // TODO allow actions to return disposables
9999 // TODO add actions that use the whole list the item belongs to (see wholeListQueue)
100100
101101 fun buildAction (
102102 enabled : (isPlayerRunning: Boolean ) -> Boolean = { true },
103- action : suspend (context: Context ) -> Unit ,
103+ action : suspend (context: Context ) -> Unit
104104 ) = LongPressAction (this , action, enabled)
105105
106106 companion object {
@@ -109,7 +109,7 @@ data class LongPressAction(
109109 val DefaultEnabledActions : List <Type > = listOf (
110110 ShowDetails , Enqueue , EnqueueNext , Background , Popup , BackgroundFromHere , Download ,
111111 AddToPlaylist , Share , OpenInBrowser , MarkAsWatched , Delete ,
112- Rename , SetAsPlaylistThumbnail , UnsetPlaylistThumbnail , Unsubscribe , Remove ,
112+ Rename , SetAsPlaylistThumbnail , UnsetPlaylistThumbnail , Unsubscribe , Remove
113113 )
114114 }
115115 }
@@ -133,7 +133,7 @@ data class LongPressAction(
133133 },
134134 Type .Play .buildAction { context ->
135135 NavigationHelper .playOnMainPlayer(context, queue(context), false )
136- },
136+ }
137137 )
138138 }
139139
@@ -147,7 +147,7 @@ data class LongPressAction(
147147 },
148148 Type .PlayFromHere .buildAction { context ->
149149 NavigationHelper .playOnMainPlayer(context, queueFromHere(), false )
150- },
150+ }
151151 )
152152 }
153153
@@ -158,7 +158,7 @@ data class LongPressAction(
158158 },
159159 Type .OpenInBrowser .buildAction { context ->
160160 ShareUtils .openUrlInBrowser(context, item.url)
161- },
161+ }
162162 )
163163 }
164164
@@ -169,7 +169,7 @@ data class LongPressAction(
169169 },
170170 Type .OpenInBrowser .buildAction { context ->
171171 ShareUtils .openUrlInBrowser(context, url)
172- },
172+ }
173173 )
174174 }
175175
@@ -200,13 +200,16 @@ data class LongPressAction(
200200 },
201201 Type .ShowChannelDetails .buildAction { context ->
202202 val uploaderUrl = fetchUploaderUrlIfSparse(
203- context, item.serviceId, item.url, item.uploaderUrl
203+ context,
204+ item.serviceId,
205+ item.url,
206+ item.uploaderUrl
204207 )
205208 NavigationHelper .openChannelFragment(
206209 context.findFragmentActivity().supportFragmentManager,
207210 item.serviceId,
208211 uploaderUrl,
209- item.uploaderName,
212+ item.uploaderName
210213 )
211214 },
212215 Type .MarkAsWatched .buildAction { context ->
@@ -216,7 +219,7 @@ data class LongPressAction(
216219 },
217220 Type .PlayWithKodi .buildAction { context ->
218221 KoreUtils .playWithKore(context, item.url.toUri())
219- },
222+ }
220223 )
221224 }
222225
@@ -227,7 +230,7 @@ data class LongPressAction(
227230 @JvmStatic
228231 fun fromStreamInfoItem (
229232 item : StreamInfoItem ,
230- queueFromHere : (() -> PlayQueue )? ,
233+ queueFromHere : (() -> PlayQueue )?
231234 /* TODO isKodiEnabled: Boolean, */
232235 ): List <LongPressAction > {
233236 return buildPlayerActionList { context -> fetchItemInfoIfSparse(context, item) } +
@@ -239,7 +242,7 @@ data class LongPressAction(
239242 @JvmStatic
240243 fun fromStreamEntity (
241244 item : StreamEntity ,
242- queueFromHere : (() -> PlayQueue )? ,
245+ queueFromHere : (() -> PlayQueue )?
243246 ): List <LongPressAction > {
244247 // TODO decide if it's fine to just convert to StreamInfoItem here (it poses an
245248 // unnecessary dependency on the extractor, when we want to just look at data; maybe
@@ -251,38 +254,43 @@ data class LongPressAction(
251254 fun fromPlayQueueItem (
252255 item : PlayQueueItem ,
253256 playQueueFromWhichToDelete : PlayQueue ,
254- showDetails : Boolean ,
257+ showDetails : Boolean
255258 ): List <LongPressAction > {
256259 // TODO decide if it's fine to just convert to StreamInfoItem here (it poses an
257260 // unnecessary dependency on the extractor, when we want to just look at data; maybe
258261 // using something like LongPressable would work)
259262 val streamInfoItem = item.toStreamInfoItem()
260263 return buildShareActionList(streamInfoItem) +
261- buildAdditionalStreamActionList(streamInfoItem) +
262- if (showDetails) {
263- listOf (
264- Type .ShowDetails .buildAction { context ->
265- // playQueue is null since we don't want any queue change
266- NavigationHelper .openVideoDetail(
267- context, item.serviceId, item.url, item.title, null , false
268- )
269- }
270- )
271- } else {
272- listOf ()
273- } +
264+ buildAdditionalStreamActionList(streamInfoItem) +
265+ if (showDetails) {
274266 listOf (
275- Type .Remove .buildAction {
276- val index = playQueueFromWhichToDelete.indexOf(item)
277- playQueueFromWhichToDelete.remove(index)
267+ Type .ShowDetails .buildAction { context ->
268+ // playQueue is null since we don't want any queue change
269+ NavigationHelper .openVideoDetail(
270+ context,
271+ item.serviceId,
272+ item.url,
273+ item.title,
274+ null ,
275+ false
276+ )
278277 }
279278 )
279+ } else {
280+ listOf ()
281+ } +
282+ listOf (
283+ Type .Remove .buildAction {
284+ val index = playQueueFromWhichToDelete.indexOf(item)
285+ playQueueFromWhichToDelete.remove(index)
286+ }
287+ )
280288 }
281289
282290 @JvmStatic
283291 fun fromStreamStatisticsEntry (
284292 item : StreamStatisticsEntry ,
285- queueFromHere : (() -> PlayQueue )? ,
293+ queueFromHere : (() -> PlayQueue )?
286294 ): List <LongPressAction > {
287295 return fromStreamEntity(item.streamEntity, queueFromHere) +
288296 listOf (
@@ -304,7 +312,7 @@ data class LongPressAction(
304312 queueFromHere : (() -> PlayQueue )? ,
305313 // TODO possibly embed these two actions here
306314 onDelete : Runnable ,
307- onSetAsPlaylistThumbnail : Runnable ,
315+ onSetAsPlaylistThumbnail : Runnable
308316 ): List <LongPressAction > {
309317 return fromStreamEntity(item.streamEntity, queueFromHere) +
310318 listOf (
@@ -318,7 +326,7 @@ data class LongPressAction(
318326 item : PlaylistMetadataEntry ,
319327 onRename : Runnable ,
320328 onDelete : Runnable ,
321- unsetPlaylistThumbnail : Runnable ? ,
329+ unsetPlaylistThumbnail : Runnable ?
322330 ): List <LongPressAction > {
323331 return listOf (
324332 Type .Rename .buildAction { onRename.run () },
@@ -332,7 +340,7 @@ data class LongPressAction(
332340 @JvmStatic
333341 fun fromPlaylistRemoteEntity (
334342 item : PlaylistRemoteEntity ,
335- onDelete : Runnable ,
343+ onDelete : Runnable
336344 ): List <LongPressAction > {
337345 return buildPlayerActionList { PlaylistPlayQueue (item.serviceId, item.url) } +
338346 buildShareActionList(
@@ -341,14 +349,14 @@ data class LongPressAction(
341349 item.thumbnailUrl
342350 ) +
343351 listOf (
344- Type .Delete .buildAction { onDelete.run () },
352+ Type .Delete .buildAction { onDelete.run () }
345353 )
346354 }
347355
348356 @JvmStatic
349357 fun fromChannelInfoItem (
350358 item : ChannelInfoItem ,
351- onUnsubscribe : Runnable ? ,
359+ onUnsubscribe : Runnable ?
352360 ): List <LongPressAction > {
353361 return buildPlayerActionList { ChannelTabPlayQueue (item.serviceId, item.url) } +
354362 buildShareActionList(item) +
@@ -358,7 +366,7 @@ data class LongPressAction(
358366 context.findFragmentActivity().supportFragmentManager,
359367 item.serviceId,
360368 item.url,
361- item.name,
369+ item.name
362370 )
363371 },
364372 onUnsubscribe?.let { r -> Type .Unsubscribe .buildAction { r.run () } }
0 commit comments