Commit 76366bc3 authored by Varun Patil's avatar Varun Patil

Do not create async task in background process

parent 57049bc9
...@@ -130,46 +130,37 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService { ...@@ -130,46 +130,37 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService {
final Context context, final String imageUrl, final String largeIconUrl, final Context context, final String imageUrl, final String largeIconUrl,
final int notification_id, final NotificationCompat.Builder builder, final String content){ final int notification_id, final NotificationCompat.Builder builder, final String content){
new AsyncTask<Void, Void, Bitmap[]>() { Bitmap[] bitmaps = null;
@Override try {
protected Bitmap[] doInBackground(Void... params) { Bitmap image = null;
try { if (imageUrl != null) {
Bitmap image = null; image = Picasso.get().load(imageUrl).get();
if (imageUrl != null) {
image = Picasso.get().load(imageUrl).get();
}
Bitmap largeIcon = null;
if (largeIconUrl != null) {
largeIcon = getCroppedBitmap(
Picasso.get().load(Constants.resizeImageUrl(largeIconUrl, 200)).get(), 200);
}
return new Bitmap[]{image, largeIcon};
} catch (IOException e) {
e.printStackTrace();
} }
return null; Bitmap largeIcon = null;
} if (largeIconUrl != null) {
largeIcon = getCroppedBitmap(
@Override Picasso.get().load(Constants.resizeImageUrl(largeIconUrl, 200)).get(), 200);
protected void onPostExecute(Bitmap[] bitmaps) {
// Check if we loaded big image
if (bitmaps != null && bitmaps[0] != null) {
builder.setStyle(
new NotificationCompat.BigPictureStyle()
.bigPicture(bitmaps[0])
.setSummaryText(content)
);
} }
bitmaps = new Bitmap[]{image, largeIcon};
} catch (IOException e) {
e.printStackTrace();
}
// Check if we loaded large icon // Check if we loaded big image
if (bitmaps != null && bitmaps[1] != null) { if (bitmaps != null && bitmaps[0] != null) {
builder.setLargeIcon(bitmaps[1]); builder.setStyle(
} new NotificationCompat.BigPictureStyle()
.bigPicture(bitmaps[0])
.setSummaryText(content)
);
}
showNotification(context, notification_id, builder.build()); // Check if we loaded large icon
super.onPostExecute(bitmaps); if (bitmaps != null && bitmaps[1] != null) {
builder.setLargeIcon(bitmaps[1]);
} }
}.execute();
showNotification(context, notification_id, builder.build());
} }
/** Get circular center cropped bitmap */ /** Get circular center cropped bitmap */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment