Updated PersonalMotionPreviewElement (previously SportPreviewCanvas)

This commit is contained in:
Luca Warmenhoven
2024-05-14 14:15:12 +02:00
parent b7459f531b
commit 490a97ae78
2 changed files with 43 additions and 44 deletions

View File

@@ -0,0 +1,43 @@
package com.example.fitbot.ui.components;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.view.View;
import com.example.fitbot.util.processing.GesturePath;
import com.example.fitbot.util.processing.MotionData;
import com.example.fitbot.util.processing.MotionProcessor;
import com.example.fitbot.util.processing.Vector3;
public class PersonalMotionPreviewElement extends View {
private GesturePath path;
private double pathTime = 0.0D; // The timestamp at which the path is currently at.
private MotionProcessor motionProcessor;
private Path targetPath, personalPath;
/**
* Method that calculates the path that will be drawn on the
* canvas. This method will be called every time new motion data is received.
*/
private void calculateDrawingPath(Vector3 transformedVector, MotionData motionData, int sampleIndex, double sampleRate) {
}
public PersonalMotionPreviewElement(Context context, GesturePath path) {
super(context);
this.path = path;
this.motionProcessor = new MotionProcessor();
this.motionProcessor.startListening();
this.motionProcessor.setMotionDataEventHandler(this::calculateDrawingPath);
this.targetPath = new Path();
this.personalPath = new Path();
}
@Override
public void onDraw(Canvas canvas) {
// Draw the sport preview canvas
}
}

View File

@@ -1,44 +0,0 @@
package com.example.fitbot.ui.components;
import android.content.Context;
import android.graphics.Canvas;
import android.view.View;
import com.example.fitbot.util.processing.GesturePath;
import com.example.fitbot.util.processing.MotionProcessor;
public class SportPreviewCanvas extends View {
private GesturePath path;
private double pathTime = 0.0D; // The timestamp at which the path is currently at.
private MotionProcessor motionProcessor;
/**
* Method that recalculates the path that will be drawn on the
* screen.
*/
private void calculateDrawingPath() {
}
public SportPreviewCanvas(Context context, GesturePath path) {
super(context);
this.path = path;
this.motionProcessor = new MotionProcessor();
this.motionProcessor.startListening();
// Add the event handler
this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate) -> {
calculateDrawingPath();
});
}
@Override
public void onDraw(Canvas canvas) {
// Draw the sport preview canvas
}
}