1
0
mirror of https://github.com/tuskyapp/Tusky synced 2024-12-26 16:54:39 +01:00

fix poll voting in NotificationFragment (#1234)

This commit is contained in:
Konrad Pozniak 2019-05-03 20:42:13 +02:00 committed by GitHub
parent 28a76c1a5f
commit 8f57dddd61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -267,7 +267,7 @@ public class NotificationsFragment extends SFragment implements
findReplyPosition(event.getStatusId());
if (posAndNotification == null) return;
//noinspection ConstantConditions
setFavovouriteForStatus(posAndNotification.first,
setFavouriteForStatus(posAndNotification.first,
posAndNotification.second.getStatus(),
event.getFavourite());
}
@ -295,7 +295,7 @@ public class NotificationsFragment extends SFragment implements
hideFab = preferences.getBoolean("fabHide", false);
scrollListener = new EndlessOnScrollListener(layoutManager) {
@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);
ActionButtonActivity activity = (ActionButtonActivity) getActivity();
@ -401,13 +401,13 @@ public class NotificationsFragment extends SFragment implements
.observeOn(AndroidSchedulers.mainThread())
.as(autoDisposable(from(this)))
.subscribe(
(newStatus) -> setFavovouriteForStatus(position, status, favourite),
(newStatus) -> setFavouriteForStatus(position, status, favourite),
(t) -> Log.d(getClass().getSimpleName(),
"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);
if (status.getReblog() != null) {
@ -442,7 +442,18 @@ public class NotificationsFragment extends SFragment implements
}
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
@ -452,7 +463,7 @@ public class NotificationsFragment extends SFragment implements
}
@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();
if (notification == null || notification.getStatus() == null) return;
super.viewMedia(attachmentIndex, notification.getStatus(), view);
@ -1099,7 +1110,7 @@ public class NotificationsFragment extends SFragment implements
}
@Override
public boolean areContentsTheSame(NotificationViewData oldItem, NotificationViewData newItem) {
public boolean areContentsTheSame(@NonNull NotificationViewData oldItem, @NonNull NotificationViewData newItem) {
return false;
}