X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fde%2Fdhbwloe%2Fcampusapp%2Ffragments%2FVorlesungsplanExams.java;h=0e3cf588e3daa48cc37511a7a44b6d475b263e1e;hb=48e758721a39298a85c69ecc7267f3daf6993e78;hp=9dc6c02472a25d3ea9831dff8cdd1dde4b64ee4e;hpb=9a28e7b4c1520f629721693a04b4978fec9692e7;p=DHBWCampusApp.git
diff --git a/app/src/main/java/de/dhbwloe/campusapp/fragments/VorlesungsplanExams.java b/app/src/main/java/de/dhbwloe/campusapp/fragments/VorlesungsplanExams.java
index 9dc6c02..0e3cf58 100644
--- a/app/src/main/java/de/dhbwloe/campusapp/fragments/VorlesungsplanExams.java
+++ b/app/src/main/java/de/dhbwloe/campusapp/fragments/VorlesungsplanExams.java
@@ -1,20 +1,42 @@
+/* VorlesungsplanExams.java
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package de.dhbwloe.campusapp.fragments;
-
-
import android.os.Bundle;
import android.support.v4.app.Fragment;
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 listItems = new ArrayList();
public VorlesungsplanExams() {
// Required empty public constructor
@@ -24,8 +46,18 @@ public class VorlesungsplanExams extends CampusAppFragment implements Vorlesungs
@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
@@ -33,4 +65,33 @@ public class VorlesungsplanExams extends CampusAppFragment implements Vorlesungs
}
+ @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 * 6)); // next 6 month
+ listItems.clear();
+ for(CourseEvent event : events) {
+
+ VorlesungsplanExamsListItem item = new VorlesungsplanExamsListItem(
+ event.getEventId(),
+ coursename,
+ event.getEventTitle(),
+ event.getEventLocation(),
+ event.getEventFrom(),
+ event.getEventTo(),
+ 1
+ );
+ listItems.add(item);
+ }
+ if(listAdapter != null)
+ listAdapter.notifyDataSetChanged();
+ }
+
}