Resource

abstract class Resource(args: Serializable) : ResolvableString

ResolvableString backed by Android resource string with optional arguments. Arguments can be ResolvableStrings as well.

Should be explicitly subclassed to ensure stable persistence, and serialVersionUID must be present. Example:

object InstallMessageTitle : ResolvableString.Resource() {
override fun stringId() = R.string.install_message_title
private const val serialVersionUID = -1310602635578779088L
private fun readResolve(): Any = InstallMessageTitle
}

class InstallMessage(fileName: String) : ResolvableString.Resource(fileName) {
override fun stringId() = R.string.install_message
private companion object {
private const val serialVersionUID = 4749568844072243110L
}
}

For transient strings, i.e. not persisted in storage, you can use ResolvableString.transientResource factory.

Parameters

args

string format arguments

Constructors

Link copied to clipboard
constructor(vararg args: Serializable)

Properties

Link copied to clipboard
open val isEmpty: Boolean

Returns whether this string is empty.

Link copied to clipboard
open val isRaw: Boolean

Returns whether this string represents a hardcoded string.

Link copied to clipboard

Returns whether this string represents a resource string.

Functions

Link copied to clipboard
operator override fun equals(other: Any?): Boolean
Link copied to clipboard
override fun hashCode(): Int
Link copied to clipboard
override fun resolve(context: Context): String

Resolves string value for a given context.