Refactor in DetectorService class

This commit is contained in:
Bastian Kohler 2023-06-19 14:41:41 +02:00
parent 0ee1446cbc
commit 7dee124378

View File

@ -1,19 +1,13 @@
package com.example.ueberwachungssystem.Detection; package com.example.ueberwachungssystem.Detection;
import android.Manifest;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Binder; import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log;
import android.widget.ImageView; import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.camera.core.ExperimentalGetImage; import androidx.camera.core.ExperimentalGetImage;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleService; import androidx.lifecycle.LifecycleService;
import java.io.File; import java.io.File;
@ -21,7 +15,7 @@ import java.io.File;
@ExperimentalGetImage @ExperimentalGetImage
public class DetectorService extends LifecycleService { public class DetectorService extends LifecycleService {
public TestBinder testBinder = new TestBinder(); public ServiceBinder serviceBinder = new ServiceBinder();
private DetectorService.OnDetectionListener listener; private DetectorService.OnDetectionListener listener;
private boolean isServiceRunning = false; private boolean isServiceRunning = false;
@ -56,7 +50,7 @@ public class DetectorService extends LifecycleService {
} }
/** Service methods */ /** Service methods */
public class TestBinder extends Binder { public class ServiceBinder extends Binder {
public DetectorService getBoundService() { public DetectorService getBoundService() {
// Return an instance of the TestService // Return an instance of the TestService
return DetectorService.this; return DetectorService.this;
@ -66,7 +60,7 @@ public class DetectorService extends LifecycleService {
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
super.onBind(intent); super.onBind(intent);
return testBinder; return serviceBinder;
} }