Interface ChatUIMediaInterceptor
-
- All Implemented Interfaces:
public interface ChatUIMediaInterceptorInterceptor for media resource loading in the ChatUI SDK.
Implement this interface to customize HTTP headers for Glide image requests and to intercept WebView resource loading.
Register an implementation via setChatUIMediaInterceptor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceChatUIMediaInterceptor.CallbackCompletion callback for asynchronous interceptor operations.
-
Method Summary
Modifier and Type Method Description abstract voidonGlidePrepareLoad(String url, Map<String, String> headers, ChatUIMediaInterceptor.Callback<Map<String, String>> callback)Called before Glide loads an image, allowing custom HTTP headers to be injected. abstract booleanshouldInterceptRequest(WebView view, String url)Intercepts a WebView resource request. StringonCombinePortraitLoad(String url)Called when a combined-message portrait URL is about to be loaded. -
-
Method Detail
-
onGlidePrepareLoad
abstract void onGlidePrepareLoad(String url, Map<String, String> headers, ChatUIMediaInterceptor.Callback<Map<String, String>> callback)
Called before Glide loads an image, allowing custom HTTP headers to be injected.
Use cases:
- Large image preview screen (
PicturePagerActivity) - Default avatar loading in GlideChatUIImageEngine (
loadConversationListPortrait,loadConversationPortrait)
Note: This callback runs on the main thread — do not perform blocking operations. Switch to a background thread if heavy work is needed.
Note: You must call
callback.onComplete(headers)to return the headers; the SDK will not proceed with image loading until the callback is invoked.- Parameters:
url- image URLheaders- HTTP headers already set for this requestcallback- invokeonComplete(headers)to pass the (possibly modified) headers back
- Large image preview screen (
-
shouldInterceptRequest
abstract boolean shouldInterceptRequest(WebView view, String url)
Intercepts a WebView resource request.
The WebView checks this method first; if it returns
truethe network request is skipped. Returningfalselets the WebView load the resource normally.Note: This callback runs on a WebView worker thread.
- Parameters:
view- WebView making the requesturl- resource URL- Returns:
trueto intercept the request;falseto allow it
-
onCombinePortraitLoad
String onCombinePortraitLoad(String url)
Called when a combined-message portrait URL is about to be loaded.
Override to transform the URL — for example, to append an authentication token.
- Parameters:
url- the original portrait URL- Returns:
the URL to use for loading (return the original
urlto use it unchanged)
-
-
-
-