fix poll voting in NotificationFragment (#1234)
This commit is contained in:
parent
28a76c1a5f
commit
8f57dddd61
1 changed files with 18 additions and 7 deletions
|
@ -267,7 +267,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
findReplyPosition(event.getStatusId());
|
findReplyPosition(event.getStatusId());
|
||||||
if (posAndNotification == null) return;
|
if (posAndNotification == null) return;
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
setFavovouriteForStatus(posAndNotification.first,
|
setFavouriteForStatus(posAndNotification.first,
|
||||||
posAndNotification.second.getStatus(),
|
posAndNotification.second.getStatus(),
|
||||||
event.getFavourite());
|
event.getFavourite());
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
hideFab = preferences.getBoolean("fabHide", false);
|
hideFab = preferences.getBoolean("fabHide", false);
|
||||||
scrollListener = new EndlessOnScrollListener(layoutManager) {
|
scrollListener = new EndlessOnScrollListener(layoutManager) {
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(RecyclerView view, int dx, int dy) {
|
public void onScrolled(@NonNull RecyclerView view, int dx, int dy) {
|
||||||
super.onScrolled(view, dx, dy);
|
super.onScrolled(view, dx, dy);
|
||||||
|
|
||||||
ActionButtonActivity activity = (ActionButtonActivity) getActivity();
|
ActionButtonActivity activity = (ActionButtonActivity) getActivity();
|
||||||
|
@ -401,13 +401,13 @@ public class NotificationsFragment extends SFragment implements
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.as(autoDisposable(from(this)))
|
.as(autoDisposable(from(this)))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(newStatus) -> setFavovouriteForStatus(position, status, favourite),
|
(newStatus) -> setFavouriteForStatus(position, status, favourite),
|
||||||
(t) -> Log.d(getClass().getSimpleName(),
|
(t) -> Log.d(getClass().getSimpleName(),
|
||||||
"Failed to favourite status: " + status.getId(), t)
|
"Failed to favourite status: " + status.getId(), t)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFavovouriteForStatus(int position, Status status, boolean favourite) {
|
private void setFavouriteForStatus(int position, Status status, boolean favourite) {
|
||||||
status.setFavourited(favourite);
|
status.setFavourited(favourite);
|
||||||
|
|
||||||
if (status.getReblog() != null) {
|
if (status.getReblog() != null) {
|
||||||
|
@ -442,7 +442,18 @@ public class NotificationsFragment extends SFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVoteForPoll(int position, Poll poll) {
|
private void setVoteForPoll(int position, Poll poll) {
|
||||||
// TODO
|
|
||||||
|
NotificationViewData.Concrete viewdata = (NotificationViewData.Concrete) notifications.getPairedItem(position);
|
||||||
|
|
||||||
|
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
|
||||||
|
viewDataBuilder.setPoll(poll);
|
||||||
|
|
||||||
|
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
||||||
|
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
||||||
|
viewDataBuilder.createStatusViewData(), viewdata.isExpanded());
|
||||||
|
|
||||||
|
notifications.setPairedItem(position, newViewData);
|
||||||
|
updateAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -452,7 +463,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewMedia(int position, int attachmentIndex, @NonNull View view) {
|
public void onViewMedia(int position, int attachmentIndex, @Nullable View view) {
|
||||||
Notification notification = notifications.get(position).asRightOrNull();
|
Notification notification = notifications.get(position).asRightOrNull();
|
||||||
if (notification == null || notification.getStatus() == null) return;
|
if (notification == null || notification.getStatus() == null) return;
|
||||||
super.viewMedia(attachmentIndex, notification.getStatus(), view);
|
super.viewMedia(attachmentIndex, notification.getStatus(), view);
|
||||||
|
@ -1099,7 +1110,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areContentsTheSame(NotificationViewData oldItem, NotificationViewData newItem) {
|
public boolean areContentsTheSame(@NonNull NotificationViewData oldItem, @NonNull NotificationViewData newItem) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue