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
5ac4a72e
Commit
5ac4a72e
authored
Jul 16, 2017
by
yvsriram
Committed by
GitHub
Jul 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into master
parents
e90b89c4
96935707
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
161 additions
and
27 deletions
+161
-27
.idea/misc.xml
.idea/misc.xml
+1
-1
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/Constants.java
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/Constants.java
+1
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
...c/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
+19
-13
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
...a/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
+58
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/FeedFragment.java
...va/in/ac/iitb/gymkhana/iitbapp/fragment/FeedFragment.java
+20
-2
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/MapFragment.java
...ava/in/ac/iitb/gymkhana/iitbapp/fragment/MapFragment.java
+2
-3
app/src/main/res/layout/fragment_event.xml
app/src/main/res/layout/fragment_event.xml
+57
-0
app/src/main/res/layout/fragment_feed.xml
app/src/main/res/layout/fragment_feed.xml
+3
-2
app/src/main/res/menu/main.xml
app/src/main/res/menu/main.xml
+0
-6
No files found.
.idea/misc.xml
View file @
5ac4a72e
...
...
@@ -24,7 +24,7 @@
</value>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
default=
"true"
project-jdk-name=
"1.8
(1)
"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/Constants.java
View file @
5ac4a72e
...
...
@@ -2,4 +2,5 @@ package in.ac.iitb.gymkhana.iitbapp;
public
class
Constants
{
public
static
final
String
NOTIFICATIONS_RESPONSE_JSON
=
"notifications_json"
;
public
static
final
String
EVENT_JSON
=
"event_json"
;
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
View file @
5ac4a72e
...
...
@@ -51,6 +51,8 @@ public class MainActivity extends AppCompatActivity
private
static
final
String
TAG
=
"MainActivity"
;
SessionManager
session
;
NotificationsResponse
notificationsResponse
;
private
boolean
showNotifications
=
false
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -81,14 +83,11 @@ public class MainActivity extends AppCompatActivity
@Override
public
void
onResponse
(
Call
<
NotificationsResponse
>
call
,
Response
<
NotificationsResponse
>
response
)
{
if
(
response
.
isSuccessful
())
{
NotificationsResponse
notificationsResponse
=
response
.
body
();
String
notificationsResponseJson
=
new
Gson
().
toJson
(
notificationsResponse
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
NOTIFICATIONS_RESPONSE_JSON
,
notificationsResponseJson
);
NotificationsFragment
notificationsFragment
=
new
NotificationsFragment
();
notificationsFragment
.
setArguments
(
bundle
);
updateFragment
(
notificationsFragment
);
notificationsResponse
=
response
.
body
();
if
(
showNotifications
)
{
showNotifications
();
showNotifications
=
false
;
}
}
//Server Error
}
...
...
@@ -100,6 +99,15 @@ public class MainActivity extends AppCompatActivity
});
}
public
void
showNotifications
()
{
String
notificationsResponseJson
=
new
Gson
().
toJson
(
notificationsResponse
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
NOTIFICATIONS_RESPONSE_JSON
,
notificationsResponseJson
);
NotificationsFragment
notificationsFragment
=
new
NotificationsFragment
();
notificationsFragment
.
setArguments
(
bundle
);
updateFragment
(
notificationsFragment
);
}
@Override
public
void
onBackPressed
()
{
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
...
...
@@ -126,10 +134,11 @@ public class MainActivity extends AppCompatActivity
int
id
=
item
.
getItemId
();
//noinspection SimplifiableIfStatement
if
(
id
==
R
.
id
.
action_settings
)
{
if
(
id
==
R
.
id
.
action_notifications
)
{
showNotifications
=
true
;
fetchNotifications
();
return
true
;
}
return
super
.
onOptionsItemSelected
(
item
);
}
...
...
@@ -176,11 +185,8 @@ public class MainActivity extends AppCompatActivity
if
(
ContextCompat
.
checkSelfPermission
(
MainActivity
.
this
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
}
else
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
Manifest
.
permission
.
ACCESS_FINE_LOCATION
},
0
);
break
;
case
R
.
id
.
nav_contacts
:
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
0 → 100644
View file @
5ac4a72e
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.google.gson.Gson
;
import
com.squareup.picasso.Picasso
;
import
in.ac.iitb.gymkhana.iitbapp.Constants
;
import
in.ac.iitb.gymkhana.iitbapp.R
;
import
in.ac.iitb.gymkhana.iitbapp.api.model.Event
;
/**
* A simple {@link Fragment} subclass.
*/
public
class
EventFragment
extends
Fragment
{
public
EventFragment
()
{
// Required empty public constructor
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
return
inflater
.
inflate
(
R
.
layout
.
fragment_event
,
container
,
false
);
}
@Override
public
void
onStart
()
{
super
.
onStart
();
Bundle
bundle
=
getArguments
();
String
eventJson
=
bundle
.
getString
(
Constants
.
EVENT_JSON
);
Event
event
=
new
Gson
().
fromJson
(
eventJson
,
Event
.
class
);
inflateViews
(
event
);
}
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
);
Picasso
.
with
(
getContext
()).
load
(
event
.
getEventImage
()).
into
(
eventPicture
);
eventTitle
.
setText
(
event
.
getEventName
());
eventDetails
.
setText
(
event
.
getEventDescription
());
eventDescription
.
setText
(
event
.
getEventDescription
());
}
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/FeedFragment.java
View file @
5ac4a72e
...
...
@@ -7,6 +7,7 @@ import android.os.Bundle;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentManager
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.util.Log
;
...
...
@@ -16,7 +17,9 @@ import android.view.ViewGroup;
import
com.google.gson.Gson
;
import
java.util.ArrayList
;
import
java.util.List
;
import
in.ac.iitb.gymkhana.iitbapp.Constants
;
...
...
@@ -38,7 +41,8 @@ import retrofit2.Response;
*/
public
class
FeedFragment
extends
Fragment
{
RecyclerView
feedRecyclerView
;
private
RecyclerView
feedRecyclerView
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
public
FeedFragment
()
{
// Required empty public constructor
...
...
@@ -87,9 +91,21 @@ public class FeedFragment extends Fragment {
}
updateFeed
();
feedSwipeRefreshLayout
=
(
SwipeRefreshLayout
)
getActivity
().
findViewById
(
R
.
id
.
feed_swipe_refresh_layout
);
feedSwipeRefreshLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
@Override
public
void
onRefresh
()
{
updateFeed
();
}
});
}
private
void
updateFeed
()
{
NewsFeedRequest
newsFeedRequest
=
new
NewsFeedRequest
(
NewsFeedRequest
.
FOLLOWED
,
0
,
20
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
retrofitInterface
.
getNewsFeed
(
newsFeedRequest
).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
retrofitInterface
.
getNewsFeed
().
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
@Override
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
if
(
response
.
isSuccessful
())
{
...
...
@@ -131,11 +147,13 @@ public class FeedFragment extends Fragment {
Log
.
d
(
"FeedFragment"
,
Integer
.
toString
(
insertCount
)
+
" elements inserted"
);
}
//Server Error
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
}
@Override
public
void
onFailure
(
Call
<
NewsFeedResponse
>
call
,
Throwable
t
)
{
//Network Error
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
}
});
}
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/MapFragment.java
View file @
5ac4a72e
...
...
@@ -36,14 +36,13 @@ public class MapFragment extends Fragment implements OnMapReadyCallback {
public
void
onMapReady
(
GoogleMap
gMap
)
{
googleMap
=
gMap
;
googleMap
.
setMyLocationEnabled
(
true
);
googleMap
.
getUiSettings
().
setMyLocationButtonEnabled
(
tru
e
);
googleMap
.
getUiSettings
().
setMyLocationButtonEnabled
(
fals
e
);
googleMap
.
getUiSettings
().
setZoomGesturesEnabled
(
true
);
LatLngBounds
iitbBounds
=
new
LatLngBounds
(
new
LatLng
(
19.1249000
,
72.9046000
),
new
LatLng
(
19.143522
,
72.920000
));
googleMap
.
setLatLngBoundsForCameraTarget
(
iitbBounds
);
googleMap
.
setMaxZoomPreference
(
30
);
googleMap
.
setMinZoomPreference
(
(
float
)
14.5
);
googleMap
.
setMinZoomPreference
(
14.5f
);
// Position the map's camera near Mumbai
LatLng
iitb
=
new
LatLng
(
19.1334
,
72.9133
);
googleMap
.
addMarker
(
new
MarkerOptions
().
position
(
iitb
)
...
...
app/src/main/res/layout/fragment_event.xml
0 → 100644
View file @
5ac4a72e
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
"in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment"
>
<ImageView
android:scaleType=
"centerCrop"
android:id=
"@+id/event_picture_2"
android:layout_width=
"match_parent"
android:layout_height=
"360dp"
/>
<TextView
android:id=
"@+id/event_title_2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/event_details_2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<LinearLayout
android:background=
"@color/colorPrimary"
style=
"?android:attr/buttonBarStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<Button
android:text=
"Going"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
<Button
android:text=
"Interested"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
<Button
android:text=
"Not Going"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
</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 @
5ac4a72e
<
Frame
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
android.support.v4.widget.SwipeRefresh
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/feed_swipe_refresh_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment"
>
...
...
@@ -9,4 +10,4 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</
Frame
Layout>
</
android.support.v4.widget.SwipeRefresh
Layout>
app/src/main/res/menu/main.xml
View file @
5ac4a72e
...
...
@@ -7,10 +7,4 @@
android:icon=
"@drawable/ic_notifications_black_24dp"
android:title=
"Notifications"
app:showAsAction=
"always"
/>
<item
android:id=
"@+id/action_settings"
android:orderInCategory=
"100"
android:title=
"@string/action_settings"
app:showAsAction=
"never"
/>
</menu>
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