removed Fragment classes from MainActivity
This commit is contained in:
parent
44e056b5fe
commit
746eec18ba
@ -0,0 +1,48 @@
|
|||||||
|
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 Fragment1 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.fragment1, container, false);
|
||||||
|
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
||||||
|
Sensor.setText(text);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
public static Fragment1 erstellen(String text) {
|
||||||
|
Fragment1 fragment = new Fragment1();
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
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 Fragment2 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 Fragment2 erstellen(String text) {
|
||||||
|
Fragment2 fragment = new Fragment2();
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,11 +20,19 @@ import android.widget.ToggleButton;
|
|||||||
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
||||||
import com.example.ueberwachungssystem.Detection.Detector;
|
import com.example.ueberwachungssystem.Detection.Detector;
|
||||||
import com.example.ueberwachungssystem.Detection.VideoDetector;
|
import com.example.ueberwachungssystem.Detection.VideoDetector;
|
||||||
|
import com.example.ueberwachungssystem.Fragments.Fragment1;
|
||||||
|
import com.example.ueberwachungssystem.Fragments.Fragment2;
|
||||||
|
import com.example.ueberwachungssystem.Fragments.Fragment3;
|
||||||
|
|
||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@ExperimentalGetImage
|
||||||
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
|
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
private Fragment aktuellesFragment;
|
private Fragment aktuellesFragment;
|
||||||
|
private Fragment1 fragment1;
|
||||||
|
private Fragment2 fragment2;
|
||||||
|
private Fragment3 fragment3;
|
||||||
|
|
||||||
WifiCommunication communication;
|
WifiCommunication communication;
|
||||||
private TextView alarm;
|
private TextView alarm;
|
||||||
private String text = "Das ist ein Alarm des Sensors";
|
private String text = "Das ist ein Alarm des Sensors";
|
||||||
@ -84,18 +92,18 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||||||
public void onClickZeigeFragment1(View view) {
|
public void onClickZeigeFragment1(View view) {
|
||||||
Button button = (Button) view;
|
Button button = (Button) view;
|
||||||
log(button.getText() + " ausgewählt");
|
log(button.getText() + " ausgewählt");
|
||||||
zeigeFragment(Fragment1.erstellen("Fragment 1 wurde angeklickt"));
|
zeigeFragment(fragment1.erstellen("Fragment 1 wurde angeklickt"));
|
||||||
}
|
}
|
||||||
public void onClickZeigeFragment2(View view) {
|
public void onClickZeigeFragment2(View view) {
|
||||||
Button button = (Button) view;
|
Button button = (Button) view;
|
||||||
log(button.getText() + " ausgewählt");
|
log(button.getText() + " ausgewählt");
|
||||||
zeigeFragment(Fragment2.erstellen("Fragment 2 wurde angeklickt"));
|
zeigeFragment(fragment2.erstellen("Fragment 2 wurde angeklickt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClickZeigeFragment3(View view) {
|
public void onClickZeigeFragment3(View view) {
|
||||||
Button button = (Button) view;
|
Button button = (Button) view;
|
||||||
log(button.getText() + " ausgewählt");
|
log(button.getText() + " ausgewählt");
|
||||||
zeigeFragment(Fragment3.erstellen("Fragment 3 wurde angeklickt"));
|
zeigeFragment(fragment3.erstellen("Fragment 3 wurde angeklickt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClickEntferneFragment(View view) {
|
public void onClickEntferneFragment(View view) {
|
||||||
@ -115,106 +123,4 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||||||
aktuellesFragment = null ;
|
aktuellesFragment = null ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class Fragment1 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.fragment1, container, false);
|
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
|
||||||
Sensor.setText(text);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
public static Fragment1 erstellen(String text) {
|
|
||||||
Fragment1 fragment = new Fragment1();
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class Fragment2 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 Fragment2 erstellen(String text) {
|
|
||||||
Fragment2 fragment = new Fragment2();
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user