Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.networking

import com.android.volley.DefaultRetryPolicy
import com.android.volley.Request
import com.android.volley.Request.Priority
import com.bumptech.glide.integration.volley.VolleyRequestFactory
Expand All @@ -12,6 +13,9 @@ import java.io.InputStream
import javax.inject.Inject
import javax.inject.Singleton

// Timeout in milliseconds for loading complex images at server side (private, heavy...)
private const val TIMEOUT = 15_000

/**
* RequestFactory which adds authorization headers to all Glide requests and makes sure requests to WPcom endpoints
* use https.
Expand All @@ -27,7 +31,18 @@ class GlideRequestFactory @Inject constructor(
headers: Map<String, String>
): Request<ByteArray>? {
val httpsUrl: String = convertWPcomUrlToHttps(url)
return VolleyStreamFetcher.GlideRequest(httpsUrl, callback, priority, addAuthHeaders(url, headers))
return VolleyStreamFetcher.GlideRequest(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put a breakpoint here and viewed the post, but this was never called for me (and the high-res image never loaded).

I tried deleting the app and reinstalling then trying again, but the issue persists (so I don't think it's something to do with caching).

What would you suggest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd. They loaded for me after 4 and 6 secs 🤔

ReaderPhotoView image loaded successfully after 4349ms https://wpmobilep2.wordpress.com/wp-content/uploads/2025/09/frame-3.png?w=2400
ReaderPhotoView image loaded successfully after 6202ms https://wpmobilep2.wordpress.com/wp-content/uploads/2025/09/frame-4.png?w=2400

Copy link
Contributor Author

@adalpari adalpari Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some debug logs. So, could you try it again and send me the trace back? Tag: "ReaderPhotoView"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't getting called either, so I did some searching. reader photo fragment > newInstance is getting called, so I added similar logs to the top of all the lifecycle methods in that fragment, and it seems none of them are being called?

This is a rather old test device – could that be related?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd... What Android version are you running?
Maybe there's an exception to run a different flow for old versions

httpsUrl,
callback,
priority,
addAuthHeaders(url, headers)
).apply {
retryPolicy = DefaultRetryPolicy(
TIMEOUT,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
)
}
}

private fun convertWPcomUrlToHttps(url: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public interface PhotoViewListener {
private boolean mIsInitialLayout = true;
private final ImageManager mImageManager;

// Used to determine when the low res placeholder is loaded, so we, at least, show something to the user
private boolean mLowResImageLoaded = false;

public ReaderPhotoView(Context context) {
this(context, null);
}
Expand Down Expand Up @@ -107,7 +110,7 @@ private void loadImage() {
}

showProgress();

mLowResImageLoaded = false;
mImageManager
.loadWithResultListener(mImageView, ImageType.IMAGE, mHiResImageUrl, ScaleType.CENTER, mLoResImageUrl,
new RequestListener<Drawable>() {
Expand All @@ -116,27 +119,29 @@ public void onLoadFailed(@Nullable Exception e, @Nullable Object model) {
if (e != null) {
AppLog.e(AppLog.T.READER, e);
}
boolean lowResNotLoadedYet = isLoading();
if (lowResNotLoadedYet) {
hideProgress();
hideProgress();
// Show error only when there's not low res image loaded
if (!mLowResImageLoaded) {
showError();
}
}

@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Object model) {
handleResponse();
// Do not hide progress if this is the placeholder loader
boolean isLoResImageUrlLoaded = model instanceof String && model.equals(mLoResImageUrl);
if (!isLoResImageUrlLoaded) {
hideProgress();
hideError();
} else {
mLowResImageLoaded = true;
}
// attach the pinch/zoom handler
setupOnTapListeners();
}
});
}

private void handleResponse() {
hideProgress();
hideError();
// attach the pinch/zoom handler
setupOnTapListeners();
}

private void setupOnTapListeners() {
PhotoViewAttacher attacher = mImageView.getAttacher();
attacher.setOnPhotoTapListener((view, v, v2) -> {
Expand Down
10 changes: 7 additions & 3 deletions WordPress/src/main/res/layout/reader_photo_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@

<ProgressBar
android:id="@+id/progress_loading"
android:layout_width="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
android:layout_alignParentBottom="true"
android:indeterminate="true"
android:indeterminateOnly="true"
android:indeterminateTint="@color/primary"
android:visibility="visible"
tools:visibility="visible" />
</merge>