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
c09b5ecd
Commit
c09b5ecd
authored
Oct 01, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update feed events global cache on changing going/interested
parent
9b5e97d6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
20 deletions
+57
-20
.idea/vcs.xml
.idea/vcs.xml
+0
-6
app/src/main/java/app/insti/UpdatableList.java
app/src/main/java/app/insti/UpdatableList.java
+30
-0
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+3
-1
app/src/main/java/app/insti/api/model/Event.java
app/src/main/java/app/insti/api/model/Event.java
+14
-0
app/src/main/java/app/insti/fragment/EventFragment.java
app/src/main/java/app/insti/fragment/EventFragment.java
+4
-1
app/src/main/java/app/insti/fragment/FeedFragment.java
app/src/main/java/app/insti/fragment/FeedFragment.java
+6
-12
No files found.
.idea/vcs.xml
deleted
100644 → 0
View file @
9b5e97d6
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
app/src/main/java/app/insti/UpdatableList.java
0 → 100644
View file @
c09b5ecd
package
app.insti
;
import
android.os.Handler
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
UpdatableList
<
T
>
extends
ArrayList
<
T
>
{
private
List
<
T
>
cache
=
new
ArrayList
<>();
public
List
<
T
>
getCache
()
{
return
cache
;
}
public
void
setCache
(
List
<
T
>
mCache
)
{
cache
=
mCache
;
}
/** Update existing or add */
public
void
updateCache
(
T
t
)
{
for
(
int
i
=
0
;
i
<
cache
.
size
();
i
++)
{
T
cachedEvent
=
cache
.
get
(
i
);
if
(
cachedEvent
.
equals
(
t
))
{
cache
.
set
(
i
,
t
);
return
;
}
}
cache
.
add
(
t
);
}
}
app/src/main/java/app/insti/Utils.java
View file @
c09b5ecd
...
...
@@ -5,9 +5,11 @@ import android.widget.ImageView;
import
com.squareup.picasso.Callback
;
import
com.squareup.picasso.Picasso
;
import
java.time.Insta
nt
;
import
app.insti.api.model.Eve
nt
;
public
final
class
Utils
{
public
static
UpdatableList
<
Event
>
eventCache
=
new
UpdatableList
<>();
public
static
final
void
loadImageWithPlaceholder
(
final
ImageView
imageView
,
final
String
url
)
{
Picasso
.
get
()
.
load
(
resizeImageUrl
(
url
))
...
...
app/src/main/java/app/insti/api/model/Event.java
View file @
c09b5ecd
...
...
@@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.Objects
;
public
class
Event
{
@NonNull
()
...
...
@@ -223,4 +224,17 @@ public class Event {
public
void
setEventBigImage
(
boolean
eventBigImage
)
{
this
.
eventBigImage
=
eventBigImage
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Event
event
=
(
Event
)
o
;
return
Objects
.
equals
(
eventID
,
event
.
eventID
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
eventID
);
}
}
app/src/main/java/app/insti/fragment/EventFragment.java
View file @
c09b5ecd
...
...
@@ -40,9 +40,9 @@ import java.util.Date;
import
java.util.List
;
import
app.insti.Constants
;
import
app.insti.Utils
;
import
app.insti.R
;
import
app.insti.ShareURLMaker
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.BodyAdapter
;
import
app.insti.api.RetrofitInterface
;
...
...
@@ -306,6 +306,9 @@ public class EventFragment extends BackHandledFragment {
event
.
setEventUserUes
(
endStatus
);
setFollowButtonColors
(
endStatus
);
// Update global memory cache
Utils
.
eventCache
.
updateCache
(
event
);
}
}
...
...
app/src/main/java/app/insti/fragment/FeedFragment.java
View file @
c09b5ecd
...
...
@@ -5,8 +5,6 @@ import android.app.Activity;
import
android.os.Bundle
;
import
android.support.design.widget.FloatingActionButton
;
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
;
...
...
@@ -15,19 +13,16 @@ import android.view.LayoutInflater;
import
android.view.View
;
import
android.view.ViewGroup
;
import
com.google.gson.Gson
;
import
java.util.List
;
import
app.insti.ActivityBuffer
;
import
app.insti.Constants
;
import
app.insti.interfaces.ItemClickListener
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.response.NewsFeedResponse
;
import
app.insti.api.model.Event
;
import
app.insti.api.response.NewsFeedResponse
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
...
...
@@ -42,7 +37,6 @@ public class FeedFragment extends BaseFragment {
private
FloatingActionButton
fab
;
LinearLayoutManager
mLayoutManager
;
public
static
int
index
=
-
1
,
top
=
-
1
;
public
static
List
<
Event
>
eventList
=
null
;
private
FeedAdapter
feedAdapter
=
null
;
public
FeedFragment
()
{
...
...
@@ -78,10 +72,10 @@ public class FeedFragment extends BaseFragment {
fab
=
getView
().
findViewById
(
R
.
id
.
fab
);
// Initialize the feed
if
(
eventList
==
null
)
{
if
(
Utils
.
eventCache
.
getCache
()
==
null
||
Utils
.
eventCache
.
getCache
().
size
()
==
0
)
{
updateFeed
();
}
else
{
displayEvents
(
eventList
);
displayEvents
(
Utils
.
eventCache
.
getCache
()
);
}
}
...
...
@@ -111,8 +105,8 @@ public class FeedFragment extends BaseFragment {
@Override
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
if
(
response
.
isSuccessful
())
{
eventList
=
response
.
body
().
getEvents
(
);
displayEvents
(
eventList
);
Utils
.
eventCache
.
setCache
(
response
.
body
().
getEvents
()
);
displayEvents
(
Utils
.
eventCache
.
getCache
()
);
}
//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