Merge pull request #13385 from arjun1194/fix/use-application-context-for-enqueue
Fix NullPointerException in enqueue actions by using Application Context
This commit is contained in:
commit
38fccceece
1 changed files with 21 additions and 15 deletions
|
|
@ -5,6 +5,7 @@ import static org.schabi.newpipe.util.SparseItemUtil.fetchItemInfoIfSparse;
|
||||||
import static org.schabi.newpipe.util.SparseItemUtil.fetchStreamInfoAndSaveToDatabase;
|
import static org.schabi.newpipe.util.SparseItemUtil.fetchStreamInfoAndSaveToDatabase;
|
||||||
import static org.schabi.newpipe.util.SparseItemUtil.fetchUploaderUrlIfSparse;
|
import static org.schabi.newpipe.util.SparseItemUtil.fetchUploaderUrlIfSparse;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -52,28 +53,33 @@ public enum StreamDialogDefaultEntry {
|
||||||
/**
|
/**
|
||||||
* Enqueues the stream automatically to the current PlayerType.
|
* Enqueues the stream automatically to the current PlayerType.
|
||||||
*/
|
*/
|
||||||
ENQUEUE(R.string.enqueue_stream, (fragment, item) ->
|
ENQUEUE(R.string.enqueue_stream, (fragment, item) -> {
|
||||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||||
NavigationHelper.enqueueOnPlayer(fragment.getContext(), singlePlayQueue))
|
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||||
),
|
NavigationHelper.enqueueOnPlayer(ctx, singlePlayQueue));
|
||||||
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueues the stream automatically to the current PlayerType
|
* Enqueues the stream automatically to the current PlayerType
|
||||||
* after the currently playing stream.
|
* after the currently playing stream.
|
||||||
*/
|
*/
|
||||||
ENQUEUE_NEXT(R.string.enqueue_next_stream, (fragment, item) ->
|
ENQUEUE_NEXT(R.string.enqueue_next_stream, (fragment, item) -> {
|
||||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||||
NavigationHelper.enqueueNextOnPlayer(fragment.getContext(), singlePlayQueue))
|
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||||
),
|
NavigationHelper.enqueueNextOnPlayer(ctx, singlePlayQueue));
|
||||||
|
}),
|
||||||
|
|
||||||
START_HERE_ON_BACKGROUND(R.string.start_here_on_background, (fragment, item) ->
|
START_HERE_ON_BACKGROUND(R.string.start_here_on_background, (fragment, item) -> {
|
||||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||||
NavigationHelper.playOnBackgroundPlayer(
|
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||||
fragment.getContext(), singlePlayQueue, true))),
|
NavigationHelper.playOnBackgroundPlayer(ctx, singlePlayQueue, true));
|
||||||
|
}),
|
||||||
|
|
||||||
START_HERE_ON_POPUP(R.string.start_here_on_popup, (fragment, item) ->
|
START_HERE_ON_POPUP(R.string.start_here_on_popup, (fragment, item) -> {
|
||||||
fetchItemInfoIfSparse(fragment.requireContext(), item, singlePlayQueue ->
|
final Context ctx = fragment.requireContext().getApplicationContext();
|
||||||
NavigationHelper.playOnPopupPlayer(fragment.getContext(), singlePlayQueue, true))),
|
fetchItemInfoIfSparse(ctx, item, singlePlayQueue ->
|
||||||
|
NavigationHelper.playOnPopupPlayer(ctx, singlePlayQueue, true));
|
||||||
|
}),
|
||||||
|
|
||||||
SET_AS_PLAYLIST_THUMBNAIL(R.string.set_as_playlist_thumbnail, (fragment, item) -> {
|
SET_AS_PLAYLIST_THUMBNAIL(R.string.set_as_playlist_thumbnail, (fragment, item) -> {
|
||||||
throw new UnsupportedOperationException("This needs to be implemented manually "
|
throw new UnsupportedOperationException("This needs to be implemented manually "
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue