Added README.txt and GPL Header to Source Files
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / fragments / VorlesungsplanUpcomingCourseListItem.java
index e706e3f334068022a22e98ce1479fa7493f2f27b..41b8f7c3680dcfe3bb50a3d63b3c1a2471d919a4 100644 (file)
@@ -1,6 +1,21 @@
+/* VorlesungsplanUpcomingCourseListItem.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 <http://www.gnu.org/licenses/>.
+ */
 package de.dhbwloe.campusapp.fragments;
-
 import android.content.Context;
+import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.TextView;
@@ -11,6 +26,7 @@ import java.util.Date;
 import de.dhbwloe.campusapp.CampusAppContext;
 import de.dhbwloe.campusapp.R;
 import de.dhbwloe.campusapp.vorlesungen.CourseEvent;
+import de.dhbwloe.campusapp.vorlesungen.CourseGroup;
 
 /**
  * Created by pk910 on 20.02.2016.
@@ -24,7 +40,15 @@ public class VorlesungsplanUpcomingCourseListItem {
 
     public void updateContainerView(View view) {
 
-        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
+        android.support.v7.widget.CardView cardView = (android.support.v7.widget.CardView) view.findViewById(R.id.card_upcomingday);
+        cardView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                onEventClicked();
+            }
+        });
+
+        SimpleDateFormat dateFormat = new SimpleDateFormat(CampusAppContext.getInstance().getResString(R.string.timeformat_vorlesungsplan_time));
         TextView timeFrom = (TextView) view.findViewById(R.id.timeFrom);
         TextView timeTo = (TextView) view.findViewById(R.id.timeTo);
         TextView location = (TextView) view.findViewById(R.id.location);
@@ -39,4 +63,13 @@ public class VorlesungsplanUpcomingCourseListItem {
         location.setText(event.getEventLocation());
         courseTitle.setText(event.getEventTitle());
     }
+
+    private void onEventClicked() {
+        Bundle args = new Bundle();
+        CourseGroup group = event.getCourseGroup();
+        if(group == null)
+            return;
+        args.putString("groupid", Integer.toString(group.getGroupId()));
+        CampusAppContext.getInstance().getNavigationManager().navigatePage("Vorlesungsplan", args);
+    }
 }