ContentT
- The type of the content.public abstract class Mountable<ContentT> extends RenderUnit<ContentT> implements Node
Mountable
represents a rendering primitive.
Every Mountable
must define what content it creates via the ContentAllocator
implementation, and its type. It must also implement a mechanism to measure itself given
arbitrary width and height specs. A Mountable
can also specify a collection of Binders to
set and unset properties on the content via RenderUnit's addMountBinder and addAttachBinder
methods.
Experimental. Currently for Litho team internal use only.
RenderUnit
,
Node
RenderUnit.Binder<MODEL,CONTENT>, RenderUnit.DelegateBinder<MODEL,CONTENT>, RenderUnit.RenderType
LayoutResult
Constructor and Description |
---|
Mountable(RenderUnit.RenderType renderType) |
Modifier and Type | Method and Description |
---|---|
void |
attachBinders(Context context,
java.lang.Object content,
java.lang.Object layoutData,
Systracer tracer)
This method is an override that calls super impl to keep it protected on RenderUnit.
|
LayoutResult |
calculateLayout(RenderState.LayoutContext context,
int widthSpec,
int heightSpec)
Implementations of Node are responsible to calculate a layout based on the width/height
constraints provided.
|
void |
detachBinders(Context context,
java.lang.Object content,
java.lang.Object layoutData,
Systracer tracer)
This method is an override that calls super impl to keep it protected on RenderUnit.
|
java.util.List<RenderUnit.DelegateBinder<?,ContentT>> |
getAttachBinders()
This method is an override that calls super impl to keep it protected on RenderUnit.
|
java.util.Map<java.lang.Class<?>,RenderUnit.DelegateBinder<?,ContentT>> |
getAttachBinderTypeToDelegateMap()
This method is an override that calls super impl to keep it protected on RenderUnit.
|
long |
getId() |
java.util.List<RenderUnit.DelegateBinder<?,ContentT>> |
getMountBinders()
This method is an override that calls super impl to keep it protected on RenderUnit.
|
java.util.Map<java.lang.Class<?>,RenderUnit.DelegateBinder<?,ContentT>> |
getMountBinderTypeToDelegateMap()
This method is an override that calls super impl to keep it protected on RenderUnit.
|
RenderUnit.RenderType |
getRenderType() |
protected abstract MeasureResult |
measure(RenderState.LayoutContext context,
int widthSpec,
int heightSpec,
java.lang.Object previousLayoutData)
Given a and set the width and height this Mountable will
require on
MeasureResult . |
void |
mountBinders(Context context,
java.lang.Object contentT,
java.lang.Object layoutData,
Systracer tracer)
This method is an override that calls super impl to keep it protected on RenderUnit.
|
void |
setId(long id) |
void |
unmountBinders(Context context,
java.lang.Object contentT,
java.lang.Object layoutData,
Systracer tracer)
This method is an override that calls super impl to keep it protected on RenderUnit.
|
addAttachBinder, addAttachBinders, addMountBinder, addMountBinders, doesMountRenderTreeHosts, getContentAllocator, getDescription, getRenderContentType, onEndUpdateRenderUnit, onStartUpdateRenderUnit
public Mountable(RenderUnit.RenderType renderType)
public final void setId(long id)
public final long getId()
getId
in class RenderUnit<ContentT>
public final RenderUnit.RenderType getRenderType()
getRenderType
in class RenderUnit<ContentT>
public final LayoutResult calculateLayout(RenderState.LayoutContext context, int widthSpec, int heightSpec)
Node
calculateLayout
in interface Node
context
- The LayoutContext associated with this layout calculation RenderState.LayoutContext
widthSpec
- a measure spec for the width in the format of View.MeasureSpec
heightSpec
- a measure spec for the height in the format of View.MeasureSpec
protected abstract MeasureResult measure(RenderState.LayoutContext context, int widthSpec, int heightSpec, java.lang.Object previousLayoutData)
MeasureResult
. In addition on MeasureResult
you can put any data
that is required to set, and unset properties on the content in the binders.
If measure is called again in the same layout pass, then will be the layout data returned by the previous measure call.
As a performance optimisation the framework will skip this method if this Mountable is equal to the previous Mountable, and if the size specs are compatible. In order to do this the framework will check if every field of the Mountable is equal using reflection.
MeasureResult
with the width, height, and optional layout data.public final void mountBinders(Context context, java.lang.Object contentT, java.lang.Object layoutData, Systracer tracer)
mountBinders
in class RenderUnit<ContentT>
public final void unmountBinders(Context context, java.lang.Object contentT, java.lang.Object layoutData, Systracer tracer)
unmountBinders
in class RenderUnit<ContentT>
public final void attachBinders(Context context, java.lang.Object content, java.lang.Object layoutData, Systracer tracer)
attachBinders
in class RenderUnit<ContentT>
public final void detachBinders(Context context, java.lang.Object content, java.lang.Object layoutData, Systracer tracer)
detachBinders
in class RenderUnit<ContentT>
public final java.util.Map<java.lang.Class<?>,RenderUnit.DelegateBinder<?,ContentT>> getMountBinderTypeToDelegateMap()
getMountBinderTypeToDelegateMap
in class RenderUnit<ContentT>
public final java.util.List<RenderUnit.DelegateBinder<?,ContentT>> getMountBinders()
getMountBinders
in class RenderUnit<ContentT>
public final java.util.Map<java.lang.Class<?>,RenderUnit.DelegateBinder<?,ContentT>> getAttachBinderTypeToDelegateMap()
getAttachBinderTypeToDelegateMap
in class RenderUnit<ContentT>
public final java.util.List<RenderUnit.DelegateBinder<?,ContentT>> getAttachBinders()
getAttachBinders
in class RenderUnit<ContentT>