Skip to content

Commit 47263f5

Browse files
authored
Merge pull request #11959 from Stypox/fix-loading-stream-twice
Fix loading StreamInfo twice on first VideoDetailFragment opening
2 parents ebf3008 + 01bf855 commit 47263f5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ public void onServiceDisconnected() {
283283
/*////////////////////////////////////////////////////////////////////////*/
284284

285285
public static VideoDetailFragment getInstance(final int serviceId,
286-
@Nullable final String videoUrl,
286+
@Nullable final String url,
287287
@NonNull final String name,
288288
@Nullable final PlayQueue queue) {
289289
final VideoDetailFragment instance = new VideoDetailFragment();
290-
instance.setInitialData(serviceId, videoUrl, name, queue);
290+
instance.setInitialData(serviceId, url, name, queue);
291291
return instance;
292292
}
293293

@@ -1736,7 +1736,7 @@ public void onQueueUpdate(final PlayQueue queue) {
17361736
playQueue = queue;
17371737
if (DEBUG) {
17381738
Log.d(TAG, "onQueueUpdate() called with: serviceId = ["
1739-
+ serviceId + "], videoUrl = [" + url + "], name = ["
1739+
+ serviceId + "], url = [" + url + "], name = ["
17401740
+ title + "], playQueue = [" + playQueue + "]");
17411741
}
17421742

app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,12 @@ public static void openVideoDetailFragment(@NonNull final Context context,
452452
if (fragment instanceof VideoDetailFragment && fragment.isVisible()) {
453453
onVideoDetailFragmentReady.run((VideoDetailFragment) fragment);
454454
} else {
455+
// Specify no url here, otherwise the VideoDetailFragment will start loading the
456+
// stream automatically if it's the first time it is being opened, but then
457+
// onVideoDetailFragmentReady will kick in and start another loading process.
458+
// See VideoDetailFragment.wasCleared() and its usage in doInitialLoadLogic().
455459
final VideoDetailFragment instance = VideoDetailFragment
456-
.getInstance(serviceId, url, title, playQueue);
460+
.getInstance(serviceId, null, title, playQueue);
457461
instance.setAutoPlay(autoPlay);
458462

459463
defaultTransaction(fragmentManager)

0 commit comments

Comments
 (0)