Skip to main content

com.bluebillywig.bbnativeshared.interfaces — Functions

getJsonStringWithAuth​

fun getJsonStringWithAuth(jsonUrl: String, authHeaders: Map<String, String>, onSuccess: (retObject: String) -> Unit, onFailure: (error: Boolean) -> Unit) : Unit

[getJsonString] with the app's content-protection headers (see [ContentAuth][com.bluebillywig.bbnativeshared.data.ContentAuth]); [jsonUrl] has already been checked. When following a redirect, send [authHeaders] on to a hop only if ContentAuth.isBbAuthOrigin(hopUrl), and strip them from any other hop.

No default, unlike [getJsonStringAndHeaders]: a default can only fall back to [getJsonString], which drops [authHeaders] without a trace and brings back the black player this exists for. An implementation that does not override it must fail to compile.

getJsonStringAndHeadersWithAuth​

fun getJsonStringAndHeadersWithAuth(jsonUrl: String, authHeaders: Map<String, String>, onSuccess: (retObject: String, responseHeaders: Map<String, List<String>>) -> Unit, onFailure: (error: Boolean) -> Unit) : Unit fun logStats(url: String, onSuccess: () -> Unit, onFailure: (error: Boolean) -> Unit): Unit fun __destruct() : Unit

[getJsonStringAndHeaders] with the app's content-protection headers; see [getJsonStringWithAuth] for the redirect rule. No default, for the same reason.

cachedFile​

fun cachedFile(key: String) : FontFileEntry? /** Full contents of the file cached under [key], or null when there is none. */ fun cachedContents(key: String): ByteArray? /** Write [contents] under [key], replacing what was there. Returns null when it failed. */ fun put(key: String, contents: ByteArray) : FontFileEntry?

Metadata + first bytes of the file cached under [key], or null when there is none.

cachedContents​

fun cachedContents(key: String) : ByteArray? /** Write [contents] under [key], replacing what was there. Returns null when it failed. */ fun put(key: String, contents: ByteArray) : FontFileEntry?

Full contents of the file cached under [key], or null when there is none.

put​

fun put(key: String, contents: ByteArray) : FontFileEntry?

Write [contents] under [key], replacing what was there. Returns null when it failed.

download​

fun download( key: String, url: String, onSuccess: (entry: FontFileEntry) -> Unit, onFailure: (error: String) -> Unit ) : Unit /** Drop the entry for [key]. Called when its bytes failed validation. */ fun remove(key: String): Unit fun __destruct() : Unit

Download [url] into the cache under [key], replacing what was there.

There is no cancel handle by design: once a key has been handed over, the transfer runs to its end and fills the cache for the next launch. The shared module stops waiting long before that, so the callback may well land after its resolver's __destruct - a store that touches its owner from the callback must survive that, and the shared module simply drops the bytes it has nobody left to hand them to.

remove​

fun remove(key: String) : Unit fun __destruct() : Unit

Drop the entry for [key]. Called when its bytes failed validation.