Package 

Class SimpleEpoxyAdapter

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

    
    public class SimpleEpoxyAdapter
    extends EpoxyAdapter
                        

    A non-abstract version of com.airbnb.epoxy.EpoxyAdapter that exposes all methods and models as public. Use this if you don't want to create your own adapter subclass and instead want to modify the adapter from elsewhere, such as from an activity.

    • Method Summary

      Modifier and Type Method Description
      List<EpoxyModel<out Object>> getModels()
      void enableDiffing() Enables support for automatically notifying model changes via notifyModelsChanged.If used, this should be called in the constructor, before any models are changed.
      void notifyModelsChanged() Intelligently notify item changes by comparing the current models list against theprevious so you don't have to micromanage notification calls yourself.
      BoundViewHolders getBoundViewHolders() Returns an object that manages the view holders currently bound to the RecyclerView.
      void notifyModelChanged(EpoxyModel<out Object> model) Notify that the given model has had its data changed.
      void addModels(Array<EpoxyModel<out Object>> modelsToAdd) Adds the models to the end of the models list and notifies that the items wereinserted.
      void addModels(Collection<out EpoxyModel<out Object>> modelsToAdd) Adds the models to the end of the models list and notifies that the items wereinserted.
      void insertModelBefore(EpoxyModel<out Object> modelToInsert, EpoxyModel<out Object> modelToInsertBefore) Inserts the given model before the other in the models list, and notifies that theitem was inserted.
      void insertModelAfter(EpoxyModel<out Object> modelToInsert, EpoxyModel<out Object> modelToInsertAfter) Inserts the given model after the other in the models list, and notifies that the itemwas inserted.
      void removeModel(EpoxyModel<out Object> model) If the given model exists it is removed and an item removal is notified.
      void removeAllModels() Removes all models
      void removeAllAfterModel(EpoxyModel<out Object> model) Removes all models after the given model, which must have already been added.
      void showModel(EpoxyModel<out Object> model, boolean show) Sets the visibility of the given model, and notifies that the item changed if the newvisibility is different from the previous.
      void showModel(EpoxyModel<out Object> model) Shows the given model, and notifies that the item changed if the item wasn't already shown.
      void showModels(Array<EpoxyModel<out Object>> models) Shows the given models, and notifies that each item changed if the item wasn't already shown.
      void showModels(boolean show, Array<EpoxyModel<out Object>> models) Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous.
      void showModels(Iterable<EpoxyModel<out Object>> epoxyModels) Shows the given models, and notifies that each item changed if the item wasn't already shown.
      void showModels(Iterable<EpoxyModel<out Object>> epoxyModels, boolean show) Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous.
      void hideModel(EpoxyModel<out Object> model) Hides the given model, and notifies that the item changed if the item wasn't already hidden.
      void hideModels(Iterable<EpoxyModel<out Object>> epoxyModels) Hides the given models, and notifies that each item changed if the item wasn't already hidden.
      void hideModels(Array<EpoxyModel<out Object>> models) Hides the given models, and notifies that each item changed if the item wasn't already hidden.
      void hideAllAfterModel(EpoxyModel<out Object> model) Hides all models currently located after the given model in the models list.
      List<EpoxyModel<out Object>> getAllModelsAfter(EpoxyModel<out Object> model) Returns a sub list of all items in models that occur after the given model.
      int getModelPosition(EpoxyModel<out Object> model) Finds the position of the given model in the list.
      • Methods inherited from class com.airbnb.epoxy.BaseEpoxyAdapter

        getItemCount, getItemId, getItemViewType, getSpanCount, getSpanSizeLookup, isEmpty, isMultiSpan, isStickyHeader, onBindViewHolder, onBindViewHolder, onCreateViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onRestoreInstanceState, onSaveInstanceState, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, setSpanCount, setupStickyHeaderView, teardownStickyHeaderView
      • Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter

        bindViewHolder, createViewHolder, findRelativeAdapterPositionIn, getItemCount, getItemId, getItemViewType, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onCreateViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver
      • 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
    • Method Detail

      • enableDiffing

         void enableDiffing()

        Enables support for automatically notifying model changes via notifyModelsChanged.If used, this should be called in the constructor, before any models are changed.

      • notifyModelsChanged

         void notifyModelsChanged()

        Intelligently notify item changes by comparing the current models list against theprevious so you don't have to micromanage notification calls yourself. This may beprohibitively slow for large model lists (in the hundreds), in which case consider doingnotification calls yourself. If you use this, all your view models must implement and equals to completely identify theirstate, so that changes to a model's content can be detected. Before using this you must enableit with enableDiffing, since keeping track of the model state adds extra computationtime to all other data change notifications.

      • getBoundViewHolders

         BoundViewHolders getBoundViewHolders()

        Returns an object that manages the view holders currently bound to the RecyclerView. Thisobject is mainly used by the base Epoxy adapter to save view states, but you may find it usefulto help access views or models currently shown in the RecyclerView.

      • notifyModelChanged

         void notifyModelChanged(EpoxyModel<out Object> model)

        Notify that the given model has had its data changed. It should only be called if the modelretained the same position.

      • addModels

         void addModels(Array<EpoxyModel<out Object>> modelsToAdd)

        Adds the models to the end of the models list and notifies that the items wereinserted.

      • removeModel

         void removeModel(EpoxyModel<out Object> model)

        If the given model exists it is removed and an item removal is notified. Otherwise this doesnothing.

      • removeAllAfterModel

         void removeAllAfterModel(EpoxyModel<out Object> model)

        Removes all models after the given model, which must have already been added. An example usecase is you want to keep a header but clear everything else, like in the case of refreshingdata.

      • showModel

         void showModel(EpoxyModel<out Object> model, boolean show)

        Sets the visibility of the given model, and notifies that the item changed if the newvisibility is different from the previous.

        Parameters:
        model - The model to show.
        show - True to show the model, false to hide it.
      • showModel

         void showModel(EpoxyModel<out Object> model)

        Shows the given model, and notifies that the item changed if the item wasn't already shown.

        Parameters:
        model - The model to show.
      • showModels

         void showModels(Array<EpoxyModel<out Object>> models)

        Shows the given models, and notifies that each item changed if the item wasn't already shown.

        Parameters:
        models - The models to show.
      • showModels

         void showModels(boolean show, Array<EpoxyModel<out Object>> models)

        Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous.

        Parameters:
        show - True to show the models, false to hide them.
        models - The models to show.
      • showModels

         void showModels(Iterable<EpoxyModel<out Object>> epoxyModels, boolean show)

        Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous.

        Parameters:
        show - True to show the models, false to hide them.
      • hideModel

         void hideModel(EpoxyModel<out Object> model)

        Hides the given model, and notifies that the item changed if the item wasn't already hidden.

        Parameters:
        model - The model to hide.
      • hideModels

         void hideModels(Iterable<EpoxyModel<out Object>> epoxyModels)

        Hides the given models, and notifies that each item changed if the item wasn't already hidden.

      • hideModels

         void hideModels(Array<EpoxyModel<out Object>> models)

        Hides the given models, and notifies that each item changed if the item wasn't already hidden.

        Parameters:
        models - The models to hide.
      • hideAllAfterModel

         void hideAllAfterModel(EpoxyModel<out Object> model)

        Hides all models currently located after the given model in the models list.

        Parameters:
        model - The model after which to hide.
      • getAllModelsAfter

         List<EpoxyModel<out Object>> getAllModelsAfter(EpoxyModel<out Object> model)

        Returns a sub list of all items in models that occur after the given model. This listis backed by the original models list, any changes to the returned list will be reflected inthe original models list.

        Parameters:
        model - Must exist in models.
      • getModelPosition

         int getModelPosition(EpoxyModel<out Object> model)

        Finds the position of the given model in the list. Doesn't use indexOf to avoid unnecessaryequals() calls since we're looking for the same object instance.