use of com.keylesspalace.tusky.entity.Notification in project Tusky by Vavassor.
the class NotificationsFragment method onReblog.
@Override
public void onReblog(final boolean reblog, final int position) {
final Notification notification = notifications.get(position).asRight();
final Status status = notification.getStatus();
Objects.requireNonNull(status, "Reblog on notification without status");
timelineCases.reblog(status.getId(), reblog).observeOn(AndroidSchedulers.mainThread()).to(autoDisposable(from(this))).subscribe((newStatus) -> setReblogForStatus(status.getId(), reblog), (t) -> Log.d(getClass().getSimpleName(), "Failed to reblog status: " + status.getId(), t));
}
use of com.keylesspalace.tusky.entity.Notification in project Tusky by Vavassor.
the class NotificationsFragment method onReply.
public void onReply(int position) {
Notification notification = adapter.getItem(position);
super.reply(notification.status);
}
use of com.keylesspalace.tusky.entity.Notification in project Tusky by Vavassor.
the class PushNotificationClient method onMessageReceived.
private void onMessageReceived(final Context context, String message) {
Log.v(TAG, "Notification received: " + message);
Gson gson = new GsonBuilder().registerTypeAdapter(Spanned.class, new SpannedTypeAdapter()).registerTypeAdapter(StringWithEmoji.class, new StringWithEmojiTypeAdapter()).create();
Notification notification = gson.fromJson(message, Notification.class);
NotificationMaker.make(context, NOTIFY_ID, notification);
}
use of com.keylesspalace.tusky.entity.Notification in project Tusky by tuskyapp.
the class NotificationsFragment method onLoadMore.
@Override
public void onLoadMore(int position) {
// check bounds before accessing list,
if (notifications.size() >= position && position > 0) {
Notification previous = notifications.get(position - 1).getAsRightOrNull();
Notification next = notifications.get(position + 1).getAsRightOrNull();
if (previous == null || next == null) {
Log.e(TAG, "Failed to load more, invalid placeholder position: " + position);
return;
}
sendFetchNotificationsRequest(previous.getId(), next.getId(), FetchEnd.MIDDLE, position);
NotificationViewData notificationViewData = new NotificationViewData.Placeholder(true);
notifications.setPairedItem(position, notificationViewData);
adapter.updateItemWithNotify(position, notificationViewData, false);
} else {
Log.d(TAG, "error loading more");
}
}
use of com.keylesspalace.tusky.entity.Notification in project Tusky by tuskyapp.
the class NotificationsFragment method onReblog.
@Override
public void onReblog(final boolean reblog, final int position) {
final Notification notification = notifications.get(position).getAsRight();
final Status status = notification.getStatus();
timelineCases.reblogWithCallback(status, reblog, new Callback<Status>() {
@Override
public void onResponse(@NonNull Call<Status> call, @NonNull retrofit2.Response<Status> response) {
if (response.isSuccessful()) {
status.setReblogged(reblog);
if (status.getReblog() != null) {
status.getReblog().setReblogged(reblog);
}
NotificationViewData.Concrete viewdata = (NotificationViewData.Concrete) notifications.getPairedItem(position);
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
viewDataBuilder.setReblogged(reblog);
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(viewdata.getType(), viewdata.getId(), viewdata.getAccount(), viewDataBuilder.createStatusViewData(), viewdata.isExpanded());
notifications.setPairedItem(position, newViewData);
adapter.updateItemWithNotify(position, newViewData, false);
}
}
@Override
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
Log.d(getClass().getSimpleName(), "Failed to reblog status: " + status.getId(), t);
}
});
}
Aggregations