Package 

Class AbstractFlexibleItem

    • Method Summary

      Modifier and Type Method Description
      abstract boolean equals(Object o) You MUST implement this method to compare items unique identifiers.
      boolean isEnabled() Returns if the Item is enabled.
      void setEnabled(boolean enabled) Setter to change enabled behaviour.
      boolean isHidden() (Internal usage).When and item has been deleted (with Undo) or has been filtered out by theadapter, then, it has hidden status.
      void setHidden(boolean hidden) Setter to change hidden behaviour.
      int getSpanSize(int spanCount, int position) Individual item's span size to use only with {@code GridLayoutManager}.
      boolean shouldNotifyChange(IFlexible newItem) Called by the FlexibleAdapter when it wants to check if this item should be boundagain with new content.
      boolean isSelectable() Checks if the item can be selected.
      void setSelectable(boolean selectable) Setter to change selectable behaviour.
      String getBubbleText(int position) Custom bubble text for FastScroller.
      boolean isDraggable()
      void setDraggable(boolean draggable)
      boolean isSwipeable()
      void setSwipeable(boolean swipeable)
      int getItemViewType() Identifies a specific view type for this item, used by FlexibleAdapter to auto-mapthe ViewTypes.
      abstract int getLayoutRes() Returns the layout resource ID to auto-inflate the View for this item.
      abstract VH createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) Delegates the creation of the ViewHolder to the user (AutoMap).
      abstract void bindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position, List<Object> payloads) Delegates the binding of this item's data to the given Layout.
      void unbindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position) Called when a view created by this adapter has been recycled.
      void onViewAttached(FlexibleAdapter<IFlexible> adapter, VH holder, int position) Called when a view created by this adapter has been attached to a window.
      void onViewDetached(FlexibleAdapter<IFlexible> adapter, VH holder, int position) Called when a view created by this adapter has been detached from its window.
      • Methods inherited from class java.lang.Object

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

      • equals

         abstract boolean equals(Object o)

        You MUST implement this method to compare items unique identifiers.

        Adapter needs this method to distinguish them and pick up correct items.

        See Writing a correct {@code equals} method to implement your own {@code equals} method.

        Hint: If you don't use unique IDs, reimplement with Basic Java implementation:

        public boolean equals(Object o) {
            return this == o;
        }

        Important Note: When used with {@code Hash[Map,Set]}, the general contract for the {@code equals} and hashCode methods is that if {@code equals} returns {@code true} for any two objects, then {@code hashCode()} must return the same value for these objects.This means that subclasses of {@code Object} usually override either both methods or neitherof them.

        Parameters:
        o - instance to compare
      • isEnabled

         boolean isEnabled()

        Returns if the Item is enabled.

      • setEnabled

         void setEnabled(boolean enabled)

        Setter to change enabled behaviour.

        Parameters:
        enabled - false to disable all operations on this item
      • isHidden

         boolean isHidden()

        (Internal usage).When and item has been deleted (with Undo) or has been filtered out by theadapter, then, it has hidden status.

      • setHidden

         void setHidden(boolean hidden)

        Setter to change hidden behaviour. Useful while filtering this item.Default value is false.

        Parameters:
        hidden - true if this item should remain hidden, false otherwise
      • getSpanSize

         int getSpanSize(int spanCount, int position)

        Individual item's span size to use only with {@code GridLayoutManager}.

        Note:

        • Default implementation in AbstractFlexibleItem already returns 1.
        • Not used when {@code StaggeredGridLayoutManager} is set. With such layout use setFullSpan.
        Parameters:
        spanCount - current column count
        position - the adapter position of the item
      • shouldNotifyChange

         boolean shouldNotifyChange(IFlexible newItem)

        Called by the FlexibleAdapter when it wants to check if this item should be boundagain with new content.

        You should return {@code true} whether you want this item will be updated becauseits visual representations will change.

        Note: This method won't be called if setNotifyChangeOfUnfilteredItems is disabled.

        Default value is {@code true}.

        Parameters:
        newItem - The new item object with the new content
      • isSelectable

         boolean isSelectable()

        Checks if the item can be selected.

      • setSelectable

         void setSelectable(boolean selectable)

        Setter to change selectable behaviour.

        Parameters:
        selectable - false to disable selection on this item
      • getBubbleText

         String getBubbleText(int position)

        Custom bubble text for FastScroller.

        To be called from the implementation of {@code onCreateBubbleText()}. Example:

        public String onCreateBubbleText(int position) {
            return getItem(position).getBubbleText(position);
        }
        Parameters:
        position - the current mapped position
      • getItemViewType

         int getItemViewType()

        Identifies a specific view type for this item, used by FlexibleAdapter to auto-mapthe ViewTypes.

        HELP: To know how to implement AutoMap for ViewTypes please refer to theFlexibleAdapter Wiki Pageon GitHub.

        If not overridden return value is the same of getLayoutRes.

      • getLayoutRes

         abstract int getLayoutRes()

        Returns the layout resource ID to auto-inflate the View for this item. Optionally, youcan assign same layout for multiple item types, but #getItemViewType() mustreturn unique values!

        NOTE: Should identify a resource Layout reference .

      • bindViewHolder

         abstract void bindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position, List<Object> payloads)

        Delegates the binding of this item's data to the given Layout.

        HELP: To know how to implement AutoMap for ViewTypes please refer to theFlexibleAdapter Wiki Pageon GitHub.

        How to use Payload, please refer to RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List).
      • unbindViewHolder

         void unbindViewHolder(FlexibleAdapter<IFlexible> adapter, VH holder, int position)

        Called when a view created by this adapter has been recycled.

        A view is recycled when a RecyclerView.LayoutManager} decides that it no longerneeds to be attached to its parent RecyclerView. This can be because it has fallen outof visibility or a set of cached views represented by views still attached to the parentRecyclerView.

        If an item view has large or expensive data bound to it such as large bitmaps, this may bea good place to release those resources.
      • onViewAttached

         void onViewAttached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)

        Called when a view created by this adapter has been attached to a window.

        This can be used as a reasonable signal that the view is about to be seen by the user.

      • onViewDetached

         void onViewDetached(FlexibleAdapter<IFlexible> adapter, VH holder, int position)

        Called when a view created by this adapter has been detached from its window.

        Becoming detached from the window is not necessarily a permanent condition; the consumer of anAdapter's views may choose to cache views offscreen while they are not visible, attaching anddetaching them as appropriate.