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
96935707
Commit
96935707
authored
Jul 16, 2017
by
Sajal Narang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement SwipeRefreshLayout
parent
94ac3f9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
6 deletions
+27
-6
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/FeedFragment.java
...va/in/ac/iitb/gymkhana/iitbapp/fragment/FeedFragment.java
+18
-2
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/MapFragment.java
...ava/in/ac/iitb/gymkhana/iitbapp/fragment/MapFragment.java
+0
-1
app/src/main/res/layout/fragment_event.xml
app/src/main/res/layout/fragment_event.xml
+6
-1
app/src/main/res/layout/fragment_feed.xml
app/src/main/res/layout/fragment_feed.xml
+3
-2
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/FeedFragment.java
View file @
96935707
...
...
@@ -5,6 +5,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.view.LayoutInflater
;
...
...
@@ -33,7 +34,8 @@ import retrofit2.Response;
*/
public
class
FeedFragment
extends
Fragment
{
RecyclerView
feedRecyclerView
;
private
RecyclerView
feedRecyclerView
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
public
FeedFragment
()
{
// Required empty public constructor
...
...
@@ -51,9 +53,21 @@ public class FeedFragment extends Fragment {
public
void
onStart
()
{
super
.
onStart
();
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
())
{
...
...
@@ -79,11 +93,13 @@ public class FeedFragment extends Fragment {
feedRecyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
()));
}
//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 @
96935707
...
...
@@ -39,7 +39,6 @@ public class MapFragment extends Fragment implements OnMapReadyCallback {
googleMap
.
getUiSettings
().
setMyLocationButtonEnabled
(
false
);
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
);
...
...
app/src/main/res/layout/fragment_event.xml
View file @
96935707
...
...
@@ -6,9 +6,10 @@
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=
"
wrap_content
"
/>
android:layout_height=
"
360dp
"
/>
<TextView
android:id=
"@+id/event_title_2"
...
...
@@ -21,24 +22,28 @@
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"
...
...
app/src/main/res/layout/fragment_feed.xml
View file @
96935707
<
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>
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