소스 검색

Created new activity to redirect to event details. Created new XML for event details screen from old one to list info. Only listing name, food, and description so far. Note: first event in list causes crash, likely due to null values.

Fernando Diaz 9 년 전
부모
커밋
6daed5f66b

+ 8 - 4
app/src/main/AndroidManifest.xml

@@ -39,8 +39,7 @@
         <activity
             android:name=".MainActivity"
             android:parentActivityName=".LoginActivity"
-            android:theme="@style/AppTheme.NoActionBar">
-        </activity>
+            android:theme="@style/AppTheme.NoActionBar"></activity>
 
         <!-- Google API meta-deta -->
         <meta-data
@@ -50,9 +49,14 @@
             android:name="com.google.android.geo.API_KEY"
             android:value="@string/google_maps_key" />
 
-
-
+        <!-- Event Details Activity -->
+        <activity
+            android:name=".EventDetailsScreen1"
+            android:parentActivityName=".MainActivity"
+            android:theme="@style/AppTheme.NoActionBar">
+        </activity>
 
 
     </application>
+
 </manifest>

+ 6 - 2
app/src/main/java/com/example/yiupang/freefoodfinder/EventDetailsScreen.java

@@ -2,10 +2,12 @@ package com.example.yiupang.freefoodfinder;
 
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ListView;
+import android.widget.TextView;
 
 import java.util.ArrayList;
 
@@ -27,6 +29,8 @@ public class EventDetailsScreen extends Fragment
         View view = inflater.inflate(R.layout.event_details_screen, container, false);
 
 
+
+
         return view;
     }
 
@@ -35,8 +39,8 @@ public class EventDetailsScreen extends Fragment
      *
      * @param evt The event to be displayed
      */
-    public void captureNewEvent(Event evt)
+    /*public void captureNewEvent(Event evt)
     {
         e = evt;
-    }
+    }*/
 }

+ 47 - 0
app/src/main/java/com/example/yiupang/freefoodfinder/EventDetailsScreen1.java

@@ -0,0 +1,47 @@
+package com.example.yiupang.freefoodfinder;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import java.io.Serializable;
+
+import android.support.v7.app.AppCompatActivity;
+
+
+public class EventDetailsScreen1 extends AppCompatActivity
+{
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState)
+    {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_event_details_screen1);
+
+       // Event selectedEvent = (Event)getIntent().getSerializableExtra("selectedEvent");
+
+        String selectedEventName = (String)getIntent().getExtras().getSerializable("selectedEventName");
+        String selectedEventDesc = (String)getIntent().getExtras().getSerializable("selectedEventDesc");
+        String selectedEventFoodType = (String)getIntent().getExtras().getSerializable("selectedEventFoodType");
+
+
+        TextView nameText = (TextView) findViewById(R.id.nameText);
+        nameText.setText(selectedEventName);
+
+        TextView foodText = (TextView) findViewById(R.id.foodText);
+        foodText.setText(selectedEventFoodType);
+
+        TextView descText = (TextView) findViewById( R.id.descText);
+        descText.setText(selectedEventDesc);
+
+       /* Log.d("NAME", selectedEventName);
+        Log.d("DESCRIPTION", selectedEventDesc);
+        Log.d("FOODTYPE", selectedEventFoodType); */
+
+    }
+}

+ 35 - 6
app/src/main/java/com/example/yiupang/freefoodfinder/EventsScreen.java

@@ -1,15 +1,24 @@
 package com.example.yiupang.freefoodfinder;
 
+import android.content.Intent;
 import android.os.Bundle;
+import android.os.Parcelable;
 import android.support.annotation.Nullable;
 
+import android.support.v4.app.Fragment;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 
+import android.widget.Adapter;
 import android.widget.AdapterView;
 import android.widget.ListView;
+import android.support.v7.app.AppCompatActivity;
 
+import android.os.Parcelable;
+
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -17,7 +26,7 @@ import java.util.List;
  *
  */
 
-public class EventsScreen extends android.support.v4.app.Fragment
+public class EventsScreen extends Fragment
 {
 
     @Nullable
@@ -44,14 +53,34 @@ public class EventsScreen extends android.support.v4.app.Fragment
         return view;
     }
 
