mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-09 08:50:34 +00:00
PlayerHolder: move unbind right next to stopService
This commit is contained in:
parent
8d15a141b1
commit
83d93e16e7
@ -162,6 +162,26 @@ public final class PlayerHolder {
|
|||||||
context.stopService(new Intent(context, PlayerService.class));
|
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 {
|
class PlayerServiceConnection implements ServiceConnection {
|
||||||
|
|
||||||
private boolean playAfterConnect = false;
|
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 =
|
private final PlayerServiceEventListener internalListener =
|
||||||
new PlayerServiceEventListener() {
|
new PlayerServiceEventListener() {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user