added logging

This commit is contained in:
2024-05-29 15:12:27 +02:00
parent ea9a35030b
commit 49eb09b105

View File

@@ -102,20 +102,24 @@ public class PersonalMotionPreviewElement extends View {
* @param context The QiContext to provide. * @param context The QiContext to provide.
*/ */
public void provideQiContext(QiContext context) { public void provideQiContext(QiContext context) {
this.qiContext = context; try {
if ( this.motionProcessor != null ) this.qiContext = context;
this.motionProcessor.stopListening(); if (this.motionProcessor != null)
this.motionProcessor.stopListening();
this.motionProcessor = new MotionProcessor(); this.motionProcessor = new MotionProcessor();
this.motionProcessor.startListening(); this.motionProcessor.startListening();
// Handler that is called every time the motion processor receives new data. // Handler that is called every time the motion processor receives new data.
this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> { this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> {
int progress = (int)this.motionProcessor.getError(this.paths[0], processed); int progress = (int) this.motionProcessor.getError(this.paths[0], processed);
this.exerciseProgress.set(Math.min(1000, Math.max(0, progress))); this.exerciseProgress.set(Math.min(1000, Math.max(0, progress)));
Log.i("MotionProcessor", "Processed data: " + progress + " (" + preprocessed + ")"); Log.i("MotionProcessor", "Processed data: " + progress + " (" + preprocessed + ")");
}); });
saySomethingNice(); saySomethingNice();
} catch (Exception e) {
Log.e("MotionProcessor", "An error occurred whilst attempting to provide QiContext:" + e.getMessage());
}
} }
/** /**