- removed fragments - removed unnecessary classes - removed unnecessary codeprepareMaster
Bundle args = getArguments(); | Bundle args = getArguments(); | ||||
c = getContext(); | c = getContext(); | ||||
ListView listView = new ListView(c); | ListView listView = new ListView(c); | ||||
setContentView(R.layout.fragment2); | |||||
listView.setAdapter(new MeinAdapter(c, getVideoFiles())); | listView.setAdapter(new MeinAdapter(c, getVideoFiles())); | ||||
if (args != null) { | if (args != null) { | ||||
text = args.getString(KEY_TEXT); | text = args.getString(KEY_TEXT); |
package com.example.ueberwachungssystem.Fragments; | |||||
import android.os.Bundle; | |||||
import android.util.Log; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.TextView; | |||||
import androidx.fragment.app.Fragment; | |||||
import com.example.ueberwachungssystem.R; | |||||
public class Fragment3 extends Fragment { | |||||
private String text; | |||||
private final static String KEY_TEXT = "KEY_TEXT" ; | |||||
private void log(String nachricht) { | |||||
Log.d(this.getClass().getSimpleName(), nachricht); | |||||
} | |||||
@Override | |||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { | |||||
log( "onCreateView" ); | |||||
View view = inflater.inflate(R.layout.fragment2, container, false ); | |||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor); | |||||
Sensor.setText(text); | |||||
return view; | |||||
} | |||||
public static Fragment3 erstellen(String text) { | |||||
Fragment3 fragment = new Fragment3(); | |||||
Bundle b = new Bundle(); | |||||
b.putString(KEY_TEXT, text); | |||||
fragment.setArguments(b); | |||||
return fragment; | |||||
} | |||||
@Override | |||||
public void onCreate(Bundle bundle) { | |||||
super.onCreate(bundle); | |||||
Bundle args = getArguments(); | |||||
if (args != null) { | |||||
text = args.getString(KEY_TEXT); | |||||
log("onCreate: text=" + text); | |||||
} else { | |||||
log("onCreate"); | |||||
} | |||||
} | |||||
} |
private TextView AoderA; | private TextView AoderA; | ||||
private String auswahltext = "Wahl des Detektionsmodus"; | private String auswahltext = "Wahl des Detektionsmodus"; | ||||
private String auswahlAoderA = "Wahl von Alarmmeldungen oder Auswahl von Alarmaufzeichnungen"; | private String auswahlAoderA = "Wahl von Alarmmeldungen oder Auswahl von Alarmaufzeichnungen"; | ||||
//Sensoren und Kommunikation | |||||
WifiCommunication communication; | |||||
//Buttons | //Buttons | ||||
private ToggleButton toggleKamera; | private ToggleButton toggleKamera; | ||||
private ToggleButton toggleAudio; | private ToggleButton toggleAudio; | ||||
private ToggleButton toggleBewegung; | private ToggleButton toggleBewegung; | ||||
//Überprüfungswerte | |||||
boolean wahr; | |||||
private void log(String nachricht) { | |||||
Log.d(this.getClass().getSimpleName(), nachricht); | |||||
} | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
if (v == toggleKamera) { | if (v == toggleKamera) { | ||||
if (toggleKamera.isChecked()) { | if (toggleKamera.isChecked()) { | ||||
wahr = true; | |||||
} else { | } else { | ||||
wahr = false; | |||||
} | } | ||||
} | } | ||||
if (v == toggleAudio) { | if (v == toggleAudio) { | ||||
if (toggleAudio.isChecked()) { | if (toggleAudio.isChecked()) { | ||||
wahr = true; | |||||
} else { | } else { | ||||
wahr = false; | |||||
} | } | ||||
} | } | ||||
if (v == toggleBewegung) { | if (v == toggleBewegung) { | ||||
if (toggleBewegung.isChecked()) { | if (toggleBewegung.isChecked()) { | ||||
wahr = true; | |||||
} else { | } else { | ||||
wahr = false; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@Override | |||||
protected void onPause() { | |||||
super.onPause(); | |||||
communication.stopCommunication(); | |||||
} | |||||
@Override | |||||
protected void onResume() { | |||||
super.onResume(); | |||||
communication = new WifiCommunication(1234); | |||||
} | |||||
public void onClickZeigeFragment1(View view) { | public void onClickZeigeFragment1(View view) { | ||||
Button button = (Button) view; | Button button = (Button) view; | ||||
log(button.getText() + " ausgewählt"); | |||||
zeigeFragment(fragment1.erstellen("Hier stehen dann die Alarme")); | zeigeFragment(fragment1.erstellen("Hier stehen dann die Alarme")); | ||||
} | } | ||||
public void onClickZeigeFragment2(View view) { | public void onClickZeigeFragment2(View view) { | ||||
Button button = (Button) view; | Button button = (Button) view; | ||||
log(button.getText() + " ausgewählt"); | |||||
zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos")); | zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos")); | ||||
} | } | ||||
package com.example.ueberwachungssystem; | |||||
import android.content.Context; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.ImageView; | |||||
import android.widget.TextView; | |||||
import java.io.File; | |||||
import java.util.List; | |||||
public class VideoListAdapter extends ArrayAdapter<File> { | |||||
public VideoListAdapter(Context context, List<File> videoList) { | |||||
super(context, 0, videoList); | |||||
} | |||||
@Override | |||||
public View getView(int position, View convertView, ViewGroup parent) { | |||||
if (convertView == null) { | |||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_video, parent, false); | |||||
} | |||||
File videoFile = getItem(position); | |||||
ImageView thumbnailImageView = convertView.findViewById(R.id.imageViewThumbnail); | |||||
TextView titleTextView = convertView.findViewById(R.id.textViewTitle); | |||||
// Set tag to identify the clicked item | |||||
convertView.setTag(videoFile.getAbsolutePath()); | |||||
return convertView; | |||||
} | |||||
} |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent"> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:gravity="center_horizontal" | |||||
android:orientation="vertical" | |||||
android:background="@android:color/holo_blue_light" > | |||||
<TextView | |||||
android:id="@+id/Sensor" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:textAppearance="?android:attr/textAppearanceLarge"/> | |||||
<TextView | |||||
android:id="@+id/Alarm" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_below="@id/Sensor" | |||||
android:textAppearance="?android:attr/textAppearanceLarge"/> | |||||
</LinearLayout> |