Skip to content

Commit 83d93e1

Browse files
committed
PlayerHolder: move unbind right next to stopService
1 parent 8d15a14 commit 83d93e1

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,26 @@ public void stopService() {
162162
context.stopService(new Intent(context, PlayerService.class));
163163
}
164164

165+
166+
private void unbind(final Context context) {
167+
if (DEBUG) {
168+
Log.d(TAG, "unbind() called");
169+
}
170+
171+
if (bound) {
172+
context.unbindService(serviceConnection);
173+
bound = false;
174+
if (player != null) {
175+
player.removeFragmentListener(internalListener);
176+
}
177+
playerService = null;
178+
player = null;
179+
if (listener != null) {
180+
listener.onServiceDisconnected();
181+
}
182+
}
183+
}
184+
165185
class PlayerServiceConnection implements ServiceConnection {
166186

167187
private boolean playAfterConnect = false;
@@ -195,25 +215,6 @@ public void onServiceConnected(final ComponentName compName, final IBinder servi
195215
}
196216
}
197217

198-
private void unbind(final Context context) {
199-
if (DEBUG) {
200-
Log.d(TAG, "unbind() called");
201-
}
202-
203-
if (bound) {
204-
context.unbindService(serviceConnection);
205-
bound = false;
206-
if (player != null) {
207-
player.removeFragmentListener(internalListener);
208-
}
209-
playerService = null;
210-
player = null;
211-
if (listener != null) {
212-
listener.onServiceDisconnected();
213-
}
214-
}
215-
}
216-
217218
private final PlayerServiceEventListener internalListener =
218219
new PlayerServiceEventListener() {
219220
@Override

0 commit comments

Comments
 (0)