1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 13:26:59 +00:00

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

View File

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

View File

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

View File

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

View File

@ -181,7 +181,7 @@ public class NewsService extends BaseService {
data.getLong("profile_id"),
data.getString("profile_name"),
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,
notificationType);
}