Interface ChatUIMediaInterceptor

  • All Implemented Interfaces:

    
    public interface ChatUIMediaInterceptor
    
                        

    Interceptor 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 interface ChatUIMediaInterceptor.Callback

      Completion callback for asynchronous interceptor operations.

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      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.
      abstract boolean shouldInterceptRequest(WebView view, String url) Intercepts a WebView resource request.
      String onCombinePortraitLoad(String url) Called when a combined-message portrait URL is about to be loaded.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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 URL
        headers - HTTP headers already set for this request
        callback - invoke onComplete(headers) to pass the (possibly modified) headers back
      • shouldInterceptRequest

         abstract boolean shouldInterceptRequest(WebView view, String url)

        Intercepts a WebView resource request.

        The WebView checks this method first; if it returns true the network request is skipped. Returning false lets the WebView load the resource normally.

        Note: This callback runs on a WebView worker thread.

        Parameters:
        view - WebView making the request
        url - resource URL
        Returns:

        true to intercept the request; false to 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 url to use it unchanged)