android-beans / rocks.frieler.android.beans.scopes.activity / ActivityScopedFactoryBeanHandler

ActivityScopedFactoryBeanHandler

class ActivityScopedFactoryBeanHandler : ScopedFactoryBeanHandler

ScopedFactoryBeanHandler for the ACTIVITY_SCOPE-scope.

It provides a bean-instance per android.app.Activity, always scoped to the foreground-activity. Due to the limitation of the ViewModelProviders this only works for subtypes of ComponentActivity such as the android.support.v7.app.AppCompatActivity.

The ActivityScopedFactoryBeanHandler supports the ActivityAware-interface.

Author
Christopher Frieler

Types

ActivityScopedBeanHolder

class ActivityScopedBeanHolder<T : Any> : ViewModel

Constructors

<init>

ActivityScopedFactoryBeanHandler(foregroundActivityHolder: ForegroundActivityHolder)

ScopedFactoryBeanHandler for the ACTIVITY_SCOPE-scope.

Properties

isActive

val isActive: Boolean

Checks whether the scope is active, i.e. if beans of this scope are currently available.

name

val name: String

Returns the name of the scope.

Functions

getBean

fun <T : Any> getBean(name: String, factoryBean: ScopedFactoryBean<T>, dependencies: BeansProvider): T

Returns the bean defined by the given ScopedFactoryBean.

Companion Object Properties

ACTIVITY_SCOPE

const val ACTIVITY_SCOPE: String

The name of the Activity-scope.