@@ -0,0 +1,2441 @@
+/*%0A * Copyright (c) Meta Platforms, Inc. and affiliates.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.facebook.rendercore.text;%0A%0Aimport android.text.SpannableStringBuilder;%0Aimport android.view.View;%0Aimport java.util.ArrayList;%0A%0A/**%0A * A %7B@link SpannableStringBuilder%7D that implements %7B@link MountableCharSequence%7D and is aware when%0A * the TextRenderUnit using it is mounted and unmounted.%0A */%0Apublic class MountableSpannableStringBuilder extends SpannableStringBuilder%0A    implements MountableCharSequence %7B%0A  private final ArrayList%3CMountUnmountListener%3E mMountUnmountListeners;%0A%0A  public MountableSpannableStringBuilder(final CharSequence text) %7B%0A    super(text);%0A    mMountUnmountListeners = new ArrayList%3C%3E();%0A  %7D%0A%0A  /**%0A   * This will be called when the TextRenderUnit is mounted.%0A   *%0A   * @param parent the parent View the string builder is being mounted to.%0A   */%0A  @Override%0A  public void onMount(View parent) %7B%0A    for (final MountUnmountListener mountUnmountListener : mMountUnmountListeners) %7B%0A      mountUnmountListener.onMount(parent);%0A    %7D%0A  %7D%0A%0A  /**%0A   * This will be called when the TextRenderUnit is unmounted.%0A   *%0A   * @param parent the parent View the string builder is being unmounted from.%0A   */%0A  @Override%0A  public void onUnmount(View parent) %7B%0A    for (final MountUnmountListener mountUnmountListener : mMountUnmountListeners) %7B%0A      mountUnmountListener.onUnmount(parent);%0A    %7D%0A  %7D%0A%0A  /**%0A   * Adds a listener to the set of listeners that will be notified of mount/unmount events.%0A   *%0A   * @param mountUnmountListener The listener to add.%0A   */%0A  public void addMountUnmountListener(final MountUnmountListener mountUnmountListener) %7B%0A    mMountUnmountListeners.add(mountUnmountListener);%0A  %7D%0A%0A  /** A listener that is notified of mount/unmount events. */%0A  public interface MountUnmountListener %7B%0A    void onMount(final View parent);%0A%0A    void onUnmount(final View parent);%0A  %7D%0A%7D%0A

Add a SpannableStringBuilder that understands when it is mounted/unmounted