|
|
@@ -1,60 +1,34 @@
|
|
|
package com.example.yiupang.freefoodfinder;
|
|
|
|
|
|
-/**
|
|
|
- * Created by Zachary Hatton on 5/26/2017.
|
|
|
- */
|
|
|
-
|
|
|
-import android.content.Intent;
|
|
|
+import android.support.v7.app.AppCompatActivity;
|
|
|
import android.os.Bundle;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
-import android.view.KeyEvent;
|
|
|
-import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
-import android.widget.EditText;
|
|
|
-import android.widget.ListView;
|
|
|
-import android.widget.TextView;
|
|
|
import android.widget.Button;
|
|
|
-import android.support.v4.app.Fragment;
|
|
|
-
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-public class CreateEventScreen extends Fragment{
|
|
|
+import android.widget.EditText;
|
|
|
|
|
|
+public class CreateEventScreen extends AppCompatActivity {
|
|
|
|
|
|
@Override
|
|
|
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
|
|
+ public void onCreate(Bundle savedInstanceState)
|
|
|
{
|
|
|
- View view = inflater.inflate(R.layout.create_event, container, false);
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_create_event_screen);
|
|
|
final Event newEvent = new Event();
|
|
|
|
|
|
- /* EditText editText = (EditText) view.findViewById(R.id.box1);
|
|
|
- editText.setOnEditorActionListener(new EditText.OnEditorActionListener() {
|
|
|
- @Override
|
|
|
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
- boolean handled = false;
|
|
|
- int i = 0;
|
|
|
- handled = true;
|
|
|
- return handled;
|
|
|
- }
|
|
|
- }); */
|
|
|
-
|
|
|
- //Button button = (Button) view.findViewById(R.id.button_create);
|
|
|
- //onClickListener(view);
|
|
|
-
|
|
|
- Button button = (Button) view.findViewById(R.id.button_create);
|
|
|
- final EditText titleEdit = (EditText)view.findViewById(R.id.titletext);
|
|
|
- final EditText dateEdit = (EditText)view.findViewById(R.id.datetext);
|
|
|
- final EditText timeEdit = (EditText)view.findViewById(R.id.timetext);
|
|
|
- final EditText placeEdit = (EditText)view.findViewById(R.id.placetext);
|
|
|
- final EditText foodEdit = (EditText)view.findViewById(R.id.foodtext);
|
|
|
- final EditText descEdit = (EditText)view.findViewById(R.id.descriptiontext);
|
|
|
+ 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 placeEdit = (EditText) findViewById(R.id.placetext);
|
|
|
+ final EditText foodEdit = (EditText) findViewById(R.id.foodtext);
|
|
|
+ final EditText descEdit = (EditText) findViewById(R.id.descriptiontext);
|
|
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
@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();
|
|
|
@@ -63,10 +37,10 @@ public class CreateEventScreen extends Fragment{
|
|
|
String desc = descEdit.getText().toString();
|
|
|
|
|
|
newEvent.setName(title);
|
|
|
- //newEvent.setTime(null);
|
|
|
newEvent.setPlace(place);
|
|
|
- //newEvent.setLatitude(0);
|
|
|
- //newEvent.setLongitude(0);
|
|
|
+ float[] coordinates = place2Coordinates(place);
|
|
|
+ newEvent.setLat(coordinates[0]);
|
|
|
+ newEvent.setLng(coordinates[1]);
|
|
|
newEvent.setDate(date);
|
|
|
newEvent.setTime(time);
|
|
|
newEvent.setFoodType(food);
|
|
|
@@ -75,19 +49,47 @@ public class CreateEventScreen extends Fragment{
|
|
|
HttpCall httpr = new HttpCall();
|
|
|
httpr.setMethodType(HttpCall.PUT);
|
|
|
httpr.setBody(newEvent);
|
|
|
- httpr.setUrl("https://free-food-finder.herokuapp.com/events");
|
|
|
+ httpr.setUrl("http://free-food-finder.herokuapp.com/events");
|
|
|
new HttpRequest(){
|
|
|
@Override
|
|
|
public void onResponse(Object response, int code)
|
|
|
{
|
|
|
- Intent details = new Intent(getContext(), EventsScreen.class);
|
|
|
- startActivity(details);
|
|
|
+ finish();
|
|
|
}
|
|
|
}.execute(httpr);
|
|
|
|
|
|
}
|
|
|
});
|
|
|
+ }
|
|
|
+
|
|
|
+ public float[] place2Coordinates(String place){
|
|
|
+ float[] coords = new float[2];
|
|
|
|
|
|
- return view;
|
|
|
+ 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;
|
|
|
}
|
|
|
+
|
|
|
}
|