Commit 9f4cbd95 authored by Mrunzzz's avatar Mrunzzz

Merge branch 'creatEventApi' of https://github.com/Mrunzzz/IITB-App into createEventApi

parents 94ac3f9c 944871dd
package in.ac.iitb.gymkhana.iitbapp;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
/**
* Created by mrunz on 15/7/17.
*/
public class AddEventAdapter extends BaseAdapter {
LayoutInflater inflater;
public int publicStatus = 0;
int permission = 0;
public String location = "";
@Override
public int getCount() {
return 3;
}
@Override
public Object getItem(int position) {
return getItem(position);
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
if (inflater == null) {
inflater = (LayoutInflater) parent.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
int type = getItemViewType(position);
if (convertView == null) {
switch (type) {
case 0: {
convertView = inflater.inflate(R.layout.advanced_options_view, null);
CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.cb_public);
if (checkBox.isChecked()) publicStatus = 1;
break;
}
case 1: {
convertView = inflater.inflate(R.layout.advanced_options_view_2, null);
EditText editText = (EditText) convertView.findViewById(R.id.map_location);
location = editText.getText().toString();
break;
}
case 2: {
convertView = inflater.inflate(R.layout.advanced_options_view_3, null);
CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.cb_permission);
if (checkBox.isChecked()) permission = 1;
break;
}
}
}
return convertView;
}
}
package in.ac.iitb.gymkhana.iitbapp.api;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.LoginRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedRequest;
......@@ -14,6 +16,9 @@ public interface RetrofitInterface {
@POST("login/")
Call<LoginResponse> login(@Body LoginRequest loginRequest);
@POST("/createEvent/")
Call<EventCreateResponse> eventCreate(@Body EventCreateRequest eventCreateRequest);
@POST("getNewsFeed/")
Call<NewsFeedResponse> getNewsFeed(@Body NewsFeedRequest newsFeedRequest);
......
package in.ac.iitb.gymkhana.iitbapp.api.model;
import android.media.Image;
import android.support.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
/**
* Created by mrunz on 15/7/17.
*/
public class EventCreateRequest {
@SerializedName("event_name")
private String eventName;
@SerializedName("event_description")
private String eventDescription;
@SerializedName("event_timing_from")
private Timestamp eventTimingFrom;
@SerializedName("event_timing_to")
private Timestamp eventTimingTo;
@SerializedName("event_venue_id")
private int eventVenueID;
@SerializedName("event_maplocation_id")
private int eventMapLocationId;
@SerializedName("event_venue")
private String eventVenue;
@SerializedName("public_status")
private int publicStatus;
public EventCreateRequest(String eventName, String eventDescription,String eventVenue,Timestamp eventTimingFrom,Timestamp eventTimingTo,int publicStatus,@Nullable int eventVenueID,@Nullable int eventMapLocationId) {
this.eventName=eventName;
this.eventDescription=eventDescription;
this.eventTimingFrom=eventTimingFrom;
this.eventTimingTo=eventTimingTo;
this.eventVenueID=eventVenueID;
this.eventMapLocationId=eventMapLocationId;
this.eventVenue=eventVenue;
this.publicStatus=publicStatus;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getEventDescription() {
return eventDescription;
}
public void setEventDescription(String eventDescription) {
this.eventDescription = eventDescription;
}
public Timestamp getEventTimingFrom() {
return eventTimingFrom;
}
public void setEventTimingFrom(Timestamp eventTimingFrom) {
this.eventTimingFrom = eventTimingFrom;
}
public Timestamp getEventTimingTo() {
return eventTimingTo;
}
public void setEventTimingTo(Timestamp eventTimingTo) {
this.eventTimingTo = eventTimingTo;
}
public int getEventVenueID() {
return eventVenueID;
}
public void setEventVenueID(@Nullable int eventVenueID) {
this.eventVenueID = eventVenueID;
}
public int getEventMapLocationId() {
return eventMapLocationId;
}
public void setEventMapLocationId(@Nullable int eventMapLocationId) {
this.eventMapLocationId = eventMapLocationId;
}
public String getEventVenue() {
return eventVenue;
}
public void setEventVenue(String eventVenue) {
this.eventVenue = eventVenue;
}
public int getPublicStatus() {
return publicStatus;
}
public void setPublicStatus(int publicStatus) {
this.publicStatus = publicStatus;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
/**
* Created by mrunz on 15/7/17.
*/
public class EventCreateResponse {
private String result;
private String eventId;
public EventCreateResponse(String result,String eventId){
this.result=result;
this.eventId=eventId;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
}
......@@ -2,8 +2,10 @@ package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.media.Image;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.ListPopupWindow;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -13,26 +15,37 @@ import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import java.sql.Timestamp;
import java.util.Calendar;
import butterknife.BindView;
import butterknife.ButterKnife;
import in.ac.iitb.gymkhana.iitbapp.AddEventAdapter;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateResponse;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class AddEventFragment extends Fragment {
@BindView(R.id.button_createEvent)
Button createEvent;
@BindView(R.id.cb_public)
CheckBox publicCheckBox;
@BindView(R.id.tv_date)
TextView date;
@BindView(R.id.tv_time)
TextView time;
@BindView(R.id.tv_start)
TextView start;
@BindView(R.id.et_eventName)
EditText eventName;
@BindView(R.id.tv_end)
TextView end;
@BindView(R.id.et_venue)
EditText venue;
@BindView(R.id.et_eventDetails)
......@@ -41,7 +54,15 @@ public class AddEventFragment extends Fragment {
ImageView eventImage;
@BindView(R.id.ib_eventImage)
ImageButton imageButton;
Timestamp timestamp_start;
Timestamp timestamp_end;
Image image;
@BindView(R.id.advanced_menu)
TextView advancedMenu;
int publicStatus;
View view;
ListPopupWindow popupWindow;
AddEventAdapter addEventAdapter;
public AddEventFragment() {
......@@ -55,62 +76,129 @@ public class AddEventFragment extends Fragment {
container.removeAllViews();
view = inflater.inflate(R.layout.fragment_add_event, container, false);
ButterKnife.bind(this,view);
ButterKnife.bind(this, view);
popupWindow=new ListPopupWindow(getContext());
addEventAdapter=new AddEventAdapter();
date.setOnClickListener(new View.OnClickListener() {
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar=Calendar.getInstance();
int mYear=calendar.get(Calendar.YEAR);
int mMonth=calendar.get(Calendar.MONTH);
int mDay=calendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog=new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
date.setText(dayOfMonth + "/" + month + "/" + year);
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
start.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
}
}, mHour, mMin, true);
timePickerDialog.show();
}
} ,mYear,mMonth,mDay);
datePickerDialog.show();
}, mYear, mMonth, mDay);
datePickerDialog.show();
timestamp_start = new Timestamp(millis);
}
});
time.setOnClickListener(new View.OnClickListener() {
end.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar=Calendar.getInstance();
int mHour=calendar.get(Calendar.HOUR_OF_DAY);
int mMin=calendar.get(Calendar.MINUTE);
Calendar calendar = Calendar.getInstance();
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int mHour = calendar.get(Calendar.HOUR_OF_DAY);
final int mMin = calendar.get(Calendar.MINUTE);
long millis = calendar.getTimeInMillis();
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
TimePickerDialog timePickerDialog=new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
time.setText(hourOfDay+":"+minute);
public void onDateSet(DatePicker view, final int year, final int month, final int dayOfMonth) {
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
end.setText(dayOfMonth + "/" + month + "/" + year + " " + hourOfDay + ":" + minute);
}
}, mHour, mMin, true);
timePickerDialog.show();
}
},mHour,mMin,true);
timePickerDialog.show();
}, mYear, mMonth, mDay);
datePickerDialog.show();
timestamp_end = new Timestamp(millis);
}
});
advancedMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createPopup();
}
});
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(),"Add Image", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), "Add Image", Toast.LENGTH_SHORT).show();
//TODO (1) upload image to server
}
});
createEvent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(),"Add Event", Toast.LENGTH_SHORT).show();
//TODO (2) save event
addEvent();
}
});
return view;
}
//TODO(3) configure onBackPressed
public void addEvent() {
EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), venue.getText().toString(), timestamp_start, timestamp_end, addEventAdapter.publicStatus, 0, 0);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.eventCreate(eventCreateRequest).enqueue(new Callback<EventCreateResponse>() {
@Override
public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) {
Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<EventCreateResponse> call, Throwable t) {
Toast.makeText(getContext(), "Event Creation Failed", Toast.LENGTH_SHORT).show();
}
});
}
public void createPopup() {
popupWindow.setAdapter(addEventAdapter);
popupWindow.setAnchorView(advancedMenu);
popupWindow.setHeight(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
popupWindow.setWidth(advancedMenu.getRight() - advancedMenu.getLeft());
popupWindow.show();
}
}
......@@ -4,7 +4,7 @@
<shape android:shape="rectangle">
<corners android:radius="50dip" />
<stroke android:width="0dip" android:color="#667162" />
<gradient android:angle="-90" android:endColor="#FFEA00" android:startColor="#FFEA00" />
<gradient android:angle="-90" android:endColor="#ecf833" android:startColor="#ecf833" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:paddingRight="16dp">
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cb_public"
android:text="Outsiders Allowed "/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:paddingRight="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/map_location"
android:hint="Map Location"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:paddingRight="16dp">
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Request User Info"
android:id="@+id/cb_permission"/>
</LinearLayout>
\ No newline at end of file
......@@ -42,45 +42,47 @@
android:layout_height="40dp">
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:paddingRight="6dp"
android:paddingLeft="6dp"
android:gravity="bottom"
android:paddingBottom="5dp"
android:layout_height="match_parent"
android:id="@+id/tv_date"
android:hint=" Date "
android:id="@+id/tv_start"
android:textSize="20sp"
android:hint=" From "
android:paddingTop="8dp"/>
<View
android:layout_width="3dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="@color/common_google_signin_btn_text_dark_disabled"/>
android:layout_marginBottom="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:paddingRight="6dp"
android:paddingLeft="6dp"
android:gravity="bottom"
android:paddingBottom="5dp"
android:layout_height="match_parent"
android:id="@+id/tv_time"
android:hint=" Time "
android:id="@+id/tv_end"
android:textSize="20sp"
android:hint=" To "
android:paddingTop="8dp"/>
<View
android:layout_width="3dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:background="@color/common_google_signin_btn_text_dark_disabled"/>
<EditText
android:layout_width="wrap_content"
android:paddingRight="6dp"
android:paddingLeft="6dp"
android:layout_height="match_parent"
android:id="@+id/et_venue"
android:hint="Venue"/>
</LinearLayout>
<EditText
android:layout_width="wrap_content"
android:paddingRight="6dp"
android:paddingLeft="8dp"
android:layout_marginLeft="16dp"
android:layout_height="40dp"
android:id="@+id/et_venue"
android:hint="Venue"/>
<EditText
android:layout_width="match_parent"
......@@ -93,35 +95,21 @@
android:paddingRight="6dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:background="#E0E0E0"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
>
android:layout_marginTop="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Public"
android:textSize="18sp"
android:layout_marginLeft="8dp"
android:paddingLeft="8dp"/>
<TextView android:layout_height="30dp"
android:layout_width="match_parent"
android:text="Advanced Options"
android:id="@+id/advanced_menu"
android:paddingLeft="16dp"
android:paddingRight="16dp"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:id="@+id/cb_public"
android:layout_marginRight="10dp"/>
</RelativeLayout>
<Button
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/colorAccent"
android:layout_height="40dp"
android:text="Create"
android:layout_margin="8dp"
android:background="@drawable/round_text_box"
android:id="@+id/button_createEvent"
android:gravity="center"/>
</LinearLayout>
\ No newline at end of file
......@@ -10,7 +10,7 @@
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#FFEB3B</item>
<item name="colorAccent">#ecf833</item>
<item name="android:colorBackground">?attr/colorButtonNormal</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">?android:attr/colorButtonNormal</item>
......
......@@ -21,7 +21,7 @@
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#FFEA00</item>
<item name="colorAccent">#ecf833</item>
<item name="android:colorBackground">@android:color/darker_gray</item>
<item name="android:textColorPrimaryInverse">@android:color/darker_gray</item>
<item name="android:windowBackground">@android:color/darker_gray</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment