Skip to content

Commit 3ffcf11

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Merge inheritors of newpipe/player/playqueue/PlayQueueEvent and
convert it to kotlin
1 parent 83596ca commit 3ffcf11

14 files changed

Lines changed: 72 additions & 223 deletions

app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import org.schabi.newpipe.player.mediasource.ManagedMediaSourcePlaylist;
1818
import org.schabi.newpipe.player.playqueue.PlayQueue;
1919
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
20-
import org.schabi.newpipe.player.playqueue.events.MoveEvent;
21-
import org.schabi.newpipe.player.playqueue.events.PlayQueueEvent;
22-
import org.schabi.newpipe.player.playqueue.events.RemoveEvent;
23-
import org.schabi.newpipe.player.playqueue.events.ReorderEvent;
20+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.MoveEvent;
21+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent;
22+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RemoveEvent;
23+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ReorderEvent;
2424

2525
import java.util.Collection;
2626
import java.util.Collections;

app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
import androidx.annotation.Nullable;
55

66
import org.schabi.newpipe.MainActivity;
7-
import org.schabi.newpipe.player.playqueue.events.AppendEvent;
8-
import org.schabi.newpipe.player.playqueue.events.ErrorEvent;
9-
import org.schabi.newpipe.player.playqueue.events.InitEvent;
10-
import org.schabi.newpipe.player.playqueue.events.MoveEvent;
11-
import org.schabi.newpipe.player.playqueue.events.PlayQueueEvent;
12-
import org.schabi.newpipe.player.playqueue.events.RecoveryEvent;
13-
import org.schabi.newpipe.player.playqueue.events.RemoveEvent;
14-
import org.schabi.newpipe.player.playqueue.events.ReorderEvent;
15-
import org.schabi.newpipe.player.playqueue.events.SelectEvent;
7+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.AppendEvent;
8+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ErrorEvent;
9+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.InitEvent;
10+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.MoveEvent;
11+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RecoveryEvent;
12+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RemoveEvent;
13+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ReorderEvent;
14+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.SelectEvent;
1615

1716
import java.io.Serializable;
1817
import java.util.ArrayList;

app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueAdapter.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
import androidx.recyclerview.widget.RecyclerView;
1111

1212
import org.schabi.newpipe.R;
13-
import org.schabi.newpipe.player.playqueue.events.AppendEvent;
14-
import org.schabi.newpipe.player.playqueue.events.ErrorEvent;
15-
import org.schabi.newpipe.player.playqueue.events.MoveEvent;
16-
import org.schabi.newpipe.player.playqueue.events.PlayQueueEvent;
17-
import org.schabi.newpipe.player.playqueue.events.RemoveEvent;
18-
import org.schabi.newpipe.player.playqueue.events.SelectEvent;
13+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.AppendEvent;
14+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ErrorEvent;
15+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.MoveEvent;
16+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RemoveEvent;
17+
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.SelectEvent;
1918
import org.schabi.newpipe.util.FallbackViewHolder;
2019

2120
import java.util.List;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2017-2026 NewPipe contributors <https://newpipe.net>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.player.playqueue
7+
8+
import java.io.Serializable
9+
10+
sealed interface PlayQueueEvent : Serializable {
11+
fun type(): Type
12+
13+
class InitEvent : PlayQueueEvent {
14+
override fun type() = Type.INIT
15+
}
16+
17+
// sent when the index is changed
18+
class SelectEvent(val oldIndex: Int, val newIndex: Int) : PlayQueueEvent {
19+
override fun type() = Type.SELECT
20+
}
21+
22+
// sent when more streams are added to the play queue
23+
class AppendEvent(val amount: Int) : PlayQueueEvent {
24+
override fun type() = Type.APPEND
25+
}
26+
27+
// sent when a pending stream is removed from the play queue
28+
class RemoveEvent(val removeIndex: Int, val queueIndex: Int) : PlayQueueEvent {
29+
override fun type() = Type.REMOVE
30+
}
31+
32+
// sent when two streams swap place in the play queue
33+
class MoveEvent(val fromIndex: Int, val toIndex: Int) : PlayQueueEvent {
34+
override fun type() = Type.MOVE
35+
}
36+
37+
// sent when queue is shuffled
38+
class ReorderEvent(val fromSelectedIndex: Int, val toSelectedIndex: Int) : PlayQueueEvent {
39+
override fun type() = Type.REORDER
40+
}
41+
42+
// sent when recovery record is set on a stream
43+
class RecoveryEvent(val index: Int, val position: Long) : PlayQueueEvent {
44+
override fun type() = Type.RECOVERY
45+
}
46+
47+
// sent when the item at index has caused an exception
48+
class ErrorEvent(val errorIndex: Int, val queueIndex: Int) : PlayQueueEvent {
49+
override fun type() = Type.ERROR
50+
}
51+
52+
// It is necessary only for use in java code. Remove it and use kotlin pattern
53+
// matching when all users of this enum are converted to kotlin
54+
enum class Type { INIT, SELECT, APPEND, REMOVE, MOVE, REORDER, RECOVERY, ERROR }
55+
}

app/src/main/java/org/schabi/newpipe/player/playqueue/events/AppendEvent.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/player/playqueue/events/ErrorEvent.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/player/playqueue/events/InitEvent.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/player/playqueue/events/MoveEvent.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/player/playqueue/events/PlayQueueEvent.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/player/playqueue/events/PlayQueueEventType.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)