Skip to content

Commit 022026a

Browse files
Fabio Carballofacebook-github-bot
Fabio Carballo
authored andcommitted
Convert LithoRenderContext to Kotlin
Summary: As per title Reviewed By: adityasharat Differential Revision: D43900506 fbshipit-source-id: 7c28e432e8e144c2b3133729f83dff03aa0dc82f
1 parent 6996395 commit 022026a

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

litho-core/src/main/java/com/facebook/litho/LithoLayoutResult.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ MeasureResult measure(
451451

452452
mWasMeasured = true;
453453

454-
if (context.getRenderContext().mLayoutStateContext.isFutureReleased()) {
454+
if (context.getRenderContext().layoutStateContext.isFutureReleased()) {
455455

456456
// If layout is released then skip measurement
457457
size = MeasureResult.error();

litho-core/src/main/java/com/facebook/litho/LithoNode.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ private static void freezeRecursive(LithoNode node, @Nullable LithoNode parent)
432432
parentNode != null ? LithoLayoutResult.getLayoutResultFromYogaNode(parentNode) : null;
433433

434434
final LithoLayoutResult layoutResult = currentNode.createLayoutResult(node);
435-
currentNode.applyDiffNode(renderContext.mLayoutStateContext, layoutResult, parentLayoutResult);
435+
currentNode.applyDiffNode(renderContext.layoutStateContext, layoutResult, parentLayoutResult);
436436
node.setData(new Pair(context, layoutResult));
437437

438438
for (int i = 0; i < currentNode.getChildCount(); i++) {
@@ -449,14 +449,14 @@ private static void freezeRecursive(LithoNode node, @Nullable LithoNode parent)
449449
public @Nullable LithoLayoutResult calculateLayout(
450450
final LayoutContext<LithoRenderContext> c, final int widthSpec, final int heightSpec) {
451451

452-
if (c.getRenderContext().mLayoutStateContext.isReleased()) {
452+
if (c.getRenderContext().layoutStateContext.isReleased()) {
453453
throw new IllegalStateException(
454454
"Cannot calculate a layout with a released LayoutStateContext.");
455455
}
456456

457457
final boolean isTracing = ComponentsSystrace.isTracing();
458458

459-
applyOverridesRecursive(c.getRenderContext().mLayoutStateContext, this);
459+
applyOverridesRecursive(c.getRenderContext().layoutStateContext, this);
460460

461461
if (isTracing) {
462462
ComponentsSystrace.beginSection("freeze:" + getHeadComponent().getSimpleName());

litho-core/src/main/java/com/facebook/litho/LithoRenderContext.java litho-core/src/main/java/com/facebook/litho/LithoRenderContext.kt

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.facebook.litho;
17+
package com.facebook.litho
1818

19-
public class LithoRenderContext {
20-
final LayoutStateContext mLayoutStateContext;
19+
import kotlin.jvm.JvmField
2120

22-
public LithoRenderContext(final LayoutStateContext context) {
23-
mLayoutStateContext = context;
24-
}
25-
}
21+
class LithoRenderContext(@JvmField val layoutStateContext: LayoutStateContext)

litho-core/src/main/java/com/facebook/litho/NestedTreeHolderResult.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected MeasureResult measureInternal(
5252
LayoutContext<LithoRenderContext> context, int widthSpec, int heightSpec) {
5353
final boolean isTracing = ComponentsSystrace.isTracing();
5454
final Component component = mNode.getTailComponent();
55-
if (context.getRenderContext().mLayoutStateContext.isReleased()) {
55+
if (context.getRenderContext().layoutStateContext.isReleased()) {
5656
throw new IllegalStateException(
5757
component.getSimpleName()
5858
+ ": To measure a component outside of a layout calculation use"
@@ -66,7 +66,7 @@ protected MeasureResult measureInternal(
6666
if (parentFromNode != null) {
6767
parentContext = parentFromNode;
6868
} else {
69-
parentContext = context.getRenderContext().mLayoutStateContext.getRootComponentContext();
69+
parentContext = context.getRenderContext().layoutStateContext.getRootComponentContext();
7070
}
7171
} else {
7272
parentContext = mNode.getComponentContextAt(1);
@@ -83,7 +83,7 @@ protected MeasureResult measureInternal(
8383
try {
8484
final @Nullable LithoLayoutResult nestedTree =
8585
Layout.measure(
86-
context.getRenderContext().mLayoutStateContext,
86+
context.getRenderContext().layoutStateContext,
8787
parentContext,
8888
this,
8989
widthSpec,

0 commit comments

Comments
 (0)