1 /* VorlesungsplanExams.java
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package de.dhbwloe.campusapp.fragments;
17 import android.os.Bundle;
18 import android.support.v4.app.Fragment;
19 import android.view.LayoutInflater;
20 import android.view.View;
21 import android.view.ViewGroup;
22 import android.widget.ListView;
24 import java.util.ArrayList;
25 import java.util.Date;
27 import de.dhbwloe.campusapp.CampusAppFragment;
28 import de.dhbwloe.campusapp.R;
29 import de.dhbwloe.campusapp.vorlesungen.CourseEvent;
30 import de.dhbwloe.campusapp.vorlesungen.CourseGroup;
33 * A simple {@link Fragment} subclass.
35 public class VorlesungsplanExams extends CampusAppFragment implements Vorlesungsplan.VorlesungsplanFragment {
36 private String coursename;
38 private VorlesungsplanExamsListAdapter listAdapter;
39 private ArrayList<VorlesungsplanExamsListItem> listItems = new ArrayList<VorlesungsplanExamsListItem>();
41 public VorlesungsplanExams() {
42 // Required empty public constructor
47 public View onCreateView(LayoutInflater inflater, ViewGroup container,
48 Bundle savedInstanceState) {
49 String kursTag = AppContext.getDatabaseManager().getRuntimeCache("CourseName");
50 if(kursTag == null || kursTag.isEmpty())
54 view = inflater.inflate(R.layout.fragment_vorlesungsplan_exams, container, false);
56 ListView listView = (ListView) view.findViewById(R.id.listView);
57 listAdapter = new VorlesungsplanExamsListAdapter(view.getContext(), R.layout.fragment_vorlesungsplan_exams_exam, listItems);
58 listView.setAdapter(listAdapter);
64 public void setActive() {
69 public void onResume() {
71 if(coursename != null)
75 private void updateCoursesList() {
76 long now = (new Date()).getTime()/1000;
78 CourseEvent[] events = AppContext.getDatabaseManager().getCourseExamEvents(coursename, now, now + (86400 * 30 * 6)); // next 6 month
80 for(CourseEvent event : events) {
82 VorlesungsplanExamsListItem item = new VorlesungsplanExamsListItem(
85 event.getEventTitle(),
86 event.getEventLocation(),
93 if(listAdapter != null)
94 listAdapter.notifyDataSetChanged();