use of forpdateam.ru.forpda.model.SchedulersProvider in project ForPDA by RadiationX.
the class NotificationsService method sendNotification.
public void sendNotification(NotificationEvent event) {
Log.e("kulolo", "sendNotification " + event.notifyId());
if (notificationPreferencesHolder.getMainAvatarsEnabled()) {
SchedulersProvider schedulers = App.get().Di().getSchedulers();
Disposable disposable = avatarRepository.getAvatar(event.getUserId(), event.getUserNick()).flatMap((Function<String, SingleSource<Bitmap>>) s -> {
return Single.fromCallable(() -> ImageLoader.getInstance().loadImageSync(s)).subscribeOn(schedulers.io()).observeOn(schedulers.ui());
}).onErrorReturn(throwable -> ImageLoader.getInstance().loadImageSync("assets://av.png")).map(bitmap -> {
if (bitmap != null) {
Resources res = App.getContext().getResources();
int height = (int) res.getDimension(android.R.dimen.notification_large_icon_height);
int width = (int) res.getDimension(android.R.dimen.notification_large_icon_width);
boolean isCircle = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
bitmap = BitmapUtils.centerCrop(bitmap, width, height, 1.0f);
bitmap = BitmapUtils.createAvatar(bitmap, width, height, isCircle);
}
return bitmap;
}).subscribe(avatar -> sendNotification(event, avatar), Throwable::printStackTrace);
addToDisposable(disposable);
} else {
sendNotification(event, null);
}
}
Aggregations