Immediately disable hr reading and activity tracking when leaving the tab #273
This commit is contained in:
parent
e87a357bed
commit
b25a47c398
|
@ -267,16 +267,12 @@ public class LiveActivityFragment extends AbstractChartFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if (pulseScheduler != null) {
|
stopActivityPulse();
|
||||||
pulseScheduler.shutdownNow();
|
|
||||||
pulseScheduler = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
pulseScheduler = startActivityPulse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledExecutorService startActivityPulse() {
|
private ScheduledExecutorService startActivityPulse() {
|
||||||
|
@ -298,6 +294,13 @@ public class LiveActivityFragment extends AbstractChartFragment {
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopActivityPulse() {
|
||||||
|
if (pulseScheduler != null) {
|
||||||
|
pulseScheduler.shutdownNow();
|
||||||
|
pulseScheduler = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called in the UI thread.
|
* Called in the UI thread.
|
||||||
*/
|
*/
|
||||||
|
@ -332,10 +335,12 @@ public class LiveActivityFragment extends AbstractChartFragment {
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
|
pulseScheduler = startActivityPulse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMadeInvisibleInActivity() {
|
protected void onMadeInvisibleInActivity() {
|
||||||
|
stopActivityPulse();
|
||||||
GBApplication.deviceService().onEnableRealtimeSteps(false);
|
GBApplication.deviceService().onEnableRealtimeSteps(false);
|
||||||
GBApplication.deviceService().onEnableRealtimeHeartRateMeasurement(false);
|
GBApplication.deviceService().onEnableRealtimeHeartRateMeasurement(false);
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
|
|
Loading…
Reference in New Issue