-    public void setItemListener(ListView listView)
+    public void setItemListener(final ListView listView)
     {
-        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+        listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
+        {
             @Override
-            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
-                AboutUsScreen es = new AboutUsScreen();
-                getFragmentManager().beginTransaction().replace(R.id.frame, es).commit();
+            public void onItemClick(AdapterView<?> adapterView, View view, int position, long id)
+            {
+                Event selectedEvent = (Event) adapterView.getAdapter().getItem(position);
+               /* Log.d("tag", selectedEvent.getName());
+                Log.d("tag", selectedEvent.getFoodType());
+                Log.d("tag", selectedEvent.getDescription()); */
+
+                switchActivity(selectedEvent);
+
+               /* EventDetailsScreen es = new EventDetailsScreen();
+                getFragmentManager().beginTransaction().replace(R.id.frame, es).commit();*/
             }
         });
     }
+
+    public void switchActivity(Event selectedEvent)
+    {
+        Intent details = new Intent(getContext(), EventDetailsScreen1.class);
+
+        details.putExtra("selectedEventName", selectedEvent.getName());
+        details.putExtra("selectedEventDesc", selectedEvent.getDescription());
+        details.putExtra("selectedEventFoodType", selectedEvent.getFoodType());
+
+        startActivity(details);
+    }
 }

+ 122 - 0
app/src/main/res/layout/activity_event_details_screen1.xml

@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="utf-8"?>
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+
+    <EditText
+        android:id="@+id/creatorlabel"
+        android:layout_width="80dp"
+        android:layout_height="wrap_content"
+        android:ems="10"
+        android:inputType="textPersonName"
+        android:text="Creator:" />
+
+    <EditText
+        android:id="@+id/datelabel"
+        android:layout_width="66dp"
+        android:layout_height="wrap_content"
+        android:ems="10"
+        android:inputType="textPersonName"
+        android:text="Date:" />
+
+    <EditText
+        android:id="@+id/timelabel"
+        android:layout_width="68dp"
+        android:layout_height="wrap_content"
+        android:ems="10"
+        android:inputType="textPersonName"
+        android:text="Time:" />
+
+    <EditText
+        android:id="@+id/placelabel"
+        android:layout_width="70dp"
+        android:layout_height="wrap_content"
+        android:ems="10"
+        android:inputType="textPersonName"
+        android:text="Place:" />
+
+    <EditText
+        android:id="@+id/foodlabel"
+        android:layout_width="115dp"
+        android:layout_height="wrap_content"
+        android:ems="10"
+        android:inputType="textPersonName"
+        android:text="Food Served:" />
+
+    <EditText
+        android:id="@+id/desclabel"
+        android:layout_width="105dp"
+        android:layout_height="wrap_content"
+        android:ems="10"
+        android:inputType="textPersonName"
+        android:text="Description:" />
+
+    <TextView
+        android:id="@+id/nameText"
+        android:layout_width="255dp"
+        android:layout_height="wrap_content"
+        android:layout_column="1"
+        android:layout_row="0"
+        android:ems="10"
+        android:inputType="textPersonName" />
+
+    <TextView
+        android:id="@+id/timetext"
+        android:layout_width="255dp"
+        android:layout_height="wrap_content"
+        android:layout_column="1"
+        android:layout_row="2"
+        android:ems="10"
+        android:inputType="textPersonName" />
+
+    <TextView
+        android:id="@+id/datetext"
+        android:layout_width="255dp"
+        android:layout_height="wrap_content"
+        android:layout_column="1"
+        android:layout_row="1"
+        android:ems="10"
+        android:inputType="textPersonName" />
+
+    <TextView
+        android:id="@+id/placetext"
+        android:layout_width="255dp"
+        android:layout_height="wrap_content"
+        android:layout_column="1"
+        android:layout_row="3"
+        android:ems="10"
+        android:inputType="textPersonName" />
+
+    <TextView
+        android:id="@+id/foodText"
+        android:layout_width="255dp"
+        android:layout_height="wrap_content"
+        android:layout_column="1"
+        android:layout_row="4"
+        android:ems="10"
+        android:inputType="textPersonName" />
+
+    <TextView
+        android:id="@+id/descText"
+        android:layout_width="255dp"
+        android:layout_height="wrap_content"
+        android:layout_column="1"
+        android:layout_row="5"
+        android:ems="10"
+        android:inputType="textPersonName" />
+
+
+    <!--
+    <TextView
+        android:id="@+id/textViewsss"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:hint="Your viewsss"/>
+        -->
+
+
+    />
+</GridLayout>