ProductDatabase

open class ProductDatabase

Class for interfacing with the local product database

Types

Link copied to clipboard
Link copied to clipboard
interface UpdateCallback

Properties

Link copied to clipboard
Link copied to clipboard
open val revisionId: Long

Functions

Link copied to clipboard
Adds a listener that gets called every time the database updates after calling update
Link copied to clipboard
open fun cancelUpdate()
Cancels a database update, if one is currently running.
Link copied to clipboard
open fun delete()
Closes and deletes the locally stored database and falls back to online only mode.
Link copied to clipboard
open fun findByCode(scannedCode: ScannedCode): Product
Find a product via its scannable code.
Link copied to clipboard
open fun findByCodeOnline(scannedCode: ScannedCode, productAvailableListener: OnProductAvailableListener)
open fun findByCodeOnline(scannedCode: ScannedCode, productAvailableListener: OnProductAvailableListener, onlineOnly: Boolean)
Finds a product via its scannable code over the network, if the service is available.
Link copied to clipboard
open fun findByName(name: String): Product
Find a product by its name.
Link copied to clipboard
open fun findBySku(sku: String): Product
Find a product via its SKU.
Link copied to clipboard
open fun findBySkuOnline(sku: String, productAvailableListener: OnProductAvailableListener)
open fun findBySkuOnline(sku: String, productAvailableListener: OnProductAvailableListener, onlineOnly: Boolean)
Finds a product via its SKU over the network, if the service is available.
Link copied to clipboard
open fun findBySkus(skus: Array<String>): Array<Product>
Find a product via its SKU.
Link copied to clipboard
Deprecated.
Link copied to clipboard
The current major schema version.
Link copied to clipboard
The current minor schema version.
Link copied to clipboard
Returns true if the product database is synchronized and available offline
Link copied to clipboard
open fun isUpdating(): Boolean
Link copied to clipboard
open fun isUpToDate(): Boolean
Return true if the database was updated recently and can be used to display accurate prices.
Link copied to clipboard
open fun loadDatabaseBundle(inputStream: InputStream, revision: Long, major: Int, minor: Int)
Loads the a database from an InputStream.
open fun loadDatabaseBundle(assetPath: String, revision: Long, major: Int, minor: Int)
Loads the a database from a file located int the assets folder.
Link copied to clipboard
open fun productAtCursor(cursor: Cursor): Product
Returns the current product where the cursor is currently pointing at.
Link copied to clipboard
Removes an already added listener
Link copied to clipboard
open fun searchByCode(searchString: String, cancellationSignal: CancellationSignal): Cursor
Returns a Cursor which can be iterated for items containing the given scannable code or sku.
Link copied to clipboard
open fun searchByFoldedName(searchString: String, cancellationSignal: CancellationSignal): Cursor
This function needs config value generateSearchIndex set to true Returns a Cursor which can be iterated for items containing the given search string at the start of a word.
Link copied to clipboard
open fun size(): Long
Link copied to clipboard
open fun update()
open fun update(callback: ProductDatabase.UpdateCallback, deltaUpdateOnly: Boolean)
Updates the current database in the background by requesting new data from the backend.