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
b21a9e47
Commit
b21a9e47
authored
Feb 04, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memcache current user in utils
parent
e79b2aa7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
17 deletions
+25
-17
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+1
-0
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+1
-0
app/src/main/java/app/insti/fragment/SettingsFragment.java
app/src/main/java/app/insti/fragment/SettingsFragment.java
+23
-17
No files found.
app/src/main/java/app/insti/Utils.java
View file @
b21a9e47
...
@@ -45,6 +45,7 @@ public final class Utils {
...
@@ -45,6 +45,7 @@ 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
<>();
public
static
UpdatableList
<
Body
>
bodyCache
=
new
UpdatableList
<>();
public
static
User
currentUserCache
=
null
;
private
static
String
sessionId
;
private
static
String
sessionId
;
private
static
RetrofitInterface
retrofitInterface
;
private
static
RetrofitInterface
retrofitInterface
;
...
...
app/src/main/java/app/insti/activity/MainActivity.java
View file @
b21a9e47
...
@@ -427,6 +427,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -427,6 +427,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
session
.
createLoginSession
(
response
.
body
().
getUserName
(),
response
.
body
(),
session
.
getSessionID
());
session
.
createLoginSession
(
response
.
body
().
getUserName
(),
response
.
body
(),
session
.
getSessionID
());
currentUser
=
response
.
body
();
currentUser
=
response
.
body
();
Utils
.
currentUserCache
=
currentUser
;
}
else
{
}
else
{
session
.
logout
();
session
.
logout
();
currentUser
=
null
;
currentUser
=
null
;
...
...
app/src/main/java/app/insti/fragment/SettingsFragment.java
View file @
b21a9e47
...
@@ -111,24 +111,29 @@ public class SettingsFragment extends PreferenceFragmentCompat {
...
@@ -111,24 +111,29 @@ public class SettingsFragment extends PreferenceFragmentCompat {
toolbar
.
setTitle
(
"Settings"
);
toolbar
.
setTitle
(
"Settings"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_settings
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_settings
);
// Get the user id
if
(
Utils
.
currentUserCache
==
null
)
{
Bundle
bundle
=
getArguments
();
// Get the user id
String
userID
=
bundle
.
getString
(
Constants
.
USER_ID
);
Bundle
bundle
=
getArguments
();
String
userID
=
bundle
.
getString
(
Constants
.
USER_ID
);
// Fill in the user
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
// Fill in the user
retrofitInterface
.
getUser
(
Utils
.
getSessionIDHeader
(),
userID
).
enqueue
(
new
EmptyCallback
<
User
>()
{
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
@Override
retrofitInterface
.
getUser
(
Utils
.
getSessionIDHeader
(),
userID
).
enqueue
(
new
EmptyCallback
<
User
>()
{
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
@Override
if
(
response
.
isSuccessful
())
{
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
if
(
getActivity
()
==
null
||
getView
()
==
null
)
return
;
if
(
response
.
isSuccessful
())
{
User
user
=
response
.
body
();
if
(
getActivity
()
==
null
||
getView
()
==
null
)
return
;
showContactPref
.
setChecked
(
user
.
getShowContactNumber
());
User
user
=
response
.
body
();
showContactPref
.
setEnabled
(
true
);
showContactPref
.
setChecked
(
user
.
getShowContactNumber
());
showContactPref
.
setEnabled
(
true
);
Utils
.
currentUserCache
=
user
;
}
}
}
}
});
});
}
else
{
showContactPref
.
setChecked
(
Utils
.
currentUserCache
.
getShowContactNumber
());
showContactPref
.
setEnabled
(
true
);
}
}
}
public
void
toggleShowContact
(
final
SwitchPreferenceCompat
showContactPref
,
Object
o
)
{
public
void
toggleShowContact
(
final
SwitchPreferenceCompat
showContactPref
,
Object
o
)
{
...
@@ -142,6 +147,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
...
@@ -142,6 +147,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
showContactPref
.
setChecked
(
response
.
body
().
getShowContactNumber
());
showContactPref
.
setChecked
(
response
.
body
().
getShowContactNumber
());
showContactPref
.
setEnabled
(
true
);
showContactPref
.
setEnabled
(
true
);
Utils
.
currentUserCache
=
response
.
body
();
}
else
{
}
else
{
showContactPref
.
setChecked
(!
isChecked
);
showContactPref
.
setChecked
(!
isChecked
);
showContactPref
.
setEnabled
(
true
);
showContactPref
.
setEnabled
(
true
);
...
...
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