import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ListView;
+
+import java.util.ArrayList;
+import java.util.Date;
import de.dhbwloe.campusapp.CampusAppFragment;
import de.dhbwloe.campusapp.R;
+import de.dhbwloe.campusapp.vorlesungen.CourseEvent;
+import de.dhbwloe.campusapp.vorlesungen.CourseGroup;
/**
* A simple {@link Fragment} subclass.
*/
public class VorlesungsplanExams extends CampusAppFragment implements Vorlesungsplan.VorlesungsplanFragment {
-
+ private String coursename;
+ private View view;
+ private VorlesungsplanExamsListAdapter listAdapter;
+ private ArrayList<VorlesungsplanExamsListItem> listItems = new ArrayList<VorlesungsplanExamsListItem>();
public VorlesungsplanExams() {
// Required empty public constructor
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.fragment_vorlesungsplan_exams, container, false);
+ String kursTag = AppContext.getDatabaseManager().getRuntimeCache("CourseName");
+ if(kursTag == null || kursTag.isEmpty())
+ return null;
+ coursename = kursTag;
+
+ view = inflater.inflate(R.layout.fragment_vorlesungsplan_exams, container, false);
+
+ ListView listView = (ListView) view.findViewById(R.id.listView);
+ listAdapter = new VorlesungsplanExamsListAdapter(view.getContext(), R.layout.fragment_vorlesungsplan_exams_exam, listItems);
+ listView.setAdapter(listAdapter);
+
+ return view;
}
@Override
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ if(coursename != null)
+ updateCoursesList();
+ }
+
+ private void updateCoursesList() {
+ long now = (new Date()).getTime()/1000;
+
+ CourseEvent[] events = AppContext.getDatabaseManager().getCourseExamEvents(coursename, now, now + (86400 * 30 * 3)); // next 3 month
+ listItems.clear();
+ for(CourseEvent event : events) {
+
+ VorlesungsplanExamsListItem item = new VorlesungsplanExamsListItem(
+ event.getEventId(),
+ coursename,
+ event.getEventTitle(),
+ event.getEventFrom(),
+ event.getEventTo(),
+ 1
+ );
+ listItems.add(item);
+ }
+ if(listAdapter != null)
+ listAdapter.notifyDataSetChanged();
+ }
+
}