Ver código fonte

AboutUsScreen desmelled. CreateEventScreen Google Map functionality added.

Zachary Hatton 9 anos atrás
pai
commit
c0267d3158

+ 2 - 15
app/src/main/java/com/example/yiupang/freefoodfinder/AboutUsScreen.java

@@ -1,29 +1,19 @@
 package com.example.yiupang.freefoodfinder;
 
-import android.content.res.Configuration;
-import android.content.Context;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 
-import android.content.res.Configuration;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.app.AppCompatDelegate;
 import android.view.Gravity;
 import android.widget.Toast;
 
 import java.util.Calendar;
-import android.view.Window;
 
 import mehdi.sakout.aboutpage.AboutPage;
 import mehdi.sakout.aboutpage.Element;
 
-
-import android.view.WindowManager;
-import android.view.Window;
-
 /**
  * Created by yiupang on 5/6/2017.
  *
@@ -40,14 +30,13 @@ public class AboutUsScreen extends android.support.v4.app.Fragment
         Element adsElement = new Element();
         adsElement.setTitle("Advertise with us");
 
-        View aboutPage = new AboutPage(getContext())
+        return new AboutPage(getContext())
                 .setDescription(" Free Food Finder is the easiest way" +
                         " to locate events serving free food wherever you may be." +
                         " FreeFood Finder enables you to easily find club meetings," +
                         " company recruiting sessions, and campus events near your current location." +
                         " Simply select an event to get all deets.")
                 .isRTL(false)
-                //.setImage(R.drawable.dummy_image2)
                 .addGroup("Connect with us")
                 .addEmail("contact@freefoodfinder.com")
                 .addWebsite("freefoodfinder.io")
@@ -62,15 +51,13 @@ public class AboutUsScreen extends android.support.v4.app.Fragment
                 .addItem(getCopyRightsElement())
                 .create();
 
-        return aboutPage;
-
     }
 
     Element getCopyRightsElement() {
         Element copyRightsElement = new Element();
         final String copyrights = String.format(getString(R.string.copy_right), Calendar.getInstance().get(Calendar.YEAR));
         copyRightsElement.setTitle(copyrights);
-        //copyRightsElement.setIconDrawable(R.drawable.about_icon_copy_right);
+
         copyRightsElement.setIconTint(mehdi.sakout.aboutpage.R.color.about_item_icon_color);
         copyRightsElement.setIconNightTint(android.R.color.white);
         copyRightsElement.setGravity(Gravity.CENTER);

+ 41 - 6
app/src/main/java/com/example/yiupang/freefoodfinder/CreateEventScreen1.java

@@ -16,9 +16,10 @@ public class CreateEventScreen1 extends AppCompatActivity {
         final Event newEvent = new Event();
 
         Button button = (Button) findViewById(R.id.button_create);
+        //final EditText creatorEdit = (EditText) findViewById(R.id.creatortext);
         final EditText titleEdit = (EditText) findViewById(R.id.titletext);
-        final EditText dateEdit = (EditText) findViewById(R.id.datetext);
-        final EditText timeEdit = (EditText) findViewById(R.id.timetext);
+        //final EditText dateEdit = (EditText) findViewById(R.id.datetext);
+        //final EditText timeEdit = (EditText) findViewById(R.id.timetext);
         final EditText placeEdit = (EditText) findViewById(R.id.placetext);
         final EditText foodEdit = (EditText) findViewById(R.id.foodtext);
         final EditText descEdit = (EditText) findViewById(R.id.descriptiontext);
@@ -27,17 +28,21 @@ public class CreateEventScreen1 extends AppCompatActivity {
             @Override
             public void onClick(View v){
 
+                //String creator = creatorEdit.getText().toString();
                 String title = titleEdit.getText().toString();
-                String date = dateEdit.getText().toString();
-                String time = timeEdit.getText().toString();
+                //String date = dateEdit.getText().toString();
+                //String time = timeEdit.getText().toString();
                 String place = placeEdit.getText().toString();
                 String food = foodEdit.getText().toString();
                 String desc = descEdit.getText().toString();
 
                 newEvent.setName(title);
                 newEvent.setPlace(place);
-                newEvent.setDate(date);
-                newEvent.setTime(time);
+                float[] coordinates = place2Coordinates(place);
+                newEvent.setLat(coordinates[0]);
+                newEvent.setLng(coordinates[1]);
+                //newEvent.setDate(date);
+                //newEvent.setTime(time);
                 newEvent.setFoodType(food);
                 newEvent.setDescription(desc);
 
@@ -57,4 +62,34 @@ public class CreateEventScreen1 extends AppCompatActivity {
         });
     }
 
+    public float[] place2Coordinates(String place){
+        float[] coords = new float[2];
+
+        if("KennedyLibrary".equals(place) || "35".equals(place)){
+            coords[0] = 35.30187f;
+            coords[1] = -120.663861f;
+        }
+        else if("Computer Science Building".equals(place) || "14".equals(place)){
+            coords[0] = 35.299895f;
+            coords[1] = -120.662144f;
+        }
+        else if("Engineering East".equals(place) || "20".equals(place)){
+            coords[0] = 35.300576f;
+            coords[1] = -120.661726f;
+        }
+        else if("Science".equals(place) || "52".equals(place)){
+            coords[0] = 35.300571f;
+            coords[1] = -120.660192f;
+        }
+        else if("Engineering West".equals(place) || "21".equals(place)){
+            coords[0] = 35.300066f;
+            coords[1] = -120.663209f;
+        }
+        else{
+            coords[0] = 35.305005f;
+            coords[1] = -120.662494f;
+        }
+        return coords;
+    }
+
 }