1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-01-08 16:30:34 +00:00

PlayerHolder: move unbind right next to stopService

This commit is contained in:
Profpatsch 2024-12-26 00:36:49 +01:00
parent 8d15a141b1
commit 83d93e16e7

View File

@ -162,6 +162,26 @@ public final class PlayerHolder {
context.stopService(new Intent(context, PlayerService.class));
}
private void unbind(final Context context) {
if (DEBUG) {
Log.d(TAG, "unbind() called");
}
if (bound) {
context.unbindService(serviceConnection);
bound = false;
if (player != null) {
player.removeFragmentListener(internalListener);
}
playerService = null;
player = null;
if (listener != null) {
listener.onServiceDisconnected();
}
}
}
class PlayerServiceConnection implements ServiceConnection {
private boolean playAfterConnect = false;
@ -195,25 +215,6 @@ public final class PlayerHolder {
}
}
private void unbind(final Context context) {
if (DEBUG) {
Log.d(TAG, "unbind() called");
}
if (bound) {
context.unbindService(serviceConnection);
bound = false;
if (player != null) {
player.removeFragmentListener(internalListener);
}
playerService = null;
player = null;
if (listener != null) {
listener.onServiceDisconnected();
}
}
}
private final PlayerServiceEventListener internalListener =
new PlayerServiceEventListener() {
@Override