public static class

OfflineResourceConfig.Builder

extends Object
java.lang.Object
   ↳ com.salesforce.android.knowledge.core.offline.OfflineResourceConfig.Builder

Class Overview

Builder class for OfflineResourceConfig instances.

Summary

Fields
protected int mConcurrentRequests
protected int mMaxSize
protected Collection<String> mMediaTypes
Public Constructors
Builder()
Public Methods
OfflineResourceConfig build()
Build an OfflineResourceConfig instance with the current values.
OfflineResourceConfig.Builder concurrentRequests(int concurrentRequests)
Set the maximum number of resources that will be downloaded concurrently.
OfflineResourceConfig.Builder maxSize(int maxSize)
Set the maximum size to consume on disk for the offline resource cache, in bytes.
OfflineResourceConfig.Builder mediaTypes(Collection<String> types)
Set the media types that will be accepted to the offline cache.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected int mConcurrentRequests

protected int mMaxSize

protected Collection<String> mMediaTypes

Public Constructors

public Builder ()

Public Methods

public OfflineResourceConfig build ()

Build an OfflineResourceConfig instance with the current values.

Returns

public OfflineResourceConfig.Builder concurrentRequests (int concurrentRequests)

Set the maximum number of resources that will be downloaded concurrently. Higher numbers will give more throughput when downloading but consume more memory. Applications should be aware that setting this value too high could potentially lead to an OutOfMemoryError. Defaults to the number of processors on the device.

Parameters
concurrentRequests The maximum number of concurrent downloads.
Returns
  • This instance for fluent API calls.
Throws
IllegalArgumentException If concurrentRequests is not greater than zero.

public OfflineResourceConfig.Builder maxSize (int maxSize)

Set the maximum size to consume on disk for the offline resource cache, in bytes. The cache will purge older items to ensure it stays under this maximum size. The default size is 10MB.

Parameters
maxSize The maximum cache size in bytes.
Returns
  • This instance for fluent API calls.
Throws
IllegalArgumentException If maxSize is an invalid value.

public OfflineResourceConfig.Builder mediaTypes (Collection<String> types)

Set the media types that will be accepted to the offline cache. These strings match against the type() of the content type response header. Only responses with headers matching a string in this collection will be cached for offline viewing - this allows the application to avoid polluting the cache with invalid content. Defaults to "image".

Parameters
types The media types to accept to the offline cache.
Returns
  • This instance for fluent API calls.