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
76098da6
Commit
76098da6
authored
Sep 30, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark notification read on click
parent
3c4771b5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
2 deletions
+24
-2
app/src/main/java/app/insti/Constants.java
app/src/main/java/app/insti/Constants.java
+1
-0
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+9
-0
app/src/main/java/app/insti/api/EmptyCallback.java
app/src/main/java/app/insti/api/EmptyCallback.java
+12
-0
app/src/main/java/app/insti/api/RetrofitInterface.java
app/src/main/java/app/insti/api/RetrofitInterface.java
+1
-1
app/src/main/java/app/insti/fragment/NotificationsFragment.java
...c/main/java/app/insti/fragment/NotificationsFragment.java
+1
-1
No files found.
app/src/main/java/app/insti/Constants.java
View file @
76098da6
...
@@ -32,6 +32,7 @@ public class Constants {
...
@@ -32,6 +32,7 @@ public class Constants {
public
static
final
String
FCM_BUNDLE_TYPE
=
"type"
;
public
static
final
String
FCM_BUNDLE_TYPE
=
"type"
;
public
static
final
String
FCM_BUNDLE_ID
=
"id"
;
public
static
final
String
FCM_BUNDLE_ID
=
"id"
;
public
static
final
String
FCM_BUNDLE_EXTRA
=
"extra"
;
public
static
final
String
FCM_BUNDLE_EXTRA
=
"extra"
;
public
static
final
String
FCM_BUNDLE_NOTIFICATION_ID
=
"notification_id"
;
public
static
final
String
DATA_TYPE_EVENT
=
"event"
;
public
static
final
String
DATA_TYPE_EVENT
=
"event"
;
public
static
final
String
DATA_TYPE_BODY
=
"body"
;
public
static
final
String
DATA_TYPE_BODY
=
"body"
;
...
...
app/src/main/java/app/insti/activity/MainActivity.java
View file @
76098da6
...
@@ -43,6 +43,7 @@ import java.util.List;
...
@@ -43,6 +43,7 @@ import java.util.List;
import
app.insti.Constants
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.SessionManager
;
import
app.insti.SessionManager
;
import
app.insti.api.EmptyCallback
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.Body
;
import
app.insti.data.Body
;
...
@@ -78,6 +79,7 @@ import static app.insti.Constants.DATA_TYPE_EVENT;
...
@@ -78,6 +79,7 @@ import static app.insti.Constants.DATA_TYPE_EVENT;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_NEWS
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_NEWS
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_PT
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_PT
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_USER
;
import
static
app
.
insti
.
Constants
.
DATA_TYPE_USER
;
import
static
app
.
insti
.
Constants
.
FCM_BUNDLE_NOTIFICATION_ID
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_ACCESS_LOCATION
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_ACCESS_LOCATION
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
;
import
static
app
.
insti
.
Constants
.
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
;
import
static
app
.
insti
.
Constants
.
RESULT_LOAD_IMAGE
;
import
static
app
.
insti
.
Constants
.
RESULT_LOAD_IMAGE
;
...
@@ -261,6 +263,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -261,6 +263,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/** Handle opening event/body/blog from FCM notification */
/** Handle opening event/body/blog from FCM notification */
private
void
handleFCMIntent
(
Bundle
bundle
)
{
private
void
handleFCMIntent
(
Bundle
bundle
)
{
/* Mark the notification read */
final
String
notificationId
=
bundle
.
getString
(
FCM_BUNDLE_NOTIFICATION_ID
);
if
(
notificationId
!=
null
)
{
getRetrofitInterface
().
markNotificationRead
(
getSessionIDHeader
(),
notificationId
).
enqueue
(
new
EmptyCallback
<
Void
>());
}
/* Follow the notification */
chooseIntent
(
chooseIntent
(
bundle
.
getString
(
Constants
.
FCM_BUNDLE_TYPE
),
bundle
.
getString
(
Constants
.
FCM_BUNDLE_TYPE
),
bundle
.
getString
(
Constants
.
FCM_BUNDLE_ID
),
bundle
.
getString
(
Constants
.
FCM_BUNDLE_ID
),
...
...
app/src/main/java/app/insti/api/EmptyCallback.java
0 → 100644
View file @
76098da6
package
app.insti.api
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
EmptyCallback
<
T
>
implements
Callback
<
T
>
{
@Override
public
void
onResponse
(
Call
<
T
>
call
,
Response
<
T
>
response
)
{}
@Override
public
void
onFailure
(
Call
<
T
>
call
,
Throwable
t
)
{}
}
app/src/main/java/app/insti/api/RetrofitInterface.java
View file @
76098da6
...
@@ -100,7 +100,7 @@ public interface RetrofitInterface {
...
@@ -100,7 +100,7 @@ public interface RetrofitInterface {
Call
<
List
<
Notification
>>
getNotifications
(
@Header
(
"Cookie"
)
String
sessionID
);
Call
<
List
<
Notification
>>
getNotifications
(
@Header
(
"Cookie"
)
String
sessionID
);
@GET
(
"notifications/read/{notificationID}"
)
@GET
(
"notifications/read/{notificationID}"
)
Call
<
Void
>
markNotificationRead
(
@Header
(
"Cookie"
)
String
sessionID
,
@Path
(
"notificationID"
)
Integer
notificationID
);
Call
<
Void
>
markNotificationRead
(
@Header
(
"Cookie"
)
String
sessionID
,
@Path
(
"notificationID"
)
String
notificationID
);
@GET
(
"logout"
)
@GET
(
"logout"
)
Call
<
Void
>
logout
(
@Header
(
"Cookie"
)
String
sessionID
);
Call
<
Void
>
logout
(
@Header
(
"Cookie"
)
String
sessionID
);
...
...
app/src/main/java/app/insti/fragment/NotificationsFragment.java
View file @
76098da6
...
@@ -89,7 +89,7 @@ public class NotificationsFragment extends BaseFragment {
...
@@ -89,7 +89,7 @@ public class NotificationsFragment extends BaseFragment {
/* Mark notification read */
/* Mark notification read */
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
();
String
sessId
=
((
MainActivity
)
getActivity
()).
getSessionIDHeader
();
String
sessId
=
((
MainActivity
)
getActivity
()).
getSessionIDHeader
();
retrofitInterface
.
markNotificationRead
(
sessId
,
notification
.
getNotificationId
()).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
markNotificationRead
(
sessId
,
notification
.
getNotificationId
()
.
toString
()
).
enqueue
(
new
Callback
<
Void
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
}
}
...
...
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