/** * True if we have manually unmounted content (e.g. via unmountAllItems) which means that while we * may not have a new LayoutState, the mounted content does not match what the viewport for the * LithoView may be. */ boolean needsRemount() { assertMainThread(); return mNeedsRemount; }
/** * Sets whether the next mount will be the first mount of this ComponentTree. This is used to * determine whether to run animations or not (we want animations to run on the first mount of * this ComponentTree, but not other times the mounted ComponentTree id changes). Ideally, we want * animations to only occur when the ComponentTree is updated on screen or is first inserted into * a list onscreen, but that requires more integration with the list controller, e.g. sections, * than we currently have. */ void setIsFirstMountOfComponentTree() { assertMainThread(); mIsFirstMountOfComponentTree = true; }
/** * Called from the ComponentTree when a new view want to use the same ComponentTree. */ void clearComponentTree() { assertMainThread(); if (mIsAttached) { throw new IllegalStateException("Trying to clear the ComponentTree while attached."); } mComponentTree = null; mNullComponentCause = "clear_CT"; }
void clearLithoView() { assertMainThread(); // Crash if the ComponentTree is mounted to a view. if (mIsAttached) { throw new IllegalStateException( "Clearing the LithoView while the ComponentTree is attached"); } mLithoView = null; }
public void release() { assertMainThread(); if (mComponentTree != null) { mComponentTree.release(); mComponentTree = null; mNullComponentCause = "release_CT"; } }
/** * To be called whenever the components needs to start the mount process from scratch * e.g. when the component's props or layout change or when the components * gets attached to a host. */ void setDirty() { assertMainThread(); mIsDirty = true; mPreviousLocalVisibleRect.setEmpty(); }
/** * @return the {@link LithoView} associated with this ComponentTree if any. */ @Keep @Nullable public LithoView getLithoView() { assertMainThread(); return mLithoView; }
void detach() { assertMainThread(); if (mIncrementalMountHelper != null) { mIncrementalMountHelper.onDetach(mLithoView); } synchronized (this) { mIsAttached = false; } }
/** * Returns {@code true} if the layout call mounted the component. */ boolean layout() { assertMainThread(); return mountComponentIfNeeded(); }
void forceMainThreadLayout() { assertMainThread(); LithoView lithoView = mLithoView; if (lithoView != null) { // If we are attached to a LithoView, then force a relayout immediately. Otherwise, we'll // relayout next time we are measured. lithoView.forceRelayout(); } else { mForceLayout = true; } }
void unmountAllItems() { assertMainThread(); if (mLayoutOutputsIds == null) { return; } for (int i = mLayoutOutputsIds.length - 1; i >= 0; i--) { unmountItem(i, mHostsByMarker); } mPreviousLocalVisibleRect.setEmpty(); mNeedsRemount = true; }
static void dispatchOnUnfocused(EventHandler<UnfocusedVisibleEvent> unfocusedHandler) { assertMainThread(); if (sUnfocusedVisibleEvent == null) { sUnfocusedVisibleEvent = new UnfocusedVisibleEvent(); } unfocusedHandler.dispatchEvent(sUnfocusedVisibleEvent); }
static void dispatchOnInvisible(EventHandler<InvisibleEvent> invisibleHandler) { assertMainThread(); if (sInvisibleEvent == null) { sInvisibleEvent = new InvisibleEvent(); } invisibleHandler.dispatchEvent(sInvisibleEvent); }
public void showRefreshing() { SectionsRecyclerView sectionsRecyclerView = mSectionsRecyclerView; if (sectionsRecyclerView == null || sectionsRecyclerView.isRefreshing()) { return; } ThreadUtils.assertMainThread(); sectionsRecyclerView.setRefreshing(true); }
static void dispatchOnFullImpression( EventHandler<FullImpressionVisibleEvent> fullImpressionHandler) { assertMainThread(); if (sFullImpressionVisibleEvent == null) { sFullImpressionVisibleEvent = new FullImpressionVisibleEvent(); } fullImpressionHandler.dispatchEvent(sFullImpressionVisibleEvent); }
@UiThread private void dataBound(Section currentSection) { ThreadUtils.assertMainThread(); if (currentSection != null) { mBoundSection = currentSection; dataBoundRecursive(currentSection); } }
@UiThread private void dataRendered( Section currentSection, boolean isDataChanged, boolean isMounted, long uptimeMillis, ChangesInfo changesInfo) { ThreadUtils.assertMainThread(); if (currentSection != null) { dataRenderedRecursive(currentSection, isDataChanged, isMounted, uptimeMillis, changesInfo); } }
static void dispatchOnClick(EventHandler<ClickEvent> clickHandler, View view) { assertMainThread(); if (sClickEvent == null) { sClickEvent = new ClickEvent(); } sClickEvent.view = view; final EventDispatcher eventDispatcher = clickHandler.mHasEventDispatcher.getEventDispatcher(); eventDispatcher.dispatchOnEvent(clickHandler, sClickEvent); sClickEvent.view = null; }
private void unmountDrawable(MountItem mountItem) { assertMainThread(); final Drawable drawable = (Drawable) mountItem.getMountableContent(); drawable.setCallback(null); invalidate(drawable.getBounds()); releaseScrapDataStructuresIfNeeded(); }
private void mountDrawable(int index, MountItem mountItem, Rect bounds) { assertMainThread(); ensureDrawableMountItems(); mDrawableMountItems.put(index, mountItem); final Drawable drawable = (Drawable) mountItem.getMountableContent(); ComponentHostUtils.mountDrawable( this, drawable, bounds, mountItem.getLayoutFlags(), mountItem.getNodeInfo()); }