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
8d98957b
Commit
8d98957b
authored
Oct 01, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache events response in memory in feed fragment
parent
37369aef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
app/src/main/java/app/insti/fragment/FeedFragment.java
app/src/main/java/app/insti/fragment/FeedFragment.java
+12
-10
No files found.
app/src/main/java/app/insti/fragment/FeedFragment.java
View file @
8d98957b
...
...
@@ -40,16 +40,15 @@ public class FeedFragment extends BaseFragment {
private
RecyclerView
feedRecyclerView
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
private
FloatingActionButton
fab
;
private
boolean
freshEventsDisplayed
=
false
;
LinearLayoutManager
mLayoutManager
;
public
static
int
index
=
-
1
,
top
=
-
1
;
public
static
List
<
Event
>
eventList
=
null
;
private
FeedAdapter
feedAdapter
=
null
;
public
FeedFragment
()
{
// Required empty public constructor
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
...
...
@@ -76,8 +75,14 @@ public class FeedFragment extends BaseFragment {
@Override
public
void
onStart
()
{
super
.
onStart
();
fab
=
(
FloatingActionButton
)
getView
().
findViewById
(
R
.
id
.
fab
);
updateFeed
();
fab
=
getView
().
findViewById
(
R
.
id
.
fab
);
// Initialize the feed
if
(
eventList
==
null
)
{
updateFeed
();
}
else
{
displayEvents
(
eventList
);
}
}
...
...
@@ -94,8 +99,7 @@ public class FeedFragment extends BaseFragment {
public
void
onResume
()
{
super
.
onResume
();
if
(
index
!=
-
1
)
{
if
(
index
!=
-
1
)
{
mLayoutManager
.
scrollToPositionWithOffset
(
index
,
top
);
}
}
...
...
@@ -107,10 +111,8 @@ public class FeedFragment extends BaseFragment {
@Override
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
if
(
response
.
isSuccessful
())
{
NewsFeedResponse
newsFeedResponse
=
response
.
body
();
List
<
Event
>
events
=
newsFeedResponse
.
getEvents
();
freshEventsDisplayed
=
true
;
displayEvents
(
events
);
eventList
=
response
.
body
().
getEvents
();
displayEvents
(
eventList
);
}
//Server Error
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
...
...
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