Skip to content

Commit

Permalink
WordPress.com News images don't show in the reader (#21713)
Browse files Browse the repository at this point in the history
* Renamed featuredImage to featuredImageView to clarify its a view

* Close existing response before proceeding with new request

* Updated comment

* Check for null body to avoid IllegalStateException
  • Loading branch information
nbradbury authored Mar 3, 2025
1 parent e344e16 commit cc82fd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -930,13 +930,13 @@ class ReaderPostDetailFragment : ViewPagerFragment(),
state: ReaderPostDetailsUiState.ReaderPostFeaturedImageUiState?,
binding: ReaderFragmentPostDetailBinding
) {
val featuredImage = binding.appbarWithCollapsingToolbarLayout.featuredImage
featuredImage.setVisible(state != null)
val featuredImageView = binding.appbarWithCollapsingToolbarLayout.featuredImage
featuredImageView.setVisible(state != null)
state?.let {
featuredImage.layoutParams.height = it.height
featuredImageView.layoutParams.height = it.height
it.url?.let { url ->
imageManager.load(featuredImage, PHOTO, url, CENTER_CROP)
featuredImage.setOnClickListener {
imageManager.load(featuredImageView, PHOTO, url, CENTER_CROP)
featuredImageView.setOnClickListener {
viewModel.onFeaturedImageClicked(blogId = state.blogId, featuredImageUrl = url)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class CustomRedirectInterceptor : Interceptor {
if (response.isRedirect) {
val newRequest = getRedirectRequest(originalRequest, response)
if (newRequest != null) {
// Failing to close the existing response results in this error:
// "IllegalStateException: cannot make a new request because the
// previous response is still open: please call response.close()"
response.body?.close()
return chain.proceed(newRequest)
}
}
Expand Down

0 comments on commit cc82fd1

Please sign in to comment.