@@ -54,7 +54,6 @@ public class DetectorService extends LifecycleService { | |||
passToServiceListener(stringBufferWifi); | |||
checkState(data); | |||
checkTyp(data); | |||
} | |||
}); | |||
@@ -1,53 +0,0 @@ | |||
package com.example.ueberwachungssystem.Fragments; | |||
import android.content.Context; | |||
import android.os.Bundle; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.ListView; | |||
import android.widget.Toast; | |||
import androidx.fragment.app.Fragment; | |||
import com.example.ueberwachungssystem.R; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class VideoFileFragment extends Fragment { | |||
private ListView listView; | |||
private ArrayAdapter<String> adapter; | |||
@Override | |||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |||
View rootView = inflater.inflate(R.layout.video_file_fragment, container, false); | |||
listView = rootView.findViewById(R.id.listView); | |||
adapter = new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, getData()); | |||
listView.setAdapter(adapter); | |||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |||
@Override | |||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |||
// Handle item click event here | |||
String selectedItem = adapter.getItem(position); | |||
Toast.makeText(requireContext(), selectedItem, Toast.LENGTH_SHORT).show(); | |||
} | |||
}); | |||
return rootView; | |||
} | |||
private List<String> getData() { | |||
// Add your data source here, e.g., an array or a list | |||
List<String> data = new ArrayList<>(); | |||
data.add("Item 1"); | |||
data.add("Item 2"); | |||
data.add("Item 3"); | |||
return data; | |||
} | |||
} |
@@ -0,0 +1,87 @@ | |||
package com.example.ueberwachungssystem.Fragments; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.Gravity; | |||
import android.view.LayoutInflater; | |||
import android.view.MotionEvent; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.ListView; | |||
import android.widget.PopupWindow; | |||
import android.widget.Toast; | |||
import android.widget.VideoView; | |||
import androidx.fragment.app.Fragment; | |||
import com.example.ueberwachungssystem.R; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class VideoListFragment extends Fragment { | |||
private ListView listView; | |||
private ArrayAdapter<String> adapter; | |||
@Override | |||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |||
View rootView = inflater.inflate(R.layout.videolist_fragment, container, false); | |||
listView = rootView.findViewById(R.id.listView); | |||
adapter = new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, getFileNames()); | |||
listView.setAdapter(adapter); | |||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |||
@Override | |||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |||
// Handle item click event here | |||
String selectedItem = getContext().getFilesDir().toString() + "/" + adapter.getItem(position); | |||
//Toast.makeText(requireContext(), selectedItem, Toast.LENGTH_SHORT).show(); | |||
openVideoPopup(selectedItem); | |||
} | |||
}); | |||
return rootView; | |||
} | |||
private List<String> getFileNames() { | |||
// Add your data source here, e.g., an array or a list | |||
File dir = getContext().getFilesDir(); | |||
File[] files = dir.listFiles(); | |||
Log.d("files", getContext().getFilesDir().toString()); | |||
List<String> fileNamesList = new ArrayList<>(); | |||
assert files != null; | |||
for (File file : files) { | |||
fileNamesList.add(file.getName()); | |||
} | |||
return fileNamesList; | |||
} | |||
private void openVideoPopup(String videoPath) { | |||
LayoutInflater inflater = LayoutInflater.from(requireContext()); | |||
View popupView = inflater.inflate(R.layout.videolist_popup, null); | |||
VideoView videoView = popupView.findViewById(R.id.videoView); | |||
videoView.setVideoPath(videoPath); | |||
videoView.start(); | |||
PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true); | |||
popupView.setOnTouchListener(new View.OnTouchListener() { | |||
@Override | |||
public boolean onTouch(View v, MotionEvent event) { | |||
//Close the window when clicked | |||
popupWindow.dismiss(); | |||
return true; | |||
} | |||
}); | |||
popupWindow.showAtLocation(listView, Gravity.CENTER, 0, 0); | |||
} | |||
} |
@@ -2,7 +2,6 @@ package com.example.ueberwachungssystem; | |||
import androidx.camera.core.ExperimentalGetImage; | |||
import androidx.fragment.app.Fragment; | |||
import androidx.fragment.app.FragmentManager; | |||
import androidx.fragment.app.FragmentTransaction; | |||
import androidx.annotation.NonNull; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
@@ -17,10 +16,7 @@ import android.util.Log; | |||
import android.view.Menu; | |||
import android.view.MenuItem; | |||
import android.view.View; | |||
import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.Button; | |||
import android.widget.ListView; | |||
import android.widget.TextView; | |||
import android.widget.Toast; | |||
import android.widget.ToggleButton; | |||
@@ -29,9 +25,7 @@ import com.example.ueberwachungssystem.Fragments.Fragment1; | |||
import com.example.ueberwachungssystem.Fragments.Fragment2; | |||
import com.example.ueberwachungssystem.Detection.DetectorService; | |||
import com.example.ueberwachungssystem.Fragments.Fragment3; | |||
import com.example.ueberwachungssystem.Fragments.VideoFileFragment; | |||
import java.util.ArrayList; | |||
import com.example.ueberwachungssystem.Fragments.VideoListFragment; | |||
@ExperimentalGetImage | |||
public class MainActivity extends AppCompatActivity { | |||
@@ -43,7 +37,7 @@ public class MainActivity extends AppCompatActivity { | |||
private Fragment1 fragment1; | |||
private Fragment2 fragment2; | |||
private Fragment3 fragment3; | |||
private VideoFileFragment videoFileFragment = new VideoFileFragment(); | |||
private VideoListFragment videoListFragment = new VideoListFragment(); | |||
private DetectorService detectorService = new DetectorService(); | |||
int num = 0; | |||
//Textviews | |||
@@ -194,7 +188,7 @@ public class MainActivity extends AppCompatActivity { | |||
public void onClickZeigeFragment2(View view) { | |||
Button button = (Button) view; | |||
//zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos")); | |||
zeigeFragment(videoFileFragment); | |||
zeigeFragment(videoListFragment); | |||
} | |||
public void onClickZeigeFragment3(View view) { | |||
Button button = (Button) view; |
@@ -1,53 +0,0 @@ | |||
package com.example.ueberwachungssystem; | |||
import android.content.Context; | |||
import android.os.Bundle; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.TextView; | |||
import androidx.annotation.NonNull; | |||
import java.util.List; | |||
public class VideoAdapter extends ArrayAdapter<String> { | |||
private List<String> fileList; | |||
private OnFileClickListener listener; | |||
public VideoAdapter (Context context, List<String> fileList, OnFileClickListener listener) { | |||
super(context, 0, fileList); | |||
this.fileList = fileList; | |||
this.listener = listener; | |||
} | |||
@Override | |||
public View getView(final int position, View convertView, ViewGroup parent) { | |||
if (convertView == null) { | |||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_file, parent, false); | |||
} | |||
TextView fileNameText = convertView.findViewById(R.id.file_name_text); | |||
final String fileName = fileList.get(position); | |||
fileNameText.setText(fileName); | |||
convertView.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View v) { | |||
listener.onFileClick(fileName); | |||
listener.onFileClick(fileName); | |||
} | |||
}); | |||
return convertView; | |||
} | |||
public interface OnFileClickListener { | |||
View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
Bundle savedInstanceState); | |||
void onFileClick(String fileName); | |||
} | |||
} |
@@ -1,17 +0,0 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<!-- list_item_file.xml --> | |||
<TextView | |||
xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:id="@+id/file_name_text" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:textSize="16sp" | |||
android:padding="8dp" | |||
tools:ignore="MissingConstraints" /> | |||
</androidx.constraintlayout.widget.ConstraintLayout> |
@@ -0,0 +1,13 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:paddingVertical="100dp"> | |||
<VideoView | |||
android:id="@+id/videoView" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_gravity="center_vertical"/> | |||
</FrameLayout> |