use of com.hannesdorfmann.mosby3.sample.mail.model.event.MailReceivedEvent in project mosby by sockeqwe.
the class GcmFakeIntentService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
Mail mail = intent.getParcelableExtra(KEY_MAIL);
// simulate network / receiving delay
try {
Thread.sleep(3000);
} catch (Exception e) {
}
mail.label(Label.INBOX);
mailProvider.addMail(mail).subscribe();
eventBus.post(new MailReceivedEvent(mail));
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());
Intent startIntent = intentStarter.getShowMailInNewActivityIntent(getApplicationContext(), mail);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, startIntent, 0);
builder.setContentIntent(pendingIntent);
builder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), mail.getSender().getImageRes()));
builder.setSmallIcon(R.mipmap.ic_launcher).setLights(getResources().getColor(R.color.primary), 1800, 3500).setAutoCancel(true).setContentTitle(mail.getSubject()).setContentText(mail.getText()).setWhen(mail.getDate().getTime()).setVibrate(new long[] { 1000, 1000 });
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(mail.getId(), builder.build());
}
Aggregations