Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
fixed unnecessary updates by the PresenceDetector
Browse files Browse the repository at this point in the history
  • Loading branch information
pLeminoq authored and DivineThreepwood committed Jan 11, 2017
1 parent 91baab2 commit c781603
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public PresenceDetector() {
public void expired() {
try {
// if motion is still detected just restart the timeout.
if(locationDataProvider.getData().getMotionState().getValue() == MotionState.State.MOTION) {
if (locationDataProvider.getData().getMotionState().getValue() == MotionState.State.MOTION) {
GlobalCachedExecutorService.submit(new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -145,9 +145,11 @@ private synchronized void updatePresenceState(final PresenceStateOrBuilder prese
presenceTimeout.restart();
this.presenceState.getLastPresenceBuilder().setTime(Math.max(this.presenceState.getLastPresence().getTime(), presenceState.getLastPresence().getTime()));
}


// update value
if (!(this.presenceState.getValue() == presenceState.getValue())) {
return;
}
this.presenceState.getTimestampBuilder().setTime(System.currentTimeMillis());
this.presenceState.setValue(presenceState.getValue());

Expand Down

0 comments on commit c781603

Please sign in to comment.