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
8085eeff
Commit
8085eeff
authored
Jul 28, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update profile on create MainActivity
parent
833f19e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
app/src/main/java/app/insti/MainActivity.java
app/src/main/java/app/insti/MainActivity.java
+29
-1
app/src/main/java/app/insti/api/RetrofitInterface.java
app/src/main/java/app/insti/api/RetrofitInterface.java
+3
-0
No files found.
app/src/main/java/app/insti/MainActivity.java
View file @
8085eeff
...
...
@@ -19,13 +19,14 @@ import android.view.Menu;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.webkit.WebChromeClient
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.squareup.picasso.Picasso
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.api.UnsafeOkHttpClient
;
import
app.insti.data.Body
;
import
app.insti.data.Event
;
...
...
@@ -48,6 +49,9 @@ import app.insti.fragment.QuickLinksFragment;
import
app.insti.fragment.SettingsFragment
;
import
app.insti.fragment.TrainingBlogFragment
;
import
app.insti.notifications.NotificationEventReceiver
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_ACCESS_LOCATION
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
;
...
...
@@ -75,6 +79,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
setContentView
(
R
.
layout
.
activity_main
);
session
=
new
SessionManager
(
getApplicationContext
());
updateProfile
();
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
...
...
@@ -121,6 +127,28 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
private
void
updateProfile
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
if
(
session
.
isLoggedIn
())
{
retrofitInterface
.
getUserMe
(
getSessionIDHeader
()).
enqueue
(
new
Callback
<
User
>()
{
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
if
(
response
.
isSuccessful
())
{
session
.
createLoginSession
(
response
.
body
().
getUserLDAPId
(),
response
.
body
(),
session
.
getSessionID
());
currentUser
=
response
.
body
();
}
else
{
session
.
logout
();
currentUser
=
null
;
Toast
.
makeText
(
MainActivity
.
this
,
"You session has expired!"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
@Override
public
void
onFailure
(
Call
<
User
>
call
,
Throwable
t
)
{
}
});
}
}
private
String
getID
(
String
appLinkData
)
{
if
(
appLinkData
.
charAt
(
appLinkData
.
length
()
-
1
)
==
'/'
)
appLinkData
=
appLinkData
.
substring
(
0
,
appLinkData
.
length
()
-
1
);
...
...
app/src/main/java/app/insti/api/RetrofitInterface.java
View file @
8085eeff
...
...
@@ -65,6 +65,9 @@ public interface RetrofitInterface {
@POST
(
"upload"
)
Call
<
ImageUploadResponse
>
uploadImage
(
@Header
(
"Cookie"
)
String
sessionID
,
@Body
ImageUploadRequest
imageUploadRequest
);
@GET
(
"user-me"
)
Call
<
User
>
getUserMe
(
@Header
(
"Cookie"
)
String
sessionId
);
@GET
(
"user-me/ues/{eventID}"
)
Call
<
Void
>
updateUserEventStatus
(
@Header
(
"Cookie"
)
String
sessionID
,
@Path
(
"eventID"
)
String
eventID
,
@Query
(
"status"
)
int
status
);
...
...
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