Package 

Class Typed2EpoxyController

  • All Implemented Interfaces:
    com.airbnb.epoxy.ModelCollector , com.airbnb.epoxy.stickyheader.StickyHeaderCallbacks

    
    public abstract class Typed2EpoxyController<T, U>
    extends EpoxyController
                        

    This is a wrapper around com.airbnb.epoxy.EpoxyController to simplify how data is accessed. Use this if the data required to build your models is represented by two objects.

    To use this, create a subclass typed with your data object. Then, call setData whenever that data changes. This class will handle calling buildModels with the latest data.

    You should NOT call requestModelBuild directly.

    • Method Summary

      Modifier and Type Method Description
      void setData(T data1, U data2) Call this with the latest data when you want models to be rebuilt.
      final void requestModelBuild() Call this to request a model update.
      void moveModel(int fromPosition, int toPosition) An optimized way to move a model from one position to another without rebuilding all models.
      void requestDelayedModelBuild(int delayMs) Call this to request a delayed model update.
      • Methods inherited from class com.airbnb.epoxy.EpoxyController

        add, addInterceptor, addModelBuildListener, cancelPendingModelBuild, getAdapter, getSpanCount, getSpanSizeLookup, hasPendingModelBuild, isDebugLoggingEnabled, isDuplicateFilteringEnabled, isMultiSpan, isStickyHeader, notifyModelChanged, onRestoreInstanceState, onSaveInstanceState, removeInterceptor, removeModelBuildListener, setDebugLoggingEnabled, setFilterDuplicates, setGlobalDebugLoggingEnabled, setGlobalDuplicateFilteringDefault, setGlobalExceptionHandler, setSpanCount, setupStickyHeaderView, teardownStickyHeaderView
      • Methods inherited from class com.airbnb.epoxy.ModelCollector

        add
      • Methods inherited from class com.airbnb.epoxy.stickyheader.StickyHeaderCallbacks

        isStickyHeader, setupStickyHeaderView, teardownStickyHeaderView
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Typed2EpoxyController

        Typed2EpoxyController()
      • Typed2EpoxyController

        Typed2EpoxyController(Handler modelBuildingHandler, Handler diffingHandler)
    • Method Detail

      • setData

         void setData(T data1, U data2)

        Call this with the latest data when you want models to be rebuilt. The data will be passed onto buildModels

      • requestModelBuild

         final void requestModelBuild()

        Call this to request a model update. The controller will schedule a call to so that models can be rebuilt for the current data. Once a build is requestedall subsequent requests are ignored until the model build runs. Therefore, the calling codeneed not worry about calling this multiple times in a row.

        The exception is that the first time this is called on a new instance of it is run synchronously. This allows state to be restored and the initial viewto be draw quicker.

        If you would like to be alerted when models have finished building use addModelBuildListener

      • moveModel

         void moveModel(int fromPosition, int toPosition)

        An optimized way to move a model from one position to another without rebuilding all models.This is intended to be used with androidx.recyclerview.widget.ItemTouchHelper toallow for efficient item dragging and rearranging. It cannot be

        If you call this you MUST also update the data backing your models as necessary.

        This will immediately change the model's position and notify the change to the RecyclerView.However, a delayed request to rebuild models will be scheduled for the future to guarantee thatmodels are in sync with data.

        Parameters:
        fromPosition - Previous position of the item.
        toPosition - New position of the item.
      • requestDelayedModelBuild

         void requestDelayedModelBuild(int delayMs)

        Call this to request a delayed model update. The controller will schedule a call to so that models can be rebuilt for the current data.

        Using this to delay a model update may be helpful in cases where user input is causing manyrapid changes in the models, such as typing. In that case, the view is already updated onscreen and constantly rebuilding models is potentially slow and unnecessary. The downside todelaying the model build too long is that models will not be in sync with the data or view, andscrolling the view offscreen and back onscreen will cause the model to bind old data.

        If a previous request is still pending it will be removed in favor of this new delay

        Any call to requestModelBuild will override a delayed request.

        In most cases you should use requestModelBuild instead of this.

        Parameters:
        delayMs - The time in milliseconds to delay the model build by.