Commit 933a0165 authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge pull request #43 from wncc/classes

Implement Event APIs
parents ccac092a bb0f6387
...@@ -56,5 +56,9 @@ dependencies { ...@@ -56,5 +56,9 @@ dependencies {
compile "com.android.support:customtabs:${supportLibVersion}" compile "com.android.support:customtabs:${supportLibVersion}"
compile "android.arch.persistence.room:runtime:${archRoomVersion}" compile "android.arch.persistence.room:runtime:${archRoomVersion}"
annotationProcessor "android.arch.persistence.room:compiler:${archRoomVersion}" annotationProcessor "android.arch.persistence.room:compiler:${archRoomVersion}"
implementation "com.android.support:cardview-v7:${supportLibVersion}"
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:allowBackup="true" android:allowBackup="true"
......
...@@ -10,7 +10,14 @@ import android.widget.TextView; ...@@ -10,7 +10,14 @@ import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import org.w3c.dom.Text;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.logging.SimpleFormatter;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener; import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
...@@ -31,7 +38,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -31,7 +38,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
context = viewGroup.getContext(); context = viewGroup.getContext();
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
View postView = inflater.inflate(R.layout.post, viewGroup, false); View postView = inflater.inflate(R.layout.feed_card, viewGroup, false);
final ViewHolder postViewHolder = new ViewHolder(postView); final ViewHolder postViewHolder = new ViewHolder(postView);
postView.setOnClickListener(new View.OnClickListener() { postView.setOnClickListener(new View.OnClickListener() {
...@@ -47,7 +54,16 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -47,7 +54,16 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
public void onBindViewHolder(ViewHolder viewHolder, int i) { public void onBindViewHolder(ViewHolder viewHolder, int i) {
Event currentEvent = posts.get(i); Event currentEvent = posts.get(i);
viewHolder.eventTitle.setText(currentEvent.getEventName()); viewHolder.eventTitle.setText(currentEvent.getEventName());
viewHolder.eventDetails.setText(currentEvent.getEventDescription()); // viewHolder.eventDetails.setText(currentEvent.getEventDescription());
Timestamp timestamp = currentEvent.getEventStartTime();
Date Date = new Date(timestamp.getTime());
SimpleDateFormat simpleDateFormatDate = new SimpleDateFormat("dd MMM");
SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm a");
viewHolder.eventDate.setText(simpleDateFormatDate.format(Date));
viewHolder.eventTime.setText(simpleDateFormatTime.format(Date));
viewHolder.eventVenue.setText(currentEvent.getEventVenues().get(0).getVenueName());
Picasso.with(context).load(currentEvent.getEventImageURL()).into(viewHolder.eventPicture); Picasso.with(context).load(currentEvent.getEventImageURL()).into(viewHolder.eventPicture);
} }
...@@ -59,7 +75,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -59,7 +75,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
private ImageView eventPicture; private ImageView eventPicture;
private TextView eventTitle; private TextView eventTitle;
private TextView eventDetails; // private TextView eventDetails;
private TextView eventDate;
private TextView eventTime;
private TextView eventVenue;
private ImageView eventEnthu; private ImageView eventEnthu;
public ViewHolder(View itemView) { public ViewHolder(View itemView) {
...@@ -67,8 +86,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -67,8 +86,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
eventPicture = (ImageView) itemView.findViewById(R.id.event_picture); eventPicture = (ImageView) itemView.findViewById(R.id.event_picture);
eventTitle = (TextView) itemView.findViewById(R.id.event_title); eventTitle = (TextView) itemView.findViewById(R.id.event_title);
eventDetails = (TextView) itemView.findViewById(R.id.event_details); // eventDetails = (TextView) itemView.findViewById(R.id.event_details);
eventEnthu = (ImageView) itemView.findViewById(R.id.event_enthu); eventDate = (TextView) itemView.findViewById(R.id.event_date);
eventTime = (TextView) itemView.findViewById(R.id.event_time);
eventVenue = (TextView) itemView.findViewById(R.id.event_venue);
} }
} }
} }
...@@ -2,6 +2,8 @@ package in.ac.iitb.gymkhana.iitbapp.api; ...@@ -2,6 +2,8 @@ package in.ac.iitb.gymkhana.iitbapp.api;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateRequest; 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.EventCreateResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.LoginRequest; 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.LoginResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse;
...@@ -12,6 +14,7 @@ import retrofit2.http.Body; ...@@ -12,6 +14,7 @@ import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.Path; import retrofit2.http.Path;
import retrofit2.http.Query;
public interface RetrofitInterface { public interface RetrofitInterface {
@POST("login/") @POST("login/")
...@@ -25,4 +28,7 @@ public interface RetrofitInterface { ...@@ -25,4 +28,7 @@ public interface RetrofitInterface {
@POST("getNotifications/") @POST("getNotifications/")
Call<NotificationsResponse> getNotifications(@Body NotificationsRequest notificationsRequest); Call<NotificationsResponse> getNotifications(@Body NotificationsRequest notificationsRequest);
@POST("upload")
Call<ImageUploadResponse> uploadImage(@Body ImageUploadRequest imageUploadRequest);
} }
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
public class ImageUploadRequest {
@SerializedName("picture")
private String base64Image;
public ImageUploadRequest(String base64Image) {
this.base64Image = base64Image;
}
public String getBase64Image() {
return base64Image;
}
public void setBase64Image(String base64Image) {
this.base64Image = base64Image;
}
}
package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
public class ImageUploadResponse {
@SerializedName("id")
private String pictureID;
@SerializedName("picture")
private String pictureURL;
public ImageUploadResponse(String pictureID, String pictureURL) {
this.pictureID = pictureID;
this.pictureURL = pictureURL;
}
public String getPictureID() {
return pictureID;
}
public void setPictureID(String pictureID) {
this.pictureID = pictureID;
}
public String getPictureURL() {
return pictureURL;
}
public void setPictureURL(String pictureURL) {
this.pictureURL = pictureURL;
}
}
...@@ -6,6 +6,7 @@ import android.arch.persistence.room.PrimaryKey; ...@@ -6,6 +6,7 @@ import android.arch.persistence.room.PrimaryKey;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
import java.util.List; import java.util.List;
@Entity(tableName = "events") @Entity(tableName = "events")
...@@ -29,10 +30,10 @@ public class Event { ...@@ -29,10 +30,10 @@ public class Event {
String eventImageURL; String eventImageURL;
@ColumnInfo(name = "start_time") @ColumnInfo(name = "start_time")
@SerializedName("start_time") @SerializedName("start_time")
String eventStartTime; Timestamp eventStartTime;
@ColumnInfo(name = "end_time") @ColumnInfo(name = "end_time")
@SerializedName("end_time") @SerializedName("end_time")
String eventEndTime; Timestamp eventEndTime;
@ColumnInfo(name = "all_day") @ColumnInfo(name = "all_day")
@SerializedName("all_day") @SerializedName("all_day")
boolean allDayEvent; boolean allDayEvent;
...@@ -55,7 +56,7 @@ public class Event { ...@@ -55,7 +56,7 @@ public class Event {
@SerializedName("going") @SerializedName("going")
List<User> eventGoing; List<User> eventGoing;
public Event(String eventID, String eventName, String eventDescription, String eventImageURL, String eventStartTime, String eventEndTime, boolean allDayEvent, List<Venue> eventVenues, List<Body> eventBodies, int eventInterestedCount, int eventGoingCount, List<User> eventInterested, List<User> eventGoing) { public Event(String eventID, String eventName, String eventDescription, String eventImageURL, Timestamp eventStartTime, Timestamp eventEndTime, boolean allDayEvent, List<Venue> eventVenues, List<Body> eventBodies, int eventInterestedCount, int eventGoingCount, List<User> eventInterested, List<User> eventGoing) {
this.eventID = eventID; this.eventID = eventID;
this.eventName = eventName; this.eventName = eventName;
this.eventDescription = eventDescription; this.eventDescription = eventDescription;
...@@ -103,19 +104,19 @@ public class Event { ...@@ -103,19 +104,19 @@ public class Event {
this.eventImageURL = eventImageURL; this.eventImageURL = eventImageURL;
} }
public String getEventStartTime() { public Timestamp getEventStartTime() {
return eventStartTime; return eventStartTime;
} }
public void setEventStartTime(String eventStartTime) { public void setEventStartTime(Timestamp eventStartTime) {
this.eventStartTime = eventStartTime; this.eventStartTime = eventStartTime;
} }
public String getEventEndTime() { public Timestamp getEventEndTime() {
return eventEndTime; return eventEndTime;
} }
public void setEventEndTime(String eventEndTime) { public void setEventEndTime(Timestamp eventEndTime) {
this.eventEndTime = eventEndTime; this.eventEndTime = eventEndTime;
} }
......
...@@ -7,10 +7,9 @@ import android.arch.persistence.room.PrimaryKey; ...@@ -7,10 +7,9 @@ import android.arch.persistence.room.PrimaryKey;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@Entity(tableName = "venues") @Entity(tableName = "venues")
class Venue { public class Venue {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
int db_id; int db_id;
@ColumnInfo(name = "id") @ColumnInfo(name = "id")
@SerializedName("id") @SerializedName("id")
String venueID; String venueID;
......
package in.ac.iitb.gymkhana.iitbapp.fragment; package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.app.DatePickerDialog; import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.app.TimePickerDialog; import android.app.TimePickerDialog;
import android.media.Image; import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.ListPopupWindow; import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -16,15 +23,14 @@ import android.widget.EditText; ...@@ -16,15 +23,14 @@ import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TimePicker; import android.widget.TimePicker;
import android.widget.Toast; import android.widget.Toast;
import java.io.ByteArrayOutputStream;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
...@@ -33,15 +39,20 @@ import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface; ...@@ -33,15 +39,20 @@ import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator; 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.EventCreateRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.EventCreateResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import static android.app.Activity.RESULT_OK;
import static android.content.ContentValues.TAG;
public class AddEventFragment extends Fragment { public class AddEventFragment extends Fragment {
private static final int RESULT_LOAD_IMAGE = 1;
@BindView(R.id.button_createEvent) @BindView(R.id.button_createEvent)
Button createEvent; Button createEvent;
@BindView(R.id.tv_start) @BindView(R.id.tv_start)
TextView start; TextView start;
@BindView(R.id.et_eventName) @BindView(R.id.et_eventName)
...@@ -71,8 +82,11 @@ public class AddEventFragment extends Fragment { ...@@ -71,8 +82,11 @@ public class AddEventFragment extends Fragment {
ImageView open; ImageView open;
@BindView(R.id.close) @BindView(R.id.close)
ImageView close; ImageView close;
ImageView eventPictureImageView;
int publicStatus; int publicStatus;
View view; View view;
String base64Image;
ProgressDialog progressDialog;
public AddEventFragment() { public AddEventFragment() {
...@@ -88,6 +102,9 @@ public class AddEventFragment extends Fragment { ...@@ -88,6 +102,9 @@ public class AddEventFragment extends Fragment {
view = inflater.inflate(R.layout.fragment_add_event, container, false); view = inflater.inflate(R.layout.fragment_add_event, container, false);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
eventPictureImageView = view.findViewById(R.id.ib_eventImage);
progressDialog = new ProgressDialog(getContext());
cb_permission.setVisibility(View.GONE); cb_permission.setVisibility(View.GONE);
cb_public.setVisibility(View.GONE); cb_public.setVisibility(View.GONE);
et_mapLocation.setVisibility(View.GONE); et_mapLocation.setVisibility(View.GONE);
...@@ -195,18 +212,17 @@ public class AddEventFragment extends Fragment { ...@@ -195,18 +212,17 @@ public class AddEventFragment extends Fragment {
imageButton.setOnClickListener(new View.OnClickListener() { imageButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Toast.makeText(getContext(), "Add Image", Toast.LENGTH_SHORT).show(); Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
//TODO (1) upload image to server startActivityForResult(i, RESULT_LOAD_IMAGE);
} }
}); });
createEvent.setOnClickListener(new View.OnClickListener() { createEvent.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
progressDialog.setIndeterminate(true);
Toast.makeText(getContext(), "Add Event", Toast.LENGTH_SHORT).show(); progressDialog.setCancelable(false);
//TODO (2) save event progressDialog.show();
addEvent(); sendImage();
} }
}); });
...@@ -214,20 +230,109 @@ public class AddEventFragment extends Fragment { ...@@ -214,20 +230,109 @@ public class AddEventFragment extends Fragment {
return view; return view;
} }
public void addEvent() { private void sendImage() {
EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), "http://resources.wncc-iitb.org/logo_banner.png", timestamp_start.toString(), timestamp_end.toString(), false, Arrays.asList(new String[]{venue.getText().toString()}), Arrays.asList(new String[]{"bde82d5e-f379-4b8a-ae38-a9f03e4f1c4a"})); progressDialog.setMessage("Uploading Image");
ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.uploadImage(imageUploadRequest).enqueue(new Callback<ImageUploadResponse>() {
@Override
public void onResponse(Call<ImageUploadResponse> call, Response<ImageUploadResponse> response) {
if (response.isSuccessful()) {
ImageUploadResponse imageUploadResponse = response.body();
String imageURL = imageUploadResponse.getPictureURL();
addEvent(imageURL);
}
}
@Override
public void onFailure(Call<ImageUploadResponse> call, Throwable t) {
progressDialog.dismiss();
}
});
}
public void addEvent(String eventImageURL) {
progressDialog.setMessage("Creating Event");
EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), eventImageURL, timestamp_start.toString(), timestamp_end.toString(), false, Arrays.asList(new String[]{venue.getText().toString()}), Arrays.asList(new String[]{"bde82d5e-f379-4b8a-ae38-a9f03e4f1c4a"}));
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.createEvent(eventCreateRequest).enqueue(new Callback<EventCreateResponse>() { retrofitInterface.createEvent(eventCreateRequest).enqueue(new Callback<EventCreateResponse>() {
@Override @Override
public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) { public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) {
Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
} }
@Override @Override
public void onFailure(Call<EventCreateResponse> call, Throwable t) { public void onFailure(Call<EventCreateResponse> call, Throwable t) {
Toast.makeText(getContext(), "Event Creation Failed", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Event Creation Failed", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
} }
}); });
} }
public static String convertImageToString(Bitmap imageBitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (imageBitmap != null) {
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 60, stream);
byte[] byteArray = stream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
} else {
return null;
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
eventPictureImageView.setImageBitmap(getScaledBitmap(picturePath, imageButton.getWidth(), imageButton.getHeight()));
eventPictureImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
base64Image = convertImageToString(getScaledBitmap(picturePath, 800, 800));
Log.d(TAG, "onActivityResult: " + base64Image);
}
}
private Bitmap getScaledBitmap(String picturePath, int width, int height) {
BitmapFactory.Options sizeOptions = new BitmapFactory.Options();
sizeOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(picturePath, sizeOptions);
int inSampleSize = calculateInSampleSize(sizeOptions, width, height);
sizeOptions.inJustDecodeBounds = false;
sizeOptions.inSampleSize = inSampleSize;
return BitmapFactory.decodeFile(picturePath, sizeOptions);
}
private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// Calculate ratios of height and width to requested height and
// width
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
// Choose the smallest ratio as inSampleSize value, this will
// guarantee
// a final image with both dimensions larger than or equal to the
// requested height and width.
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
} }
...@@ -12,6 +12,10 @@ import android.widget.TextView; ...@@ -12,6 +12,10 @@ import android.widget.TextView;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import in.ac.iitb.gymkhana.iitbapp.Constants; import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.data.Event; import in.ac.iitb.gymkhana.iitbapp.data.Event;
...@@ -46,13 +50,21 @@ public class EventFragment extends Fragment { ...@@ -46,13 +50,21 @@ public class EventFragment extends Fragment {
private void inflateViews(Event event) { private void inflateViews(Event event) {
ImageView eventPicture = (ImageView) getActivity().findViewById(R.id.event_picture_2); ImageView eventPicture = (ImageView) getActivity().findViewById(R.id.event_picture_2);
TextView eventTitle = (TextView) getActivity().findViewById(R.id.event_title_2); TextView eventTitle = (TextView) getActivity().findViewById(R.id.event_page_title);
TextView eventDetails = (TextView) getActivity().findViewById(R.id.event_details_2); TextView eventDate = (TextView) getActivity().findViewById(R.id.event_page_date);
TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_description_2); TextView eventTime = (TextView) getActivity().findViewById(R.id.event_page_time);
TextView eventVenue = (TextView) getActivity().findViewById(R.id.event_page_venue);
TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description);
Picasso.with(getContext()).load(event.getEventImageURL()).into(eventPicture); Picasso.with(getContext()).load(event.getEventImageURL()).into(eventPicture);
eventTitle.setText(event.getEventName()); eventTitle.setText(event.getEventName());
eventDetails.setText(event.getEventDescription());
eventDescription.setText(event.getEventDescription()); eventDescription.setText(event.getEventDescription());
Timestamp timestamp = event.getEventStartTime();
Date Date = new Date(timestamp.getTime());
SimpleDateFormat simpleDateFormatDate = new SimpleDateFormat("dd MMM");
SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm a");
eventDate.setText(simpleDateFormatDate.format(Date));
eventTime.setText(simpleDateFormatDate.format(Date));
eventVenue.setText(event.getEventVenues().get(0).getVenueName());
} }
} }
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="match_parent"
card_view:cardElevation="4dp"
card_view:cardCornerRadius="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/event_picture"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:scaleType="centerCrop"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp">
<TextView
android:id="@+id/event_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="18sp"
android:text="Event Title"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/event_date"
android:text="26 May"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textSize="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/event_time"
android:text="6:00 PM"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textSize="20dp"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/event_venue"
android:text="LH 101"
android:ellipsize="end"/>
</LinearLayout>
</LinearLayout>
<!--<ImageView-->
<!--android:id="@+id/event_enthu"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_marginRight="20dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:src="@drawable/ic_action_add"-->
<!--android:layout_gravity="center_vertical"/>-->
</LinearLayout>
<!--<View-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="2dp"-->
<!--android:background="#adfff6"-->
<!--android:layout_marginLeft="16dp"-->
<!--android:layout_marginRight="16dp">-->
<!--</View>-->
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
...@@ -2,30 +2,94 @@ ...@@ -2,30 +2,94 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment"> tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment">
<ImageView <ImageView
android:id="@+id/event_picture_2" android:id="@+id/event_picture_2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="360dp" android:layout_height="0dp"
android:scaleType="centerCrop" /> android:scaleType="centerCrop"
android:layout_weight="1"/>
<TextView <LinearLayout
android:id="@+id/event_title_2" android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/colorPrimary">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp">
<TextView <TextView
android:id="@+id/event_details_2" android:id="@+id/event_page_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:textSize="28sp"
android:textColor="#fff"
android:text="Event Title"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/event_page_date"
android:text="26 May"
android:textSize="16sp"
android:textColor="#fff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textSize="20dp"
android:textColor="#fff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/event_page_time"
android:text="6:00 PM"
android:textSize="16sp"
android:textColor="#fff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textSize="20dp"
android:textColor="#fff"/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/event_page_venue"
android:text="LH 101"
android:ellipsize="end"
android:textSize="16sp"
android:textColor="#fff"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<LinearLayout <LinearLayout
style="?android:attr/buttonBarStyle" style="?android:attr/buttonBarStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
...@@ -33,25 +97,63 @@ ...@@ -33,25 +97,63 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Going" /> android:text="Going"
android:layout_margin="0dp"
android:textColor="@color/colorGray"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#aaa"
android:layout_marginTop="10dp"
android:layout_marginBottom="6dp">
</View>
<Button <Button
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Interested" /> android:text="Interested"
android:layout_margin="0dp"
android:textColor="@color/colorGray"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#aaa"
android:layout_marginTop="10dp"
android:layout_marginBottom="6dp">
</View>
<Button <Button
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Not Going" /> android:text="Not Going"
android:layout_margin="0dp"
android:textColor="@color/colorGray"/>
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#aaa"
android:layout_marginBottom="6dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp">
</View>
<TextView <TextView
android:id="@+id/event_description_2" android:id="@+id/event_page_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:textColor="#777"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/feed_recycler_view" android:id="@+id/feed_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
android:paddingTop="8dp"/>
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="8dp">
<ImageView
android:id="@+id/event_picture"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/event_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="24sp" />
<TextView
android:id="@+id/event_details"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<ImageView
android:id="@+id/event_enthu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_input_add" />
</LinearLayout>
\ No newline at end of file
...@@ -5,11 +5,13 @@ buildscript { ...@@ -5,11 +5,13 @@ buildscript {
repositories { repositories {
maven { url 'https://maven.google.com' } maven { url 'https://maven.google.com' }
jcenter() jcenter()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.0' classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }
...@@ -19,6 +21,7 @@ allprojects { ...@@ -19,6 +21,7 @@ allprojects {
repositories { repositories {
jcenter() jcenter()
maven { url 'https://maven.google.com' } maven { url 'https://maven.google.com' }
google()
} }
} }
......
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