ripe / com.ripe.android.base / Ripe

Ripe

class Ripe : Observable

Represents a customizable model. The options map supports the following keys:

Constructors

<init>

Ripe(brand: String?, model: String?, options: Map<String, Any> = HashMap())

Creates a Ripe instance with the provided brand, model and options.

Properties

api

var api: RipeAPI

The API instance to be used.

brand

var brand: String?

The brand of the model.

country

var country: String?

The country where the model will be delivered.

currency

var currency: String?

The currency to use when calculating the price.

engraving

var engraving: String

The current engraving of the model.

flag

var flag: String?

A specific attribute of the model.

initials

var initials: String

The current initials of the model.

loadedConfig

var loadedConfig: Map<String, Any>?

The configuration information of the current model.

locale

var locale: String?

The default locale to use when localizing values.

model

var model: String?

The name of the model.

options

var options: MutableMap<String, Any>

A map with options to customise the Ripe instance.

parts

var parts: MutableMap<String, Any>

The current customisation of the model.

ready

var ready: Boolean

If the instance is ready for interactions.

variant

var variant: String?

The variant of the model.

version

var version: String?

The version of the build in use.

Inherited Properties

callbacks

val callbacks: MutableMap<String, MutableList<ObservableCallback>>

A dictionary that contains all methods to be executed when an event is triggered

Functions

addPlugin

fun addPlugin(plugin: Plugin): Unit

Registers a plugin to this Ripe instance.

bindImage

fun bindImage(view: ImageView, options: Map<String, Any> = HashMap()): Image

Binds an Image to this Ripe instance.

bindInteractable

fun bindInteractable(child: Interactable): Interactable

Binds an Interactable to this Ripe instance.

canRedo

fun canRedo(): Boolean

Indicates if there are part changes to redo.

canUndo

fun canUndo(): Boolean

Indicates if there are part changes to undo.

cloneParts

fun cloneParts(parts: Map<String, Any>): Map<String, Any>

config

suspend fun config(brand: String?, model: String?, options: Map<String, Any> = HashMap()): Unit

Sets the model to be customised.

deselectPart

fun deselectPart(part: String, options: Map<String, Any> = HashMap()): Unit

Deselects a part of the model. Triggers a "deselected_part" event with the part.

getPartsCopy

fun getPartsCopy(): Map<String, Any>

Retrieves a copy of the current customization.

isReady

suspend fun isReady(): Boolean?

Verifies if the current ripe instance is ready (properly loaded) and if not blocks until it becomes ready.

redo

fun redo(): Unit

Reapplies the last change to the parts that was undone. Notice that if there's a change when the history pointer is in the middle of the stack the complete stack forward is removed (history re-written).

removePlugin

fun removePlugin(plugin: Plugin): Unit

Unregisters a plugin to this Ripe instance.

selectPart

fun selectPart(part: String, options: Map<String, Any> = HashMap()): Unit

Selects a part of the model. Triggers a "selected_part" event with the part.

setInitials

fun setInitials(initials: String, engraving: String, noUpdate: Boolean = false): Unit

Changes the personalization of the model.

setPart

fun setPart(part: String, material: String?, color: String?, noEvents: Boolean = false, options: Map<String, Any> = HashMap()): Unit

Changes the customization of a part.

setParts

fun setParts(parts: Any, noEvents: Boolean = false, options: Map<String, Any> = HashMap()): Unit

Allows changing the customization of a set of parts in bulk.

unbindImage

fun unbindImage(image: Image): Unit

Unbinds an Image from this Ripe instance.

unbindInteractable

fun unbindInteractable(child: Interactable): Unit

Unbinds an Interactable from this Ripe instance.

undo

fun undo(): Unit

Reverses the last change to the parts. It is possible to undo all the changes done from the initial state.

update

fun update(state: Map<String, Any> = this._getState()): Unit

Triggers the update of the children so that they represent the current state of the model.

Inherited Functions

addCallback

fun addCallback(event: String, callback: ObservableCallback): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter and return a Deferred that will be completed asynchronously.

bind

fun bind(event: String, callback: (args: Map<String, Any>) -> Unit): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter. The block will be executed synchronously, for costly operations prefer the use of bindAsync.

bindAsync

fun bindAsync(event: String, callback: ObservableCallback): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter and return a Deferred that will be completed asynchronously.

bindSync

fun bindSync(event: String, callback: (args: Map<String, Any>) -> Unit): ObservableCallback

Binds to an event by providing a block that will receive the event payload as a parameter. The block will be executed synchronously, for costly operations prefer the use of bindAsync.

removeCallback

fun removeCallback(event: String, callback: ObservableCallback?): Unit

Unbinds the provided callback from an event.

runCallbacks

fun runCallbacks(event: String, args: Map<String, Any> = HashMap()): Deferred<List<Any?>>

Triggers the event by calling all its bound callbacks with args as parameters.

trigger

fun trigger(event: String, args: Map<String, Any> = HashMap()): Deferred<List<Any?>>

Triggers the event by calling all its bound callbacks with args as parameters.

unbind

fun unbind(event: String, callback: ObservableCallback?): Unit

Unbinds the provided callback from an event.

waitForEvent

suspend fun waitForEvent(event: String): Any

Waits for a certain event to occurs suspending the current coroutine until the event is triggered.