The Android Developer Challenge is back! Submit your idea before December 2.

ParallaxTarget

abstract class ParallaxTarget
kotlin.Any
   ↳ androidx.leanback.widget.ParallaxTarget

ParallaxTarget is responsible for updating the target through the update(float) method or the directUpdate(Number) method when isDirectMapping() is true. When isDirectMapping() is false, ParallaxEffect transforms the values of Parallax, which represents the current state of UI, into a float value between 0 and 1. That float value is passed into update(float) method.

Summary

Nested classes

DirectPropertyTarget is to support direct mapping into either Integer Property or Float Property.

PropertyValuesHolderTarget is an implementation of ParallaxTarget that uses PropertyValuesHolder to update the target object.

Public constructors

ParallaxTarget is responsible for updating the target through the update(float) method or the directUpdate(Number) method when isDirectMapping() is true.

Public methods

open Unit

Directly update the target using a float or int value.

open Boolean

Returns true if the ParallaxTarget is directly mapping from source value, directUpdate(Number) will be used to update value, otherwise update(fraction) will be called to update value.

open Unit
update(fraction: Float)

Implementation class is supposed to update target with the provided fraction (between 0 and 1).

Public constructors

<init>

ParallaxTarget()

ParallaxTarget is responsible for updating the target through the update(float) method or the directUpdate(Number) method when isDirectMapping() is true. When isDirectMapping() is false, ParallaxEffect transforms the values of Parallax, which represents the current state of UI, into a float value between 0 and 1. That float value is passed into update(float) method.

Public methods

directUpdate

open fun directUpdate(value: Number!): Unit

Directly update the target using a float or int value. Called when isDirectMapping() is true.

Parameters
value Number!: Either int or float value.

isDirectMapping

open fun isDirectMapping(): Boolean

Returns true if the ParallaxTarget is directly mapping from source value, directUpdate(Number) will be used to update value, otherwise update(fraction) will be called to update value. Default implementation returns false.

Return
Boolean: True if direct mapping, false otherwise.

update

open fun update(fraction: Float): Unit

Implementation class is supposed to update target with the provided fraction (between 0 and 1). The fraction represents percentage of completed change (e.g. scroll) on target. Called only when isDirectMapping() is false.

Parameters
fraction Float: Fraction between 0 to 1.