Merge inheritors of newpipe/player/playqueue/PlayQueueEvent and
convert it to kotlin
This commit is contained in:
parent
83596ca907
commit
3ffcf11a3a
@ -17,10 +17,10 @@ import org.schabi.newpipe.player.mediasource.ManagedMediaSource;
|
||||
import org.schabi.newpipe.player.mediasource.ManagedMediaSourcePlaylist;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
|
||||
import org.schabi.newpipe.player.playqueue.events.MoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.PlayQueueEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.RemoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.ReorderEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.MoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RemoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ReorderEvent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@ -4,15 +4,14 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.player.playqueue.events.AppendEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.ErrorEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.InitEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.MoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.PlayQueueEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.RecoveryEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.RemoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.ReorderEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.SelectEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.AppendEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ErrorEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.InitEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.MoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RecoveryEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RemoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ReorderEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.SelectEvent;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -10,12 +10,11 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.player.playqueue.events.AppendEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.ErrorEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.MoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.PlayQueueEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.RemoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.SelectEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.AppendEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.ErrorEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.MoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.RemoveEvent;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueEvent.SelectEvent;
|
||||
import org.schabi.newpipe.util.FallbackViewHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2026 NewPipe contributors <https://newpipe.net>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package org.schabi.newpipe.player.playqueue
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
sealed interface PlayQueueEvent : Serializable {
|
||||
fun type(): Type
|
||||
|
||||
class InitEvent : PlayQueueEvent {
|
||||
override fun type() = Type.INIT
|
||||
}
|
||||
|
||||
// sent when the index is changed
|
||||
class SelectEvent(val oldIndex: Int, val newIndex: Int) : PlayQueueEvent {
|
||||
override fun type() = Type.SELECT
|
||||
}
|
||||
|
||||
// sent when more streams are added to the play queue
|
||||
class AppendEvent(val amount: Int) : PlayQueueEvent {
|
||||
override fun type() = Type.APPEND
|
||||
}
|
||||
|
||||
// sent when a pending stream is removed from the play queue
|
||||
class RemoveEvent(val removeIndex: Int, val queueIndex: Int) : PlayQueueEvent {
|
||||
override fun type() = Type.REMOVE
|
||||
}
|
||||
|
||||
// sent when two streams swap place in the play queue
|
||||
class MoveEvent(val fromIndex: Int, val toIndex: Int) : PlayQueueEvent {
|
||||
override fun type() = Type.MOVE
|
||||
}
|
||||
|
||||
// sent when queue is shuffled
|
||||
class ReorderEvent(val fromSelectedIndex: Int, val toSelectedIndex: Int) : PlayQueueEvent {
|
||||
override fun type() = Type.REORDER
|
||||
}
|
||||
|
||||
// sent when recovery record is set on a stream
|
||||
class RecoveryEvent(val index: Int, val position: Long) : PlayQueueEvent {
|
||||
override fun type() = Type.RECOVERY
|
||||
}
|
||||
|
||||
// sent when the item at index has caused an exception
|
||||
class ErrorEvent(val errorIndex: Int, val queueIndex: Int) : PlayQueueEvent {
|
||||
override fun type() = Type.ERROR
|
||||
}
|
||||
|
||||
// It is necessary only for use in java code. Remove it and use kotlin pattern
|
||||
// matching when all users of this enum are converted to kotlin
|
||||
enum class Type { INIT, SELECT, APPEND, REMOVE, MOVE, REORDER, RECOVERY, ERROR }
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class AppendEvent implements PlayQueueEvent {
|
||||
private final int amount;
|
||||
|
||||
public AppendEvent(final int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.APPEND;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class ErrorEvent implements PlayQueueEvent {
|
||||
private final int errorIndex;
|
||||
private final int queueIndex;
|
||||
|
||||
public ErrorEvent(final int errorIndex, final int queueIndex) {
|
||||
this.errorIndex = errorIndex;
|
||||
this.queueIndex = queueIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.ERROR;
|
||||
}
|
||||
|
||||
public int getErrorIndex() {
|
||||
return errorIndex;
|
||||
}
|
||||
|
||||
public int getQueueIndex() {
|
||||
return queueIndex;
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class InitEvent implements PlayQueueEvent {
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.INIT;
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class MoveEvent implements PlayQueueEvent {
|
||||
private final int fromIndex;
|
||||
private final int toIndex;
|
||||
|
||||
public MoveEvent(final int oldIndex, final int newIndex) {
|
||||
this.fromIndex = oldIndex;
|
||||
this.toIndex = newIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.MOVE;
|
||||
}
|
||||
|
||||
public int getFromIndex() {
|
||||
return fromIndex;
|
||||
}
|
||||
|
||||
public int getToIndex() {
|
||||
return toIndex;
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface PlayQueueEvent extends Serializable {
|
||||
PlayQueueEventType type();
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public enum PlayQueueEventType {
|
||||
INIT,
|
||||
|
||||
// sent when the index is changed
|
||||
SELECT,
|
||||
|
||||
// sent when more streams are added to the play queue
|
||||
APPEND,
|
||||
|
||||
// sent when a pending stream is removed from the play queue
|
||||
REMOVE,
|
||||
|
||||
// sent when two streams swap place in the play queue
|
||||
MOVE,
|
||||
|
||||
// sent when queue is shuffled
|
||||
REORDER,
|
||||
|
||||
// sent when recovery record is set on a stream
|
||||
RECOVERY,
|
||||
|
||||
// sent when the item at index has caused an exception
|
||||
ERROR
|
||||
}
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class RecoveryEvent implements PlayQueueEvent {
|
||||
private final int index;
|
||||
private final long position;
|
||||
|
||||
public RecoveryEvent(final int index, final long position) {
|
||||
this.index = index;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.RECOVERY;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public long getPosition() {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class RemoveEvent implements PlayQueueEvent {
|
||||
private final int removeIndex;
|
||||
private final int queueIndex;
|
||||
|
||||
public RemoveEvent(final int removeIndex, final int queueIndex) {
|
||||
this.removeIndex = removeIndex;
|
||||
this.queueIndex = queueIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.REMOVE;
|
||||
}
|
||||
|
||||
public int getQueueIndex() {
|
||||
return queueIndex;
|
||||
}
|
||||
|
||||
public int getRemoveIndex() {
|
||||
return removeIndex;
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class ReorderEvent implements PlayQueueEvent {
|
||||
private final int fromSelectedIndex;
|
||||
private final int toSelectedIndex;
|
||||
|
||||
public ReorderEvent(final int fromSelectedIndex, final int toSelectedIndex) {
|
||||
this.fromSelectedIndex = fromSelectedIndex;
|
||||
this.toSelectedIndex = toSelectedIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.REORDER;
|
||||
}
|
||||
|
||||
public int getFromSelectedIndex() {
|
||||
return fromSelectedIndex;
|
||||
}
|
||||
|
||||
public int getToSelectedIndex() {
|
||||
return toSelectedIndex;
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package org.schabi.newpipe.player.playqueue.events;
|
||||
|
||||
public class SelectEvent implements PlayQueueEvent {
|
||||
private final int oldIndex;
|
||||
private final int newIndex;
|
||||
|
||||
public SelectEvent(final int oldIndex, final int newIndex) {
|
||||
this.oldIndex = oldIndex;
|
||||
this.newIndex = newIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayQueueEventType type() {
|
||||
return PlayQueueEventType.SELECT;
|
||||
}
|
||||
|
||||
public int getOldIndex() {
|
||||
return oldIndex;
|
||||
}
|
||||
|
||||
public int getNewIndex() {
|
||||
return newIndex;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user