Unify all ways of opening VideoDetailFragment
This commit is contained in:
parent
f4435f9031
commit
1d42e45d78
13 changed files with 201 additions and 328 deletions
|
|
@ -367,7 +367,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
final MenuItem detail = popupMenu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, 1,
|
||||
Menu.NONE, R.string.play_queue_stream_detail);
|
||||
detail.setOnMenuItemClickListener(menuItem -> {
|
||||
onOpenDetail(item.getServiceId(), item.getUrl(), item.getTitle());
|
||||
// playQueue is null since we don't want any queue change
|
||||
NavigationHelper.openVideoDetail(
|
||||
this, item.getServiceId(), item.getUrl(), item.getTitle(), null);
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
@ -454,11 +456,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
};
|
||||
}
|
||||
|
||||
private void onOpenDetail(final int serviceId, final String videoUrl,
|
||||
final String videoTitle) {
|
||||
NavigationHelper.openVideoDetail(this, serviceId, videoUrl, videoTitle);
|
||||
}
|
||||
|
||||
private void scrollToSelected() {
|
||||
if (player == null) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -785,7 +785,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||
intent.putExtra(Constants.KEY_LINK_TYPE, StreamingService.LinkType.STREAM);
|
||||
intent.putExtra(Constants.KEY_URL, getVideoUrl());
|
||||
intent.putExtra(Constants.KEY_TITLE, getVideoTitle());
|
||||
intent.putExtra(VideoDetailFragment.AUTO_PLAY, true);
|
||||
intent.putExtra(VideoDetailFragment.KEY_SWITCHING_PLAYERS, true);
|
||||
service.onDestroy();
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
package org.schabi.newpipe.player.playqueue;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.reactivestreams.Subscriber;
|
||||
import org.reactivestreams.Subscription;
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.player.playqueue.events.AppendEvent;
|
||||
import org.schabi.newpipe.player.playqueue.events.ErrorEvent;
|
||||
|
|
@ -43,7 +39,6 @@ import io.reactivex.subjects.BehaviorSubject;
|
|||
* </p>
|
||||
*/
|
||||
public abstract class PlayQueue implements Serializable {
|
||||
private final String TAG = "PlayQueue@" + Integer.toHexString(hashCode());
|
||||
public static final boolean DEBUG = MainActivity.DEBUG;
|
||||
|
||||
private ArrayList<PlayQueueItem> backup;
|
||||
|
|
@ -55,7 +50,6 @@ public abstract class PlayQueue implements Serializable {
|
|||
|
||||
private transient BehaviorSubject<PlayQueueEvent> eventBroadcast;
|
||||
private transient Flowable<PlayQueueEvent> broadcastReceiver;
|
||||
private transient Subscription reportingReactor;
|
||||
|
||||
private transient boolean disposed;
|
||||
|
||||
|
|
@ -87,10 +81,6 @@ public abstract class PlayQueue implements Serializable {
|
|||
broadcastReceiver = eventBroadcast.toFlowable(BackpressureStrategy.BUFFER)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.startWith(new InitEvent());
|
||||
|
||||
if (DEBUG) {
|
||||
broadcastReceiver.subscribe(getSelfReporter());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -100,13 +90,9 @@ public abstract class PlayQueue implements Serializable {
|
|||
if (eventBroadcast != null) {
|
||||
eventBroadcast.onComplete();
|
||||
}
|
||||
if (reportingReactor != null) {
|
||||
reportingReactor.cancel();
|
||||
}
|
||||
|
||||
eventBroadcast = null;
|
||||
broadcastReceiver = null;
|
||||
reportingReactor = null;
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
|
|
@ -544,35 +530,5 @@ public abstract class PlayQueue implements Serializable {
|
|||
eventBroadcast.onNext(event);
|
||||
}
|
||||
}
|
||||
|
||||
private Subscriber<PlayQueueEvent> getSelfReporter() {
|
||||
return new Subscriber<PlayQueueEvent>() {
|
||||
@Override
|
||||
public void onSubscribe(final Subscription s) {
|
||||
if (reportingReactor != null) {
|
||||
reportingReactor.cancel();
|
||||
}
|
||||
reportingReactor = s;
|
||||
reportingReactor.request(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(final PlayQueueEvent event) {
|
||||
Log.d(TAG, "Received broadcast: " + event.type().name() + ". "
|
||||
+ "Current index: " + getIndex() + ", play queue length: " + size() + ".");
|
||||
reportingReactor.request(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(final Throwable t) {
|
||||
Log.e(TAG, "Received broadcast error", t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.d(TAG, "Broadcast is shutting down.");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue