diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/PersonalMotionPreviewElement.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/PersonalMotionPreviewElement.java index a4af8fb..96ec533 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/PersonalMotionPreviewElement.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/PersonalMotionPreviewElement.java @@ -89,11 +89,6 @@ public class PersonalMotionPreviewElement extends View { this.exercise = exercise; this.path = exercise.getPath(); - this.motionProcessor = new MotionProcessor(qiContext); - this.motionProcessor.startListening(); - this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> { - // TODO: Implement the calculation of the `performingPath` based on the motion data - }); } /** @@ -105,6 +100,13 @@ public class PersonalMotionPreviewElement extends View { */ public void provideQiContext(QiContext context) { this.qiContext = context; + if ( this.motionProcessor != null ) + this.motionProcessor.stopListening(); + this.motionProcessor = new MotionProcessor(qiContext); + this.motionProcessor.startListening(); + this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> { + // TODO: Implement the calculation of the `performingPath` based on the motion data + }); saySomethingNice(); }