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
5a4bc493
Commit
5a4bc493
authored
Sep 04, 2018
by
Sajal Narang
Committed by
GitHub
Sep 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #195 from safwankdb/master, fix #192
Added BigPictureStyle to Notifs
parents
97f3375b
32cdd3ff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
1 deletion
+42
-1
app/src/main/java/app/insti/notifications/NotificationIntentService.java
...va/app/insti/notifications/NotificationIntentService.java
+42
-1
No files found.
app/src/main/java/app/insti/notifications/NotificationIntentService.java
View file @
5a4bc493
...
...
@@ -5,14 +5,21 @@ import android.app.NotificationManager;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.media.Image
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.support.v4.app.JobIntentService
;
import
android.support.v4.app.NotificationCompat
;
import
android.util.Log
;
import
com.squareup.picasso.Picasso
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeUnit
;
import
app.insti.Constants
;
...
...
@@ -27,6 +34,7 @@ import retrofit2.Call;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
NotificationIntentService
extends
JobIntentService
{
public
static
final
String
ACTION_OPEN_EVENT
=
"ACTION_OPEN_EVENT"
;
...
...
@@ -58,6 +66,37 @@ public class NotificationIntentService extends JobIntentService {
return
timeUnit
.
convert
(
diffInMillies
,
TimeUnit
.
MILLISECONDS
);
}
public
static
Bitmap
getImageBitmapFromURL
(
final
String
imageUrl
){
Bitmap
imageBitmap
=
null
;
try
{
imageBitmap
=
new
AsyncTask
<
Void
,
Void
,
Bitmap
>()
{
@Override
protected
Bitmap
doInBackground
(
Void
...
params
)
{
{
int
targetHeight
=
200
;
int
targetWidth
=
200
;
try
{
return
Picasso
.
get
()
.
load
(
String
.
valueOf
(
imageUrl
)).
get
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
}.
execute
().
get
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
return
imageBitmap
;
}
@Override
protected
void
onHandleWork
(
Intent
intent
)
{
Log
.
d
(
getClass
().
getSimpleName
(),
"onHandleIntent, started handling a notification event"
);
...
...
@@ -129,7 +168,9 @@ public class NotificationIntentService extends JobIntentService {
.
setColor
(
getResources
().
getColor
(
R
.
color
.
colorAccent
))
.
setContentText
(
"Event is about to start in "
+
getDateDiff
(
new
Date
(),
event
.
getEventStartTime
(),
TimeUnit
.
MINUTES
)
+
((
getDateDiff
(
new
Date
(),
event
.
getEventStartTime
(),
TimeUnit
.
MINUTES
)
==
1
)
?
" minute."
:
" minutes."
))
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
lotus_white
))
.
setSmallIcon
(
R
.
drawable
.
lotus_white
);
.
setSmallIcon
(
R
.
drawable
.
lotus_white
)
.
setStyle
(
new
NotificationCompat
.
BigPictureStyle
()
.
bigPicture
(
getImageBitmapFromURL
(
event
.
getEventImageURL
())));
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
intent
.
setAction
(
ACTION_OPEN_EVENT
);
...
...
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