Class ZBrowserCore

  • Direct Known Subclasses:
    ZBrowser

    public class ZBrowserCore
    extends Object
    • Constructor Detail

      • ZBrowserCore

        @Deprecated
        public ZBrowserCore​(int htmlMemSize,
                            int staticMemSize,
                            int photoMemSize,
                            String diskCacheDirectory,
                            int htmlDiskSize,
                            int staticDiskSize,
                            int photoDiskSize,
                            ConfigCache cacheConfig,
                            Context context)
        Deprecated.
      • ZBrowserCore

        public ZBrowserCore​(@NonNull
                            ConfigCache configCache,
                            @NonNull
                            String diskCacheDirectory,
                            Context context)
    • Method Detail

      • cancelDebugToast

        public void cancelDebugToast()
      • setRequestHeaders

        public void setRequestHeaders​(Map<String,​String> headers)
        Set custom http request header such as cookie...
        Parameters:
        headers - map header name and value
      • setCacheConfig

        public boolean setCacheConfig​(ConfigCache cacheConfig,
                                      Context context)
        Set cache config to zbrowser Every time this function is called, zbrowser will preload static files within cacheConfig.preloadStatic
        Parameters:
        cacheConfig - new cache config
      • load

        public void load​(String inputUrl,
                         ZBrowserCore.DownloadCallback callback,
                         PreloadParam preloadParam,
                         Context context)
        Download an html resource from url, and store content to both memory cache and disk cache.
        Parameters:
        inputUrl - http url of resource
        callback - download callback function raise when downloading article.
        preloadParam - information about url in order to decide to preload it or not
      • getWebResourceResponse

        public WebResourceResponse getWebResourceResponse​(String inputUrl,
                                                          Context context)
        Get WebResourceResponse represent for content of url. Override WebViewClient.shouldInterceptRequest and return this function. This function is now deprecated for external call. Use getWebResourceResponse(WebResourceRequest) instead
        Parameters:
        inputUrl - http url of resource
        Returns:
        WebResourceResponse represent for content of resource if it is cached otherwise null
      • getWebResourceResponse

        @RequiresApi(api=21)
        public WebResourceResponse getWebResourceResponse​(WebResourceRequest request,
                                                          Context context)
        Get WebResourceResponse represent for content of request Override WebViewClient.shouldInterceptRequest and return this function
        Parameters:
        request - Object containing the details of the request
        Returns:
        WebResourceResponse represent for content of resource if it is cached otherwise null
      • removeCacheItem

        public void removeCacheItem​(String inputUrl)
        Force remove a resource from both memory and disk cache
        Parameters:
        inputUrl - url of resource that need removed
      • removeFromDiskCache

        public void removeFromDiskCache​(DiskLruCache cache,
                                        String key)
      • checkCacheItem

        public boolean checkCacheItem​(String inputUrl)
      • getHtmlMemCacheSize

        public long getHtmlMemCacheSize()
      • getStaticMemCacheSize

        public long getStaticMemCacheSize()
      • clearCache

        public void clearCache()
      • destroy

        public void destroy()
        Destroy all instance inside zbrowser Http client will be shutdown All cached content in memory cache will be evicted Cached content in disk cache will not be deleted
      • checkUrlRedirect

        public String checkUrlRedirect​(String url)
      • onOpenUrl

        public void onOpenUrl()
      • onInitWebviewStarted

        public void onInitWebviewStarted()
      • onInitWebviewEnded

        public void onInitWebviewEnded()
      • onJumpPreloadStarted

        public void onJumpPreloadStarted()
      • onJumpPreloadEnded

        public void onJumpPreloadEnded()
      • onCallWebviewLoadUrl

        public void onCallWebviewLoadUrl​(String url)