@GuardedBy("this") private void releaseTree() { if (mComponentTree != null) { mComponentTree.release(); mComponentTree = null; } mIsTreeValid = false; }
public void release() { assertMainThread(); if (mComponentTree != null) { mComponentTree.release(); mComponentTree = null; mNullComponentCause = "release_CT"; } }
@Test public void testSetRootAfterRelease() { ComponentTree componentTree = ComponentTree.create(mContext, mComponent).build(); componentTree.release(); // Verify we don't crash componentTree.setRoot(TestDrawableComponent.create(mContext).build()); }
@Test public void testComponentTreeReleaseClearsView() { Component component = TestDrawableComponent.create(mContext) .build(); ComponentTree componentTree = create( mContext, component) .build(); LithoView lithoView = new LithoView(mContext); lithoView.setComponentTree(componentTree); assertThat(componentTree).isEqualTo(lithoView.getComponentTree()); componentTree.release(); assertThat(lithoView.getComponentTree()).isNull(); }