{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PlatformTextInputPluginRegistryImpl


Implementation of PlatformTextInputPluginRegistry that manages a map of adapters to cached services and allows retrieval of the first active one.

Summary

Nested types

Public constructors

Cmn

Public functions

PlatformTextInputPluginRegistryImpl.AdapterHandle<T>

Returns the text input service T managed by plugin.

Cmn
open T

Returns an instance of the PlatformTextInputAdapter type T specified by plugin.

Cmn

Public properties

PlatformTextInputAdapter?

Returns the currently-focused adapter, or null if no adapter is focused.

Cmn

Public constructors

PlatformTextInputPluginRegistryImpl

PlatformTextInputPluginRegistryImpl(
    factory: (PlatformTextInputPlugin<*>, PlatformTextInput) -> PlatformTextInputAdapter
)
Parameters
factory: (PlatformTextInputPlugin<*>, PlatformTextInput) -> PlatformTextInputAdapter

A platform-specific function that invokes the appropriate create method on a PlatformTextInputAdapter to return a service.

Public functions

getOrCreateAdapter

@InternalTextApi
fun <T : PlatformTextInputAdapter> getOrCreateAdapter(
    plugin: PlatformTextInputPlugin<T>
): PlatformTextInputPluginRegistryImpl.AdapterHandle<T>

Returns the text input service T managed by plugin.

The first time this method is called for a given PlatformTextInputAdapter, the adapter's platform-specific factory method is called to instantiate the service. The service is then added to the cache and returned. Subsequent calls passing the same adapter, over the entire lifetime of this service provider, will return the same service instance. It is expected that adapters will be singleton objects, and in most apps there will only ever be one or maybe two input adapters in use, since each input adapter represents an entire text input subsystem.

Parameters
<T : PlatformTextInputAdapter>

The type of the PlatformTextInputAdapter that plugin creates.

plugin: PlatformTextInputPlugin<T>

The factory for service objects and the key into the cache of those objects.

rememberAdapter

@Composable
open fun <T : PlatformTextInputAdapter> rememberAdapter(
    plugin: PlatformTextInputPlugin<T>
): T

Returns an instance of the PlatformTextInputAdapter type T specified by plugin.

The returned adapter instance will be shared by all callers of this method passing the same plugin object. The adapter will be created when the first call is made, then cached and returned by every subsequent call in the same or subsequent compositions. When there are no longer any calls to this method for a given plugin, the adapter instance will be PlatformTextInputAdapter.onDisposed.

Parameters
<T : PlatformTextInputAdapter>

The type of PlatformTextInputAdapter that plugin creates.

plugin: PlatformTextInputPlugin<T>

The factory for adapters and the key into the cache of those adapters.

Public properties

focusedAdapter

val focusedAdapterPlatformTextInputAdapter?

Returns the currently-focused adapter, or null if no adapter is focused.

An adapter can request input focus by calling PlatformTextInput.requestInputFocus. It will keep input focus until either:

  1. It calls PlatformTextInput.releaseInputFocus, or

  2. Another adapter calls PlatformTextInput.requestInputFocus.