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
71db08b4
Commit
71db08b4
authored
Jan 04, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use memory cache for body
parent
3b675d07
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+1
-0
app/src/main/java/app/insti/api/model/Body.java
app/src/main/java/app/insti/api/model/Body.java
+9
-0
app/src/main/java/app/insti/fragment/BodyFragmentNew.java
app/src/main/java/app/insti/fragment/BodyFragmentNew.java
+12
-5
No files found.
app/src/main/java/app/insti/Utils.java
View file @
71db08b4
...
@@ -40,6 +40,7 @@ import app.insti.fragment.UserFragment;
...
@@ -40,6 +40,7 @@ import app.insti.fragment.UserFragment;
public
final
class
Utils
{
public
final
class
Utils
{
public
static
UpdatableList
<
Event
>
eventCache
=
new
UpdatableList
<>();
public
static
UpdatableList
<
Event
>
eventCache
=
new
UpdatableList
<>();
public
static
UpdatableList
<
Notification
>
notificationCache
=
null
;
public
static
UpdatableList
<
Notification
>
notificationCache
=
null
;
public
static
UpdatableList
<
Body
>
bodyCache
=
new
UpdatableList
<>();
private
static
String
sessionId
;
private
static
String
sessionId
;
private
static
RetrofitInterface
retrofitInterface
;
private
static
RetrofitInterface
retrofitInterface
;
...
...
app/src/main/java/app/insti/api/model/Body.java
View file @
71db08b4
...
@@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
...
@@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
app.insti.interfaces.CardInterface
;
import
app.insti.interfaces.CardInterface
;
...
@@ -199,4 +200,12 @@ public class Body implements CardInterface {
...
@@ -199,4 +200,12 @@ public class Body implements CardInterface {
public
String
getAvatarUrl
()
{
public
String
getAvatarUrl
()
{
return
getBodyImageURL
();
return
getBodyImageURL
();
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Body
body
=
(
Body
)
o
;
return
Objects
.
equals
(
bodyID
,
body
.
getBodyID
());
}
}
}
\ No newline at end of file
app/src/main/java/app/insti/fragment/BodyFragmentNew.java
View file @
71db08b4
...
@@ -136,10 +136,16 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
...
@@ -136,10 +136,16 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
/* Initialize */
/* Initialize */
bodyDisplayed
=
false
;
bodyDisplayed
=
false
;
body
=
min_body
;
displayBody
();
int
index
=
Utils
.
bodyCache
.
indexOf
(
min_body
);
if
(
index
<
0
)
{
body
=
min_body
;
updateBody
();
updateBody
();
}
else
{
body
=
Utils
.
bodyCache
.
get
(
index
);
}
displayBody
();
bodySwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
body_swipe_refresh_layout
);
bodySwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
body_swipe_refresh_layout
);
bodySwipeRefreshLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
bodySwipeRefreshLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
...
@@ -166,6 +172,7 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
...
@@ -166,6 +172,7 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
Body
bodyResponse
=
response
.
body
();
Body
bodyResponse
=
response
.
body
();
Utils
.
bodyCache
.
updateCache
(
response
.
body
());
if
(!
bodyDisplayed
)
{
if
(!
bodyDisplayed
)
{
body
=
bodyResponse
;
body
=
bodyResponse
;
...
@@ -185,7 +192,7 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
...
@@ -185,7 +192,7 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
private
void
displayBody
()
{
private
void
displayBody
()
{
/* Skip if we're already destroyed */
/* Skip if we're already destroyed */
if
(
getActivity
()
==
null
||
getView
()
==
null
)
return
;
if
(
getActivity
()
==
null
||
getView
()
==
null
)
return
;
if
(!
body
.
equals
(
min_body
))
bodyDisplayed
=
true
;
if
(!
(
body
==
min_body
))
bodyDisplayed
=
true
;
bodyPicture
=
(
ImageView
)
getActivity
().
findViewById
(
R
.
id
.
body_picture
);
bodyPicture
=
(
ImageView
)
getActivity
().
findViewById
(
R
.
id
.
body_picture
);
...
@@ -197,7 +204,7 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
...
@@ -197,7 +204,7 @@ public class BodyFragmentNew extends BackHandledFragment implements TransitionTa
}
}
/* Skip for min body */
/* Skip for min body */
if
(
body
.
equals
(
min_body
)
)
{
if
(
body
==
min_body
)
{
return
;
return
;
}
}
...
...
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