package com.example.ueberwachungssystem.Fragments; | |||||
import android.content.Context; | |||||
import android.content.Intent; | |||||
import android.os.Bundle; | |||||
import android.util.Log; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.ListView; | |||||
import android.widget.TextView; | |||||
import androidx.fragment.app.Fragment; | |||||
import com.example.ueberwachungssystem.MeinAdapter; | |||||
import com.example.ueberwachungssystem.R; | |||||
import java.io.File; | |||||
import java.util.Arrays; | |||||
import java.util.List; | |||||
public class Fragment2 extends Fragment { | |||||
private String text; | |||||
private Context c; | |||||
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.Aufzeichnungen); | |||||
// 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(); | |||||
c = getContext(); | |||||
ListView listView = new ListView(c); | |||||
listView.setAdapter(new MeinAdapter(c, getVideoFiles())); | |||||
if (args != null) { | |||||
text = args.getString(KEY_TEXT); | |||||
log("onCreate: text=" + text); | |||||
} else { | |||||
log("onCreate"); | |||||
} | |||||
} | |||||
public List<File> getVideoFiles(){ | |||||
File directory = c.getFilesDir(); | |||||
File[] files = directory.listFiles(); | |||||
assert files != null; | |||||
return Arrays.asList(files); | |||||
} | |||||
} |
package com.example.ueberwachungssystem.Fragments; | package com.example.ueberwachungssystem.Fragments; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.media.Image; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.util.Log; | import android.util.Log; | ||||
import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||
import android.view.View; | import android.view.View; | ||||
import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
import android.widget.ImageView; | import android.widget.ImageView; | ||||
import android.widget.ListView; | |||||
import android.widget.TextView; | |||||
import androidx.fragment.app.Fragment; | import androidx.fragment.app.Fragment; | ||||
import com.example.ueberwachungssystem.MeinAdapter; | |||||
import com.example.ueberwachungssystem.R; | import com.example.ueberwachungssystem.R; | ||||
import java.io.File; | |||||
import java.util.Arrays; | |||||
import java.util.List; | |||||
public class Fragment3 extends Fragment { | public class Fragment3 extends Fragment { | ||||
private OnImageViewReadyListener onImageViewReadyListener; | private OnImageViewReadyListener onImageViewReadyListener; |
package com.example.ueberwachungssystem.Logger; | |||||
import android.util.Log; | |||||
import android.widget.TextView; | |||||
import java.io.PrintWriter; | |||||
import java.io.StringWriter; | |||||
public class Logger { | |||||
private TextView textView; | |||||
private StringBuffer sb = new StringBuffer(); | |||||
private String tag; | |||||
public Logger(String tag, TextView textView, String logInitText) { | |||||
this.tag = tag; | |||||
this.textView = textView; | |||||
sb.append(logInitText); | |||||
} | |||||
public void log(String s) { | |||||
Log.d(tag, s); | |||||
sb.append(s).append("\n"); | |||||
if (textView != null) { | |||||
textView.setText(sb.toString()); | |||||
} | |||||
} | |||||
public void log(Exception e) { | |||||
StringWriter sw = new StringWriter(); | |||||
e.printStackTrace(new PrintWriter(sw)); | |||||
log(sw.toString()); | |||||
} | |||||
public void clearLog() { | |||||
sb.setLength(0); | |||||
if (textView != null) { | |||||
textView.setText(""); | |||||
} | |||||
} | |||||
public String getLoggedText() { | |||||
return sb.toString(); | |||||
} | |||||
} |
import android.widget.ToggleButton; | import android.widget.ToggleButton; | ||||
import com.example.ueberwachungssystem.Fragments.Fragment1; | import com.example.ueberwachungssystem.Fragments.Fragment1; | ||||
import com.example.ueberwachungssystem.Fragments.Fragment2; | |||||
import com.example.ueberwachungssystem.Detection.DetectorService; | import com.example.ueberwachungssystem.Detection.DetectorService; | ||||
import com.example.ueberwachungssystem.Fragments.Fragment3; | import com.example.ueberwachungssystem.Fragments.Fragment3; | ||||
import com.example.ueberwachungssystem.Fragments.VideoListFragment; | import com.example.ueberwachungssystem.Fragments.VideoListFragment; | ||||
private Fragment fragment3_; | private Fragment fragment3_; | ||||
private Fragment1 fragment1; | private Fragment1 fragment1; | ||||
private Fragment2 fragment2; | |||||
private Fragment3 fragment3; | private Fragment3 fragment3; | ||||
private ImageView fragmentImage; | private ImageView fragmentImage; |
package com.example.ueberwachungssystem; | |||||
import android.content.Context; | |||||
import android.util.Log; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.ArrayAdapter; | |||||
import java.io.File; | |||||
import java.util.List; | |||||
public class MeinAdapter extends ArrayAdapter<File> { | |||||
private Context context; | |||||
private File[] files; | |||||
public MeinAdapter(Context context, List<File> listf) { | |||||
super(context, android.R.layout.simple_list_item_1, listf); | |||||
this.context = context; | |||||
} | |||||
@Override | |||||
public View getView(final int pos, View cv, ViewGroup vg) { | |||||
View v = super.getView(pos, cv, vg); | |||||
v.setOnClickListener( new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
Log.d("DerLog","nicht null"); | |||||
} | |||||
}); | |||||
return v; | |||||
} | |||||
} |