-
public class ZBrowserCore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classZBrowserCore.Statspublic interfaceZBrowserCore.DownloadCallbackpublic interfaceZBrowserCore.InvestigateListenerpublic interfaceZBrowserCore.PreloadCallbackpublic interfaceZBrowserCore.CacheCallback
-
Field Summary
Fields Modifier and Type Field Description public final static StringVERSIONprivate ZBrowserCore.CacheCallbackcacheCallbackprotected final Map<String, String>requestHeadersprotected ConfigCachecacheConfigprotected ZBrowserCore.Statsstatisticprotected ZBrowserCore.InvestigateListenerinvestigateListenerpublic static booleanNEW_MODEpublic static booleanUSE_CACHEpublic final WebViewClientzbrowserWebviewListenerpublic final WebChromeClientzbrowserWebChromeClientListener
-
Constructor Summary
Constructors Constructor Description ZBrowserCore(int htmlMemSize, int staticMemSize, int photoMemSize, String diskCacheDirectory, int htmlDiskSize, int staticDiskSize, int photoDiskSize, ConfigCache cacheConfig, Context context)ZBrowserCore(ConfigCache configCache, String diskCacheDirectory, Context context)
-
Method Summary
Modifier and Type Method Description voidsetCacheCallback(ZBrowserCore.CacheCallback callback)voidsetRequestHeaders(Map<String, String> headers)Set custom http request header such as cookie... ConfigCachegetCacheConfig()booleansetCacheConfig(ConfigCache cacheConfig, Context context)Set cache config to zbrowserEvery time this function is called, zbrowser will preloadstatic files within {@code cacheConfig.preloadStatic}ZBrowserCore.StatsgetStatistic()voidsetInvestigateListener(ZBrowserCore.InvestigateListener listener)booleanisNeedToPreload(String url)WebResourceResponsegetSyncWebResourceResponse(WebView view, WebResourceRequest request)voidcancelDebugToast()voidaddCookie(String domain, Map<String, String> cookies)voidsetZbrowserPreloadCallback(ZBrowserPreload.ZBrowserPreloadCallback callback)CacheItemgetFromDiskCache(DiskLruCache cache, String key)voidload(String inputUrl, ZBrowserCore.DownloadCallback callback, PreloadParam preloadParam, Context context)Download an html resource from {@code url}, and store contentto both memory cache and disk cache.WebResourceResponsegetWebResourceResponse(String inputUrl, Context context, boolean isSyncMode)Get WebResourceResponse represent for content of {@code url}.Override WebViewClient.shouldInterceptRequest and return this function.This function is now deprecated for external call.WebResourceResponsegetWebResourceResponse(WebResourceRequest request, Context context, boolean isSyncMode)Get WebResourceResponse represent for content of {@code request}Override WebViewClient.voidremoveCacheItem(String inputUrl)Force remove a resource from both memory and disk cache voidremoveFromDiskCache(DiskLruCache cache, String key)booleancheckCacheItem(String inputUrl)longgetHtmlMemCacheSize()longgetStaticMemCacheSize()voidclearCache()voiddestroy()Destroy all instance inside zbrowserHttp client will be shutdownAll cached content in memory cache will be evictedCached content in disk cache will not be deleted StringcheckUrlRedirect(String url)voidonOpenUrl()voidonInitWebviewStarted()voidonInitWebviewEnded()voidonJumpPreloadStarted()voidonJumpPreloadEnded()voidonCallWebviewLoadUrl(String url)-
-
Constructor Detail
-
ZBrowserCore
ZBrowserCore(int htmlMemSize, int staticMemSize, int photoMemSize, String diskCacheDirectory, int htmlDiskSize, int staticDiskSize, int photoDiskSize, ConfigCache cacheConfig, Context context)
-
ZBrowserCore
ZBrowserCore(ConfigCache configCache, String diskCacheDirectory, Context context)
-
-
Method Detail
-
setCacheCallback
void setCacheCallback(ZBrowserCore.CacheCallback callback)
-
setRequestHeaders
void setRequestHeaders(Map<String, String> headers)
Set custom http request header such as cookie...
- Parameters:
headers- map header name and value
-
getCacheConfig
ConfigCache getCacheConfig()
-
setCacheConfig
boolean setCacheConfig(ConfigCache cacheConfig, Context context)
Set cache config to zbrowserEvery time this function is called, zbrowser will preloadstatic files within
{@code cacheConfig.preloadStatic}- Parameters:
cacheConfig- new cache config
-
getStatistic
ZBrowserCore.Stats getStatistic()
-
setInvestigateListener
void setInvestigateListener(ZBrowserCore.InvestigateListener listener)
-
isNeedToPreload
boolean isNeedToPreload(String url)
-
getSyncWebResourceResponse
WebResourceResponse getSyncWebResourceResponse(WebView view, WebResourceRequest request)
-
cancelDebugToast
void cancelDebugToast()
-
setZbrowserPreloadCallback
void setZbrowserPreloadCallback(ZBrowserPreload.ZBrowserPreloadCallback callback)
-
getFromDiskCache
CacheItem getFromDiskCache(DiskLruCache cache, String key)
-
load
void load(String inputUrl, ZBrowserCore.DownloadCallback callback, PreloadParam preloadParam, Context context)
Download an html resource from
{@code url}, and store contentto both memory cache and disk cache.- Parameters:
inputUrl- http url of resourcecallback- download callback function raise when downloading article.preloadParam- information about{@code url}in order to decide to preload it or not
-
getWebResourceResponse
WebResourceResponse getWebResourceResponse(String inputUrl, Context context, boolean isSyncMode)
Get WebResourceResponse represent for content of
{@code url}.Override WebViewClient.shouldInterceptRequest and return this function.This function is now deprecated for external call.Use{@code getWebResourceResponse(WebResourceRequest)}instead- Parameters:
inputUrl- http url of resource
-
getWebResourceResponse
@RequiresApi(api = 21) WebResourceResponse getWebResourceResponse(WebResourceRequest request, Context context, boolean isSyncMode)
Get WebResourceResponse represent for content of
{@code request}Override WebViewClient.shouldInterceptRequest and return this function- Parameters:
request- Object containing the details of the request
-
removeCacheItem
void removeCacheItem(String inputUrl)
Force remove a resource from both memory and disk cache
- Parameters:
inputUrl- url of resource that need removed
-
removeFromDiskCache
void removeFromDiskCache(DiskLruCache cache, String key)
-
checkCacheItem
boolean checkCacheItem(String inputUrl)
-
getHtmlMemCacheSize
long getHtmlMemCacheSize()
-
getStaticMemCacheSize
long getStaticMemCacheSize()
-
clearCache
void clearCache()
-
destroy
void destroy()
Destroy all instance inside zbrowserHttp client will be shutdownAll cached content in memory cache will be evictedCached content in disk cache will not be deleted
-
checkUrlRedirect
String checkUrlRedirect(String url)
-
onOpenUrl
void onOpenUrl()
-
onInitWebviewStarted
void onInitWebviewStarted()
-
onInitWebviewEnded
void onInitWebviewEnded()
-
onJumpPreloadStarted
void onJumpPreloadStarted()
-
onJumpPreloadEnded
void onJumpPreloadEnded()
-
onCallWebviewLoadUrl
void onCallWebviewLoadUrl(String url)
-
-
-
-