Added comments to abstract class "Detector"

This commit is contained in:
Bastian Kohler 2023-05-25 10:19:21 +02:00
parent f9797f2dca
commit fdb0036ea6

View File

@ -1,14 +1,17 @@
package com.example.ueberwachungssystem;
import android.content.Context;
import androidx.annotation.NonNull;
abstract public class Detector {
private OnDetectionListener listener;
/** Constructor - takes context of current activity */
public Detector(Context context) {};
/** On Detection Listener - runs when violation is reported */
public interface OnDetectionListener {
void onDetection(@NonNull DetectionReport detectionReport);
}
@ -16,6 +19,8 @@ abstract public class Detector {
this.listener = listener;
}
/** Triggers onDetectionListener - call this to trigger violation/alarm */
private void reportViolation(String detectorID, String detectionType, float amplitude) {
if (listener != null) {
DetectionReport detectionReport = new DetectionReport(detectorID, detectionType, amplitude);
@ -25,6 +30,10 @@ abstract public class Detector {
}
}
/** Starts Detection (abstract method: needs to be overridden in child class) */
public abstract void startDetection();
/** Stops Detection (abstract method: needs to be overridden in child class) */
public abstract void stopDetection();
}