Package com.zing.zalo.zbrowser
Class ZBrowserCore
- java.lang.Object
-
- com.zing.zalo.zbrowser.ZBrowserCore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceZBrowserCore.CacheCallbackstatic interfaceZBrowserCore.DownloadCallbackstatic interfaceZBrowserCore.InvestigateListenerstatic interfaceZBrowserCore.PreloadCallbackstatic classZBrowserCore.Stats
-
Field Summary
Fields Modifier and Type Field Description protected ConfigCachecacheConfigprotected ZBrowserCore.InvestigateListenerinvestigateListenerprotected static StringLOG_TAGprotected Map<String,String>requestHeadersprotected ZBrowserCore.Statsstatisticstatic StringVERSIONprotected ZBrowserPreload.ZBrowserPreloadCallbackzbrowserCallbackWebChromeClientzbrowserWebChromeClientListenerWebViewClientzbrowserWebviewListener
-
Constructor Summary
Constructors Constructor Description ZBrowserCore(int htmlMemSize, int staticMemSize, int photoMemSize, String diskCacheDirectory, int htmlDiskSize, int staticDiskSize, int photoDiskSize, ConfigCache cacheConfig, Context context)Deprecated.ZBrowserCore(ConfigCache configCache, String diskCacheDirectory, Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCookie(String domain, Map<String,String> cookies)voidcancelDebugToast()booleancheckCacheItem(String inputUrl)StringcheckUrlRedirect(String url)voidclearCache()voiddestroy()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 deletedprotected voidfinalize()ConfigCachegetCacheConfig()CacheItemgetFromDiskCache(DiskLruCache cache, String key)longgetHtmlMemCacheSize()longgetStaticMemCacheSize()ZBrowserCore.StatsgetStatistic()WebResourceResponsegetWebResourceResponse(WebResourceRequest request, Context context)Get WebResourceResponse represent for content ofrequestOverride WebViewClient.shouldInterceptRequest and return this functionWebResourceResponsegetWebResourceResponse(String inputUrl, Context context)Get WebResourceResponse represent for content ofurl.voidload(String inputUrl, ZBrowserCore.DownloadCallback callback, PreloadParam preloadParam, Context context)Download an html resource fromurl, and store content to both memory cache and disk cache.voidonCallWebviewLoadUrl(String url)voidonInitWebviewEnded()voidonInitWebviewStarted()voidonJumpPreloadEnded()voidonJumpPreloadStarted()voidonOpenUrl()protected voidputToDiskCache(DiskLruCache cache, String key, CacheItem value)voidremoveCacheItem(String inputUrl)Force remove a resource from both memory and disk cachevoidremoveFromDiskCache(DiskLruCache cache, String key)voidsetCacheCallback(ZBrowserCore.CacheCallback callback)booleansetCacheConfig(ConfigCache cacheConfig, Context context)Set cache config to zbrowser Every time this function is called, zbrowser will preload static files withincacheConfig.preloadStaticvoidsetInvestigateListener(ZBrowserCore.InvestigateListener listener)voidsetRequestHeaders(Map<String,String> headers)Set custom http request header such as cookie...voidsetZbrowserPreloadCallback(ZBrowserPreload.ZBrowserPreloadCallback callback)
-
-
-
Field Detail
-
VERSION
public static final String VERSION
- See Also:
- Constant Field Values
-
LOG_TAG
protected static final String LOG_TAG
- See Also:
- Constant Field Values
-
cacheConfig
protected ConfigCache cacheConfig
-
statistic
protected ZBrowserCore.Stats statistic
-
investigateListener
protected ZBrowserCore.InvestigateListener investigateListener
-
zbrowserCallback
protected ZBrowserPreload.ZBrowserPreloadCallback zbrowserCallback
-
zbrowserWebviewListener
public final WebViewClient zbrowserWebviewListener
-
zbrowserWebChromeClientListener
public final WebChromeClient zbrowserWebChromeClientListener
-
-
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()
-
setZbrowserPreloadCallback
public void setZbrowserPreloadCallback(ZBrowserPreload.ZBrowserPreloadCallback callback)
-
setCacheCallback
public void setCacheCallback(ZBrowserCore.CacheCallback callback)
-
setInvestigateListener
public void setInvestigateListener(ZBrowserCore.InvestigateListener listener)
-
getFromDiskCache
public CacheItem getFromDiskCache(DiskLruCache cache, String key)
-
putToDiskCache
protected void putToDiskCache(DiskLruCache cache, String key, CacheItem value)
-
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 withincacheConfig.preloadStatic- Parameters:
cacheConfig- new cache config
-
load
public void load(String inputUrl, ZBrowserCore.DownloadCallback callback, PreloadParam preloadParam, Context context)
Download an html resource fromurl, and store content to both memory cache and disk cache.- Parameters:
inputUrl- http url of resourcecallback- download callback function raise when downloading article.preloadParam- information abouturlin order to decide to preload it or not
-
getWebResourceResponse
public WebResourceResponse getWebResourceResponse(String inputUrl, Context context)
Get WebResourceResponse represent for content ofurl. Override WebViewClient.shouldInterceptRequest and return this function. This function is now deprecated for external call. UsegetWebResourceResponse(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 ofrequestOverride 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)
-
getStatistic
public ZBrowserCore.Stats getStatistic()
-
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
-
finalize
protected void finalize() throws Throwable
-
getCacheConfig
public ConfigCache getCacheConfig()
-
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)
-
-