Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
933a0165
Commit
933a0165
authored
Mar 17, 2018
by
Sajal Narang
Committed by
GitHub
Mar 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #43 from wncc/classes
Implement Event APIs
parents
ccac092a
bb0f6387
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
476 additions
and
112 deletions
+476
-112
app/build.gradle
app/build.gradle
+4
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/FeedAdapter.java
...java/in/ac/iitb/gymkhana/iitbapp/adapter/FeedAdapter.java
+26
-5
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
...va/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
+6
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/model/ImageUploadRequest.java
...c/iitb/gymkhana/iitbapp/api/model/ImageUploadRequest.java
+20
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/model/ImageUploadResponse.java
.../iitb/gymkhana/iitbapp/api/model/ImageUploadResponse.java
+31
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/Event.java
...src/main/java/in/ac/iitb/gymkhana/iitbapp/data/Event.java
+8
-7
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/Venue.java
...src/main/java/in/ac/iitb/gymkhana/iitbapp/data/Venue.java
+1
-2
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/AddEventFragment.java
...n/ac/iitb/gymkhana/iitbapp/fragment/AddEventFragment.java
+121
-16
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
...a/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
+16
-4
app/src/main/res/drawable-hdpi/ic_action_add.png
app/src/main/res/drawable-hdpi/ic_action_add.png
+0
-0
app/src/main/res/drawable-mdpi/ic_action_add.png
app/src/main/res/drawable-mdpi/ic_action_add.png
+0
-0
app/src/main/res/drawable-xhdpi/ic_action_add.png
app/src/main/res/drawable-xhdpi/ic_action_add.png
+0
-0
app/src/main/res/drawable-xxhdpi/ic_action_add.png
app/src/main/res/drawable-xxhdpi/ic_action_add.png
+0
-0
app/src/main/res/drawable-xxxhdpi/ic_action_add.png
app/src/main/res/drawable-xxxhdpi/ic_action_add.png
+0
-0
app/src/main/res/layout/feed_card.xml
app/src/main/res/layout/feed_card.xml
+99
-0
app/src/main/res/layout/fragment_event.xml
app/src/main/res/layout/fragment_event.xml
+138
-36
app/src/main/res/layout/fragment_feed.xml
app/src/main/res/layout/fragment_feed.xml
+2
-1
app/src/main/res/layout/post.xml
app/src/main/res/layout/post.xml
+0
-41
build.gradle
build.gradle
+3
-0
No files found.
app/build.gradle
View file @
933a0165
...
...
@@ -56,5 +56,9 @@ dependencies {
compile
"com.android.support:customtabs:${supportLibVersion}"
compile
"android.arch.persistence.room:runtime:${archRoomVersion}"
annotationProcessor
"android.arch.persistence.room:compiler:${archRoomVersion}"
implementation
"com.android.support:cardview-v7:${supportLibVersion}"
}
apply
plugin:
'com.google.gms.google-services'
app/src/main/AndroidManifest.xml
View file @
933a0165
...
...
@@ -6,6 +6,7 @@
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<application
android:allowBackup=
"true"
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/FeedAdapter.java
View file @
933a0165
...
...
@@ -10,7 +10,14 @@ import android.widget.TextView;
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.logging.SimpleFormatter
;
import
in.ac.iitb.gymkhana.iitbapp.ItemClickListener
;
import
in.ac.iitb.gymkhana.iitbapp.R
;
...
...
@@ -31,7 +38,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
public
ViewHolder
onCreateViewHolder
(
ViewGroup
viewGroup
,
int
i
)
{
context
=
viewGroup
.
getContext
();
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
);
postView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
...
...
@@ -47,7 +54,16 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
public
void
onBindViewHolder
(
ViewHolder
viewHolder
,
int
i
)
{
Event
currentEvent
=
posts
.
get
(
i
);
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
);
}
...
...
@@ -59,7 +75,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
public
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
private
ImageView
eventPicture
;
private
TextView
eventTitle
;
private
TextView
eventDetails
;
// private TextView eventDetails;
private
TextView
eventDate
;
private
TextView
eventTime
;
private
TextView
eventVenue
;
private
ImageView
eventEnthu
;
public
ViewHolder
(
View
itemView
)
{
...
...
@@ -67,8 +86,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
eventPicture
=
(
ImageView
)
itemView
.
findViewById
(
R
.
id
.
event_picture
);
eventTitle
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
event_title
);
eventDetails
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
event_details
);
eventEnthu
=
(
ImageView
)
itemView
.
findViewById
(
R
.
id
.
event_enthu
);
// eventDetails = (TextView) itemView.findViewById(R.id.event_details);
eventDate
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
event_date
);
eventTime
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
event_time
);
eventVenue
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
event_venue
);
}
}
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
View file @
933a0165
...
...
@@ -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.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.LoginResponse
;
import
in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse
;
...
...
@@ -12,6 +14,7 @@ import retrofit2.http.Body;
import
retrofit2.http.GET
;
import
retrofit2.http.POST
;
import
retrofit2.http.Path
;
import
retrofit2.http.Query
;
public
interface
RetrofitInterface
{
@POST
(
"login/"
)
...
...
@@ -25,4 +28,7 @@ public interface RetrofitInterface {
@POST
(
"getNotifications/"
)
Call
<
NotificationsResponse
>
getNotifications
(
@Body
NotificationsRequest
notificationsRequest
);
@POST
(
"upload"
)
Call
<
ImageUploadResponse
>
uploadImage
(
@Body
ImageUploadRequest
imageUploadRequest
);
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/model/ImageUploadRequest.java
0 → 100644
View file @
933a0165
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
;
}
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/model/ImageUploadResponse.java
0 → 100644
View file @
933a0165
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
;
}
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/Event.java
View file @
933a0165
...
...
@@ -6,6 +6,7 @@ import android.arch.persistence.room.PrimaryKey;
import
com.google.gson.annotations.SerializedName
;
import
java.sql.Timestamp
;
import
java.util.List
;
@Entity
(
tableName
=
"events"
)
...
...
@@ -29,10 +30,10 @@ public class Event {
String
eventImageURL
;
@ColumnInfo
(
name
=
"start_time"
)
@SerializedName
(
"start_time"
)
String
eventStartTime
;
Timestamp
eventStartTime
;
@ColumnInfo
(
name
=
"end_time"
)
@SerializedName
(
"end_time"
)
String
eventEndTime
;
Timestamp
eventEndTime
;
@ColumnInfo
(
name
=
"all_day"
)
@SerializedName
(
"all_day"
)
boolean
allDayEvent
;
...
...
@@ -55,7 +56,7 @@ public class Event {
@SerializedName
(
"going"
)
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
.
eventName
=
eventName
;
this
.
eventDescription
=
eventDescription
;
...
...
@@ -103,19 +104,19 @@ public class Event {
this
.
eventImageURL
=
eventImageURL
;
}
public
String
getEventStartTime
()
{
public
Timestamp
getEventStartTime
()
{
return
eventStartTime
;
}
public
void
setEventStartTime
(
String
eventStartTime
)
{
public
void
setEventStartTime
(
Timestamp
eventStartTime
)
{
this
.
eventStartTime
=
eventStartTime
;
}
public
String
getEventEndTime
()
{
public
Timestamp
getEventEndTime
()
{
return
eventEndTime
;
}
public
void
setEventEndTime
(
String
eventEndTime
)
{
public
void
setEventEndTime
(
Timestamp
eventEndTime
)
{
this
.
eventEndTime
=
eventEndTime
;
}
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/Venue.java
View file @
933a0165
...
...
@@ -7,10 +7,9 @@ import android.arch.persistence.room.PrimaryKey;
import
com.google.gson.annotations.SerializedName
;
@Entity
(
tableName
=
"venues"
)
class
Venue
{
public
class
Venue
{
@PrimaryKey
(
autoGenerate
=
true
)
int
db_id
;
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
String
venueID
;
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/AddEventFragment.java
View file @
933a0165
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
import
android.app.DatePickerDialog
;
import
android.app.ProgressDialog
;
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.provider.MediaStore
;
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.View
;
import
android.view.ViewGroup
;
...
...
@@ -16,15 +23,14 @@ import android.widget.EditText;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TimePicker
;
import
android.widget.Toast
;
import
java.io.ByteArrayOutputStream
;
import
java.sql.Timestamp
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
...
...
@@ -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.model.EventCreateRequest
;
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.Callback
;
import
retrofit2.Response
;
import
static
android
.
app
.
Activity
.
RESULT_OK
;
import
static
android
.
content
.
ContentValues
.
TAG
;
public
class
AddEventFragment
extends
Fragment
{
private
static
final
int
RESULT_LOAD_IMAGE
=
1
;
@BindView
(
R
.
id
.
button_createEvent
)
Button
createEvent
;
@BindView
(
R
.
id
.
tv_start
)
TextView
start
;
@BindView
(
R
.
id
.
et_eventName
)
...
...
@@ -68,11 +79,14 @@ public class AddEventFragment extends Fragment {
@BindView
(
R
.
id
.
map_location
)
EditText
et_mapLocation
;
@BindView
(
R
.
id
.
open
)
ImageView
open
;
ImageView
open
;
@BindView
(
R
.
id
.
close
)
ImageView
close
;
ImageView
close
;
ImageView
eventPictureImageView
;
int
publicStatus
;
View
view
;
String
base64Image
;
ProgressDialog
progressDialog
;
public
AddEventFragment
()
{
...
...
@@ -88,6 +102,9 @@ public class AddEventFragment extends Fragment {
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_add_event
,
container
,
false
);
ButterKnife
.
bind
(
this
,
view
);
eventPictureImageView
=
view
.
findViewById
(
R
.
id
.
ib_eventImage
);
progressDialog
=
new
ProgressDialog
(
getContext
());
cb_permission
.
setVisibility
(
View
.
GONE
);
cb_public
.
setVisibility
(
View
.
GONE
);
et_mapLocation
.
setVisibility
(
View
.
GONE
);
...
...
@@ -195,18 +212,17 @@ public class AddEventFragment extends Fragment {
imageButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Toast
.
makeText
(
getContext
(),
"Add Image"
,
Toast
.
LENGTH_SHORT
).
show
(
);
//TODO (1) upload image to server
Intent
i
=
new
Intent
(
Intent
.
ACTION_PICK
,
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
startActivityForResult
(
i
,
RESULT_LOAD_IMAGE
);
}
});
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
();
progressDialog
.
setIndeterminate
(
true
);
progressDialog
.
setCancelable
(
false
);
progressDialog
.
show
();
sendImage
();
}
});
...
...
@@ -214,20 +230,109 @@ public class AddEventFragment extends Fragment {
return
view
;
}
public
void
addEvent
()
{
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"
}));
private
void
sendImage
()
{
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
.
createEvent
(
eventCreateRequest
).
enqueue
(
new
Callback
<
EventCreateResponse
>()
{
@Override
public
void
onResponse
(
Call
<
EventCreateResponse
>
call
,
Response
<
EventCreateResponse
>
response
)
{
Toast
.
makeText
(
getContext
(),
"Event Created"
,
Toast
.
LENGTH_SHORT
).
show
();
progressDialog
.
dismiss
();
}
@Override
public
void
onFailure
(
Call
<
EventCreateResponse
>
call
,
Throwable
t
)
{
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
;
}
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
View file @
933a0165
...
...
@@ -12,6 +12,10 @@ import android.widget.TextView;
import
com.google.gson.Gson
;
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.R
;
import
in.ac.iitb.gymkhana.iitbapp.data.Event
;
...
...
@@ -46,13 +50,21 @@ public class EventFragment extends Fragment {
private
void
inflateViews
(
Event
event
)
{
ImageView
eventPicture
=
(
ImageView
)
getActivity
().
findViewById
(
R
.
id
.
event_picture_2
);
TextView
eventTitle
=
(
TextView
)
getActivity
().
findViewById
(
R
.
id
.
event_title_2
);
TextView
eventDetails
=
(
TextView
)
getActivity
().
findViewById
(
R
.
id
.
event_details_2
);
TextView
eventDescription
=
(
TextView
)
getActivity
().
findViewById
(
R
.
id
.
event_description_2
);
TextView
eventTitle
=
(
TextView
)
getActivity
().
findViewById
(
R
.
id
.
event_page_title
);
TextView
eventDate
=
(
TextView
)
getActivity
().
findViewById
(
R
.
id
.
event_page_date
);
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
);
eventTitle
.
setText
(
event
.
getEventName
());
eventDetails
.
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
());
}
}
app/src/main/res/drawable-hdpi/ic_action_add.png
0 → 100644
View file @
933a0165
139 Bytes
app/src/main/res/drawable-mdpi/ic_action_add.png
0 → 100644
View file @
933a0165
121 Bytes
app/src/main/res/drawable-xhdpi/ic_action_add.png
0 → 100644
View file @
933a0165
174 Bytes
app/src/main/res/drawable-xxhdpi/ic_action_add.png
0 → 100644
View file @
933a0165
246 Bytes
app/src/main/res/drawable-xxxhdpi/ic_action_add.png
0 → 100644
View file @
933a0165
477 Bytes
app/src/main/res/layout/feed_card.xml
0 → 100644
View file @
933a0165
<?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
app/src/main/res/layout/fragment_event.xml
View file @
933a0165
...
...
@@ -2,56 +2,158 @@
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:orientation=
"vertical"
tools:context=
"in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment"
>
<ImageView
android:id=
"@+id/event_picture_2"
android:layout_width=
"match_parent"
android:layout_height=
"360dp"
android:scaleType=
"centerCrop"
/>
android:layout_height=
"0dp"
android:scaleType=
"centerCrop"
android:layout_weight=
"1"
/>
<TextView
android:id=
"@+id/event_title_2"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
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_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
android:id=
"@+id/event_details_2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/event_page_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textSize=
"28sp"
android:textColor=
"#fff"
android:text=
"Event Title"
/>
<LinearLayout
style=
"?android:attr/buttonBarStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:orientation=
"horizontal"
>
<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>
<Button
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"Going"
/>
<Button
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
<LinearLayout
style=
"?android:attr/buttonBarStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"Interested"
/>
android:orientation=
"horizontal"
>
<Button
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
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"
>
<Button
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
</View>
<Button
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
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
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"Not Going"
android:layout_margin=
"0dp"
android:textColor=
"@color/colorGray"
/>
</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
android:id=
"@+id/event_page_description"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"Not Going"
/>
android:layout_marginTop=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:textColor=
"#777"
android:textSize=
"16sp"
/>
</LinearLayout>
<TextView
android:id=
"@+id/event_description_2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
app/src/main/res/layout/fragment_feed.xml
View file @
933a0165
...
...
@@ -8,6 +8,7 @@
<android.support.v7.widget.RecyclerView
android:id=
"@+id/feed_recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
android:paddingTop=
"8dp"
/>
</android.support.v4.widget.SwipeRefreshLayout>
app/src/main/res/layout/post.xml
deleted
100644 → 0
View file @
ccac092a
<?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
build.gradle
View file @
933a0165
...
...
@@ -5,11 +5,13 @@ buildscript {
repositories
{
maven
{
url
'https://maven.google.com'
}
jcenter
()
google
()
}
dependencies
{
classpath
'com.android.tools.build:gradle:3.0.1'
classpath
'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
...
...
@@ -19,6 +21,7 @@ allprojects {
repositories
{
jcenter
()
maven
{
url
'https://maven.google.com'
}
google
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment