java.lang.Object | |
↳ | com.salesforce.android.knowledge.core.offline.OfflineResourceCacher |
Class that handles downloading resources from article contents and storing them in a cache for later offline use.
Offline resource caching is disabled by default to avoid consuming disk space,
but may be enabled by passing an OfflineResourceConfig
instance to offlineResourceConfig(OfflineResourceConfig)
during client configuration.
You can access an instance of this class with getResourceCacher()
.
Generally you do not need to use this class directly, as article resources will be cached
automatically on fetch if the client is properly configured and
cacheImages(boolean)
is set to true. You may wish to access the backing OfflineResourceCache
with getCache()
in order to retrieve the cached images if your application manually renders article content.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected static ServiceLogger | log | ||||||||||
protected final ArticleParser | mArticleParser | ||||||||||
protected final OfflineResourceCache | mCache | ||||||||||
protected final HttpService | mHttpService | ||||||||||
protected final JobQueue | mJobQueue | ||||||||||
protected final Looper | mLooper |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Async<Void> |
downloadAndCacheAllResources(ArticleDetails details)
Parses the contents of the given article and downloads all resources found, caching
the results on the local filesystem.
| ||||||||||
Async<Void> |
downloadAndCacheResource(String url)
Downloads a resource from the supplied URL in the background and caches it on the local
filesystem.
| ||||||||||
OfflineResourceCache |
getCache()
Get the
OfflineResourceCache instance which is used to cache the resources. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static HttpUrl | getResourceUrl(ResourceTarget target) | ||||||||||
static boolean |
isRtaImageProbablyPubliclyAccessible(Throwable throwable, ResourceTarget target)
RTA Images that are access restricted are fetched from the "richTextImageFields" endpoint, and
if the image is actually publicly accessible then the "richTextImageFields" will return a bunch
of HTML and a 503 error.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Parses the contents of the given article and downloads all resources found, caching the results on the local filesystem. The parsing and downloading happens on a background thread. Does nothing if offline resource caching is disabled.
details | The article from which to cache all resources. |
---|
Downloads a resource from the supplied URL in the background and caches it on the local filesystem. Does nothing if offline resource caching is disabled.
url | The URL of the resource to download. |
---|
Get the OfflineResourceCache
instance which is used to cache the resources.
RTA Images that are access restricted are fetched from the "richTextImageFields" endpoint, and if the image is actually publicly accessible then the "richTextImageFields" will return a bunch of HTML and a 503 error. We can use this opportunity to fetch the image from the public URL and then take a shower to try to get rid of the dirty feeling.