use of forpdateam.ru.forpda.entity.remote.events.NotificationEvent in project ForPDA by RadiationX.
the class NotificationsService method createStackedContent.
private CharSequence createStackedContent(List<NotificationEvent> events) {
StringBuilder content = new StringBuilder();
int size = Math.min(events.size(), STACKED_MAX);
for (int i = 0; i < size; i++) {
NotificationEvent event = events.get(i);
if (event.fromQms()) {
String nick = event.getUserNick();
if (nick == null || nick.isEmpty())
nick = "Сообщения 4PDA";
content.append("<b>").append(nick).append("</b>");
content.append(": ").append(event.getSourceTitle());
} else if (event.fromTheme()) {
content.append(event.getSourceTitle());
}
if (i < size - 1) {
content.append("<br>");
}
}
if (events.size() > size) {
content.append("<br>");
content.append("...и еще ").append(events.size() - size);
}
return ApiUtils.spannedFromHtml(content.toString());
}
use of forpdateam.ru.forpda.entity.remote.events.NotificationEvent 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);
}
}
use of forpdateam.ru.forpda.entity.remote.events.NotificationEvent in project ForPDA by RadiationX.
the class NotificationEventsApi method getFavoritesEvents.
public List<NotificationEvent> getFavoritesEvents(String response) {
List<NotificationEvent> events = new ArrayList<>();
Matcher matcher = inspectorFavoritesPattern.matcher(response);
while (matcher.find()) {
// Log.e("events_lalala", "Matcher add event: " + matcher.group());
NotificationEvent event = getFavoritesEvent(matcher);
events.add(event);
}
return events;
}
Aggregations