Merge pull request #305 from the-blank-x/ryd-runonuithread

Attempt to fix crash by RYD showing dislike info while screen is being rotated
This commit is contained in:
poly 2023-04-08 14:34:14 -06:00 committed by GitHub
commit f112058870
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1528,11 +1528,18 @@ public final class VideoDetailFragment
new Thread(() -> {
info.setDislikeCount(ReturnYouTubeDislikeUtils.getDislikes(getContext(), info));
if (info.getDislikeCount() >= 0) {
if (activity == null) {
return;
}
activity.runOnUiThread(() -> {
binding.detailThumbsDownCountView.setText(Localization
.shortCount(activity, info.getDislikeCount()));
binding.detailThumbsDownCountView.setVisibility(View.VISIBLE);
binding.detailThumbsDownImgView.setVisibility(View.VISIBLE);
if (binding != null && binding.detailThumbsDownCountView != null) {
binding.detailThumbsDownCountView.setText(Localization
.shortCount(activity, info.getDislikeCount()));
binding.detailThumbsDownCountView.setVisibility(View.VISIBLE);
}
if (binding != null && binding.detailThumbsDownImgView != null) {
binding.detailThumbsDownImgView.setVisibility(View.VISIBLE);
}
});
}
}).start();