public final class Text extends SpecGeneratedComponent
Example Text usage:
final SpannableStringBuilder spannable = new SpannableStringBuilder();
spannable.setSpan(new StyleSpan(Typeface.BOLD), start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
Text.create(c)
.text(spannable) // String can be used
.textSizeDip(20)
.maxLines(3)
.ellipsize(TextUtils.TruncateAt.END)
.textColor(Color.BLACK)
.build()
com.facebook.litho.widget.TextSpec
Modifier and Type | Class and Description |
---|---|
static class |
Text.Builder |
SpecGeneratedComponent.TransitionContainer
Component.ContainerBuilder<T extends Component.ContainerBuilder<T>>, Component.MountType, Component.RenderData
Modifier and Type | Method and Description |
---|---|
protected void |
bindDynamicProp(int dynamicPropIndex,
java.lang.Object value,
java.lang.Object mountedContent) |
protected boolean |
canMeasure()
Whether this
Component is able to measure itself according to
specific size constraints. |
boolean |
canPreallocate()
This API informs the framework to fill the content pool for this Mountable ahead of time.
|
protected void |
copyInterStageImpl(InterStagePropsContainer copyIntoInterStagePropsContainer,
InterStagePropsContainer copyFromInterStagePropsContainer) |
static Text.Builder |
create(ComponentContext context) |
static Text.Builder |
create(ComponentContext context,
int defStyleAttr,
int defStyleRes) |
protected com.facebook.litho.widget.Text.TextInterStagePropsContainer |
createInterStagePropsContainer() |
protected DynamicValue[] |
getDynamicProps() |
protected int |
getExtraAccessibilityNodeAt(ComponentContext c,
int x,
int y,
InterStagePropsContainer _3)
Get extra accessibility node id at a given point within the component.
|
protected int |
getExtraAccessibilityNodesCount(ComponentContext c,
InterStagePropsContainer _1)
The number of extra accessibility nodes that this component wishes to provides to the
accessibility system.
|
Component.MountType |
getMountType()
This indicates the type of the
Object that will be returned by com.facebook.litho.Component#mount . |
static EventHandler<TextOffsetOnTouchEvent> |
getTextOffsetOnTouchEventHandler(ComponentContext context) |
boolean |
implementsAccessibility()
Whether this component will populate any accessibility nodes or events that are passed to it.
|
boolean |
implementsExtraAccessibilityNodes()
Whether this component will expose any virtual views to the accessibility framework
|
boolean |
isEquivalentProps(Component other,
boolean shouldCompareCommonProps)
Determine if this component has equivalent props to a given component.
|
protected boolean |
isMountSizeDependent() |
boolean |
isPureRender() |
Text |
makeShallowCopy() |
protected void |
onBoundsDefined(ComponentContext c,
ComponentLayout layout,
InterStagePropsContainer _2)
Called after the layout calculation is finished and the given
ComponentLayout has its
bounds defined. |
protected java.lang.Object |
onCreateMountContent(Context c)
Create the object that will be mounted in the
LithoView . |
protected void |
onLoadStyle(ComponentContext c) |
protected void |
onMeasure(ComponentContext context,
ComponentLayout layout,
int widthSpec,
int heightSpec,
Size size,
InterStagePropsContainer _5) |
protected void |
onMount(ComponentContext c,
java.lang.Object textDrawable,
InterStagePropsContainer _2)
Deploy all UI elements representing the final bounds defined in the given
ComponentLayout . |
protected void |
onPopulateAccessibilityNode(ComponentContext c,
View host,
AccessibilityNodeInfoCompat node,
InterStagePropsContainer _3)
Populate an accessibility node with information about the component.
|
protected void |
onPopulateExtraAccessibilityNode(ComponentContext c,
AccessibilityNodeInfoCompat node,
int extraNodeIndex,
int componentBoundsLeft,
int componentBoundsTop,
InterStagePropsContainer _5)
Populate an extra accessibility node.
|
protected void |
onUnmount(ComponentContext c,
java.lang.Object textDrawable,
InterStagePropsContainer _2)
Unload UI elements associated with this component.
|
int |
poolSize()
This API informs the framework about the size of the content pool.
|
acceptTriggerEvent, acceptTriggerEventImpl, applyPreviousRenderData, copyPrepareInterStageImpl, createContent, createInitialState, createPoolableContent, createPrepareInterStagePropsContainer, createRecyclingPool, createStateContainer, dispatchOnEnteredRange, dispatchOnExitedRange, getInterStagePropsContainer, getPoolableContentType, getPrepareInterStagePropsContainer, getSimpleName, getSimpleNameDelegate, getTreePropsForChildren, hasAttachDetachCallback, hasOwnErrorHandler, hasState, isRecyclingDisabled, needsPreviousRenderData, onAttached, onBind, onCreateLayout, onCreateLayoutWithSizeSpec, onCreateMountContentPool, onDetached, onError, onMeasureBaseline, onPrepare, onUnbind, populateTreeProps, prepare, recordEventTrigger, recordRenderData, render, shouldAlwaysRemeasure, usesLocalStateContainer
clone, createMountContent, dispatchErrorEvent, dispatchOnEvent, dispatchOnEventImpl, equals, excludeFromIncrementalMount, getCommonProps, getErrorHandler, getEventDispatcher, getEventTrigger, getEventTrigger, getHandle, getTreePropFromParent, getTypeId, hasChildLithoViews, hasClickHandlerSet, hashCode, implementsShouldUpdate, isEqualivalentTreeProps, isEquivalentCommonProps, isEquivalentTo, isEquivalentTo, isLayoutSpecWithSizeSpec, isPureRender, measure, measure, measureMightNotCacheInternalNode, newEventHandler, newEventTrigger, newEventTrigger, onCreateTransition, registerWorkingRange, resolve, retrieveValue, shouldUpdate, toString, transferState, willRender
protected com.facebook.litho.widget.Text.TextInterStagePropsContainer createInterStagePropsContainer()
createInterStagePropsContainer
in class SpecGeneratedComponent
public boolean isEquivalentProps(Component other, boolean shouldCompareCommonProps)
Component
isEquivalentProps
in class Component
other
- the component to compare toprotected void copyInterStageImpl(InterStagePropsContainer copyIntoInterStagePropsContainer, InterStagePropsContainer copyFromInterStagePropsContainer)
copyInterStageImpl
in class SpecGeneratedComponent
public Text makeShallowCopy()
makeShallowCopy
in class Component
protected DynamicValue[] getDynamicProps()
getDynamicProps
in class Component
protected void bindDynamicProp(int dynamicPropIndex, java.lang.Object value, java.lang.Object mountedContent)
bindDynamicProp
in class SpecGeneratedComponent
protected void onLoadStyle(ComponentContext c)
onLoadStyle
in class Component
protected void onMeasure(ComponentContext context, ComponentLayout layout, int widthSpec, int heightSpec, Size size, InterStagePropsContainer _5)
onMeasure
in class SpecGeneratedComponent
protected boolean canMeasure()
Component
Component
is able to measure itself according to
specific size constraints.canMeasure
in class Component
protected void onBoundsDefined(ComponentContext c, ComponentLayout layout, InterStagePropsContainer _2)
SpecGeneratedComponent
ComponentLayout
has its
bounds defined. You can use ComponentLayout.getX()
, ComponentLayout.getY()
,
ComponentLayout.getWidth()
, and ComponentLayout.getHeight()
to get the size and
position of the component in the layout tree.onBoundsDefined
in class SpecGeneratedComponent
c
- The Context
used by this component.layout
- The ComponentLayout
with defined position and size.protected java.lang.Object onCreateMountContent(Context c)
Component
LithoView
.onCreateMountContent
in class Component
c
- The Context
to be used to create the content.protected void onMount(ComponentContext c, java.lang.Object textDrawable, InterStagePropsContainer _2)
SpecGeneratedComponent
ComponentLayout
. Return either a Drawable
or a View
or null
to be
mounted.onMount
in class SpecGeneratedComponent
c
- The ComponentContext
to mount the component into.protected void onUnmount(ComponentContext c, java.lang.Object textDrawable, InterStagePropsContainer _2)
SpecGeneratedComponent
onUnmount
in class SpecGeneratedComponent
c
- The Context
for this mount operation.textDrawable
- The Drawable
or View
mounted by this component.protected void onPopulateAccessibilityNode(ComponentContext c, View host, AccessibilityNodeInfoCompat node, InterStagePropsContainer _3)
Component
onPopulateAccessibilityNode
in class Component
node
- node to populatepublic boolean implementsAccessibility()
SpecGeneratedComponent
implementsAccessibility
in class SpecGeneratedComponent
protected int getExtraAccessibilityNodesCount(ComponentContext c, InterStagePropsContainer _1)
SpecGeneratedComponent
getExtraAccessibilityNodesCount
in class SpecGeneratedComponent
protected void onPopulateExtraAccessibilityNode(ComponentContext c, AccessibilityNodeInfoCompat node, int extraNodeIndex, int componentBoundsLeft, int componentBoundsTop, InterStagePropsContainer _5)
Component
onPopulateExtraAccessibilityNode
in class Component
node
- node to populateextraNodeIndex
- index of extra nodecomponentBoundsLeft
- left bound of the mounted componentcomponentBoundsTop
- top bound of the mounted componentpublic boolean implementsExtraAccessibilityNodes()
SpecGeneratedComponent
implementsExtraAccessibilityNodes
in class SpecGeneratedComponent
protected int getExtraAccessibilityNodeAt(ComponentContext c, int x, int y, InterStagePropsContainer _3)
SpecGeneratedComponent
getExtraAccessibilityNodeAt
in class SpecGeneratedComponent
x
- x co-ordinate within the mounted componenty
- y co-ordinate within the mounted componentExploreByTouchHelper#INVALID_ID
public Component.MountType getMountType()
Component
Object
that will be returned by com.facebook.litho.Component#mount
.getMountType
in class Component
Component.MountType
public int poolSize()
ContentAllocator
Experimental. Currently for Litho team internal use only.
poolSize
in interface ContentAllocator
poolSize
in class SpecGeneratedComponent
public boolean canPreallocate()
ContentAllocator
false
, i.e. content is not pre-allocated. Pre-allocation of the
content can improve performance in some circumstances where creating the content is expensive.canPreallocate
in interface ContentAllocator
canPreallocate
in class SpecGeneratedComponent
protected boolean isMountSizeDependent()
isMountSizeDependent
in class SpecGeneratedComponent
public boolean isPureRender()
isPureRender
in class Component
public static EventHandler<TextOffsetOnTouchEvent> getTextOffsetOnTouchEventHandler(ComponentContext context)
public static Text.Builder create(ComponentContext context)
public static Text.Builder create(ComponentContext context, int defStyleAttr, int defStyleRes)