Fix bug allowing computer polling to continue when the stream is resumed from the PcView activity

This commit is contained in:
Cameron Gutman 2015-10-15 00:55:05 -07:00
parent 5f13b9bca4
commit 4b92b8f714

View File

@ -53,7 +53,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
private RelativeLayout noPcFoundLayout; private RelativeLayout noPcFoundLayout;
private PcGridAdapter pcGridAdapter; private PcGridAdapter pcGridAdapter;
private ComputerManagerService.ComputerManagerBinder managerBinder; private ComputerManagerService.ComputerManagerBinder managerBinder;
private boolean freezeUpdates, runningPolling; private boolean freezeUpdates, runningPolling, hasResumed;
private final ServiceConnection serviceConnection = new ServiceConnection() { private final ServiceConnection serviceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder binder) { public void onServiceConnected(ComponentName className, IBinder binder) {
final ComputerManagerService.ComputerManagerBinder localBinder = final ComputerManagerService.ComputerManagerBinder localBinder =
@ -215,6 +215,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
hasResumed = true;
startComputerUpdates(); startComputerUpdates();
} }
@ -222,6 +223,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
hasResumed = false;
stopComputerUpdates(false); stopComputerUpdates(false);
} }
@ -268,7 +270,11 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
@Override @Override
public void onContextMenuClosed(Menu menu) { public void onContextMenuClosed(Menu menu) {
startComputerUpdates(); // For some reason, this gets called again _after_ onPause() is called on this activity.
// We don't want to start computer updates again, so we need to keep track of whether we're paused.
if (hasResumed) {
startComputerUpdates();
}
} }
private void doPair(final ComputerDetails computer) { private void doPair(final ComputerDetails computer) {