Browse Source

more small fixes, closes #498

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
9ba48ebe2e
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 8
      app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
  2. 7
      app/src/main/java/awais/instagrabber/repositories/responses/Media.java
  3. 2
      app/src/main/java/awais/instagrabber/utils/DirectItemFactory.java
  4. 1
      app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java
  5. 2
      app/src/main/java/awais/instagrabber/webservices/NewsService.java

8
app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java

@ -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);
});
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;

7
app/src/main/java/awais/instagrabber/repositories/responses/Media.java

@ -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;
}

2
app/src/main/java/awais/instagrabber/utils/DirectItemFactory.java

@ -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,

1
app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java

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

2
app/src/main/java/awais/instagrabber/webservices/NewsService.java

@ -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);
}

Loading…
Cancel
Save