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

Do not create async task in background process

parent 57049bc9
...@@ -130,9 +130,7 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService { ...@@ -130,9 +130,7 @@ 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
protected Bitmap[] doInBackground(Void... params) {
try { try {
Bitmap image = null; Bitmap image = null;
if (imageUrl != null) { if (imageUrl != null) {
...@@ -143,15 +141,11 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService { ...@@ -143,15 +141,11 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService {
largeIcon = getCroppedBitmap( largeIcon = getCroppedBitmap(
Picasso.get().load(Constants.resizeImageUrl(largeIconUrl, 200)).get(), 200); Picasso.get().load(Constants.resizeImageUrl(largeIconUrl, 200)).get(), 200);
} }
return new Bitmap[]{image, largeIcon}; bitmaps = new Bitmap[]{image, largeIcon};
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null;
}
@Override
protected void onPostExecute(Bitmap[] bitmaps) {
// Check if we loaded big image // Check if we loaded big image
if (bitmaps != null && bitmaps[0] != null) { if (bitmaps != null && bitmaps[0] != null) {
builder.setStyle( builder.setStyle(
...@@ -167,9 +161,6 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService { ...@@ -167,9 +161,6 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService {
} }
showNotification(context, notification_id, builder.build()); showNotification(context, notification_id, builder.build());
super.onPostExecute(bitmaps);
}
}.execute();
} }
/** 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