more small fixes, closes #498

This commit is contained in:
Austin Huang 2021-01-11 12:52:45 -05:00
parent 1b6894bf5f
commit 9ba48ebe2e
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
5 changed files with 21 additions and 9 deletions

View File

@ -465,16 +465,16 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment im
binding.date.setVisibility(View.VISIBLE); binding.date.setVisibility(View.VISIBLE);
binding.date.setText(date); binding.date.setText(date);
})); }));
if (viewModel.getMedia().isCommentLikesEnabled()) { viewModel.getLikeCount().observe(getViewLifecycleOwner(), count -> {
viewModel.getLikeCount().observe(getViewLifecycleOwner(), count -> { final long safeCount = getSafeCount(count);
final long safeCount = getSafeCount(count); final String likesString = getResources().getQuantityString(R.plurals.likes_count, (int) safeCount, safeCount);
final String likesString = getResources().getQuantityString(R.plurals.likes_count, (int) safeCount, safeCount); binding.likesCount.setText(likesString);
binding.likesCount.setText(likesString); });
}); if (!viewModel.getMedia().isCommentsDisabled()) {
viewModel.getCommentCount().observe(getViewLifecycleOwner(), count -> { viewModel.getCommentCount().observe(getViewLifecycleOwner(), count -> {
final long safeCount = getSafeCount(count); final long safeCount = getSafeCount(count);
final String likesString = getResources().getQuantityString(R.plurals.comments_count, (int) safeCount, safeCount); final String likesString = getResources().getQuantityString(R.plurals.comments_count, (int) safeCount, safeCount);
binding.likesCount.setText(likesString); binding.commentsCount.setText(likesString);
}); });
} }
viewModel.getViewCount().observe(getViewLifecycleOwner(), count -> { viewModel.getViewCount().observe(getViewLifecycleOwner(), count -> {
@ -538,7 +538,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment im
} }
private void setupComment() { private void setupComment() {
if (!viewModel.hasPk() || !viewModel.getMedia().isCommentLikesEnabled()) { if (!viewModel.hasPk() || viewModel.getMedia().isCommentsDisabled()) {
binding.comment.setVisibility(View.GONE); binding.comment.setVisibility(View.GONE);
binding.commentsCount.setVisibility(View.GONE); binding.commentsCount.setVisibility(View.GONE);
return; return;
@ -577,12 +577,14 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment im
} }
private void setupLike() { private void setupLike() {
/*
final boolean likableMedia = viewModel.hasPk() && viewModel.getMedia().isCommentLikesEnabled(); final boolean likableMedia = viewModel.hasPk() && viewModel.getMedia().isCommentLikesEnabled();
if (!likableMedia) { if (!likableMedia) {
binding.like.setVisibility(View.GONE); binding.like.setVisibility(View.GONE);
binding.likesCount.setVisibility(View.GONE); binding.likesCount.setVisibility(View.GONE);
return; return;
} }
*/
if (!viewModel.isLoggedIn()) { if (!viewModel.isLoggedIn()) {
binding.like.setVisibility(View.GONE); binding.like.setVisibility(View.GONE);
return; return;

View File

@ -19,6 +19,7 @@ public class Media implements Serializable {
private final MediaItemType mediaType; private final MediaItemType mediaType;
private final boolean canViewerReshare; private final boolean canViewerReshare;
private final boolean commentLikesEnabled; private final boolean commentLikesEnabled;
private final boolean commentsDisabled;
private final long nextMaxId; private final long nextMaxId;
private final long commentCount; private final long commentCount;
private final ImageVersions2 imageVersions2; private final ImageVersions2 imageVersions2;
@ -56,6 +57,7 @@ public class Media implements Serializable {
final int originalHeight, final int originalHeight,
final MediaItemType mediaType, final MediaItemType mediaType,
final boolean commentLikesEnabled, final boolean commentLikesEnabled,
final boolean commentsDisabled,
final long nextMaxId, final long nextMaxId,
final long commentCount, final long commentCount,
final long likeCount, final long likeCount,
@ -87,6 +89,7 @@ public class Media implements Serializable {
this.originalHeight = originalHeight; this.originalHeight = originalHeight;
this.mediaType = mediaType; this.mediaType = mediaType;
this.commentLikesEnabled = commentLikesEnabled; this.commentLikesEnabled = commentLikesEnabled;
this.commentsDisabled = commentsDisabled;
this.nextMaxId = nextMaxId; this.nextMaxId = nextMaxId;
this.commentCount = commentCount; this.commentCount = commentCount;
this.likeCount = likeCount; this.likeCount = likeCount;
@ -182,6 +185,10 @@ public class Media implements Serializable {
return commentLikesEnabled; return commentLikesEnabled;
} }
public boolean isCommentsDisabled() {
return commentsDisabled;
}
public long getNextMaxId() { public long getNextMaxId() {
return nextMaxId; return nextMaxId;
} }

View File

@ -81,6 +81,7 @@ public class DirectItemFactory {
height, height,
isVideo ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE, isVideo ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE,
false, false,
false,
-1, -1,
-1, -1,
-1, -1,
@ -156,6 +157,7 @@ public class DirectItemFactory {
0, 0,
MediaItemType.MEDIA_TYPE_VOICE, MediaItemType.MEDIA_TYPE_VOICE,
false, false,
false,
-1, -1,
0, 0,
0, 0,

View File

@ -857,6 +857,7 @@ public final class ResponseBodyUtils {
height, height,
mediaItemType, mediaItemType,
false, false,
feedItem.optBoolean("comments_disabled"),
-1, -1,
commentsCount, commentsCount,
likesCount, likesCount,

View File

@ -181,7 +181,7 @@ public class NewsService extends BaseService {
data.getLong("profile_id"), data.getLong("profile_id"),
data.getString("profile_name"), data.getString("profile_name"),
data.getString("profile_image"), data.getString("profile_image"),
!data.isNull("media") ? data.getJSONArray("media").getJSONObject(0).getLong("id") : 0, !data.isNull("media") ? Long.valueOf(data.getJSONArray("media").getJSONObject(0).getString("id").split("_")[0]) : 0,
!data.isNull("media") ? data.getJSONArray("media").getJSONObject(0).getString("image") : null, !data.isNull("media") ? data.getJSONArray("media").getJSONObject(0).getString("image") : null,
notificationType); notificationType);
} }