mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 00:20:32 +00:00
Use newInstance in PlaylistDialog
This commit is contained in:
parent
629b685f5a
commit
638f227b51
@ -33,8 +33,16 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
|
|||||||
|
|
||||||
private final CompositeDisposable playlistDisposables = new CompositeDisposable();
|
private final CompositeDisposable playlistDisposables = new CompositeDisposable();
|
||||||
|
|
||||||
public PlaylistAppendDialog(final List<StreamEntity> streamEntities) {
|
/**
|
||||||
super(streamEntities);
|
* Create a new instance of {@link PlaylistAppendDialog}.
|
||||||
|
*
|
||||||
|
* @param streamEntities a list of {@link StreamEntity} to be added to playlists
|
||||||
|
* @return a new instance of {@link PlaylistAppendDialog}
|
||||||
|
*/
|
||||||
|
public static PlaylistAppendDialog newInstance(final List<StreamEntity> streamEntities) {
|
||||||
|
final PlaylistAppendDialog dialog = new PlaylistAppendDialog();
|
||||||
|
dialog.setStreamEntities(streamEntities);
|
||||||
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
@ -103,13 +111,14 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
|
|||||||
// Helper
|
// Helper
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
/** Display create playlist dialog. */
|
||||||
public void openCreatePlaylistDialog() {
|
public void openCreatePlaylistDialog() {
|
||||||
if (getStreamEntities() == null || !isAdded()) {
|
if (getStreamEntities() == null || !isAdded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlaylistCreationDialog playlistCreationDialog =
|
final PlaylistCreationDialog playlistCreationDialog =
|
||||||
new PlaylistCreationDialog(getStreamEntities());
|
PlaylistCreationDialog.newInstance(getStreamEntities());
|
||||||
// Move the dismissListener to the new dialog.
|
// Move the dismissListener to the new dialog.
|
||||||
playlistCreationDialog.setOnDismissListener(this.getOnDismissListener());
|
playlistCreationDialog.setOnDismissListener(this.getOnDismissListener());
|
||||||
this.setOnDismissListener(null);
|
this.setOnDismissListener(null);
|
||||||
|
@ -21,8 +21,17 @@ import java.util.List;
|
|||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
|
||||||
public final class PlaylistCreationDialog extends PlaylistDialog {
|
public final class PlaylistCreationDialog extends PlaylistDialog {
|
||||||
public PlaylistCreationDialog(final List<StreamEntity> streamEntities) {
|
|
||||||
super(streamEntities);
|
/**
|
||||||
|
* Create a new instance of {@link PlaylistCreationDialog}.
|
||||||
|
*
|
||||||
|
* @param streamEntities a list of {@link StreamEntity} to be added to playlists
|
||||||
|
* @return a new instance of {@link PlaylistCreationDialog}
|
||||||
|
*/
|
||||||
|
public static PlaylistCreationDialog newInstance(final List<StreamEntity> streamEntities) {
|
||||||
|
final PlaylistCreationDialog dialog = new PlaylistCreationDialog();
|
||||||
|
dialog.setStreamEntities(streamEntities);
|
||||||
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -31,10 +31,6 @@ public abstract class PlaylistDialog extends DialogFragment implements StateSave
|
|||||||
|
|
||||||
private org.schabi.newpipe.util.SavedState savedState;
|
private org.schabi.newpipe.util.SavedState savedState;
|
||||||
|
|
||||||
public PlaylistDialog(final List<StreamEntity> streamEntities) {
|
|
||||||
this.streamEntities = streamEntities;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// LifeCycle
|
// LifeCycle
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
@ -120,6 +116,10 @@ public abstract class PlaylistDialog extends DialogFragment implements StateSave
|
|||||||
this.onDismissListener = onDismissListener;
|
this.onDismissListener = onDismissListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setStreamEntities(final List<StreamEntity> streamEntities) {
|
||||||
|
this.streamEntities = streamEntities;
|
||||||
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Dialog creation
|
// Dialog creation
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
@ -143,8 +143,8 @@ public abstract class PlaylistDialog extends DialogFragment implements StateSave
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(hasPlaylists ->
|
.subscribe(hasPlaylists ->
|
||||||
onExec.accept(hasPlaylists
|
onExec.accept(hasPlaylists
|
||||||
? new PlaylistAppendDialog(streamEntities)
|
? PlaylistAppendDialog.newInstance(streamEntities)
|
||||||
: new PlaylistCreationDialog(streamEntities))
|
: PlaylistCreationDialog.newInstance(streamEntities))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user