mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-27 03:14:30 +00:00
A couple tweaks to ensure clients are properly disconnected when the
device sleeps -- this prevents unnecessary auto-reconnects.
This commit is contained in:
parent
2a7dbf4089
commit
c8497f9524
@ -48,9 +48,15 @@ public class PlayQueueActivity extends WebSocketActivityBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
this.tracks.destroy();
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
this.tracks.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
this.tracks.resume(); /* needs to happen before */
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,9 +65,15 @@ public class TrackListActivity extends WebSocketActivityBase implements Filterab
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
this.tracks.destroy();
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
this.tracks.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
this.tracks.resume(); /* needs to happen before */
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,9 +52,6 @@ public class TrackListScrollCache<TrackType> {
|
||||
this.wss = wss;
|
||||
this.queryFactory = queryFactory;
|
||||
this.mapper = mapper;
|
||||
|
||||
this.recyclerView.addOnScrollListener(scrollListener);
|
||||
this.wss.addClient(this.client);
|
||||
}
|
||||
|
||||
public void requery() {
|
||||
@ -72,11 +69,16 @@ public class TrackListScrollCache<TrackType> {
|
||||
});
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
public void pause() {
|
||||
this.recyclerView.removeOnScrollListener(scrollListener);
|
||||
this.wss.removeClient(this.client);
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
this.recyclerView.addOnScrollListener(scrollListener);
|
||||
this.wss.addClient(this.client);
|
||||
}
|
||||
|
||||
public void setInitialPosition(int initialIndex) {
|
||||
this.initialPosition = initialIndex;
|
||||
}
|
||||
|
@ -331,8 +331,11 @@ public class WebSocketService {
|
||||
disconnect(autoReconnect);
|
||||
handler.removeMessages(MESSAGE_AUTO_RECONNECT);
|
||||
setState(State.Connecting);
|
||||
thread = new ConnectThread();
|
||||
thread.start();
|
||||
|
||||
if (this.clients.size() > 0) {
|
||||
thread = new ConnectThread();
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user