Package 

Class ConcatAdapter

    • Method Detail

      • addAdapter

         boolean addAdapter(int index, @NonNull() RecyclerView.Adapter<out RecyclerView.ViewHolder> adapter)

        Adds the given adapter to the given index among other adapters that are already added.

        Parameters:
        index - The index into which to insert the adapter.
        adapter - The new adapter to add to the adapters list.
      • getItemViewType

         int getItemViewType(int position)

        Return the view type of the item at position for the purposesof view recycling.

        The default implementation of this method returns 0, making the assumption ofa single view type for the adapter. Unlike ListView adapters, types need notbe contiguous. Consider using id resources to uniquely identify item view types.

        Parameters:
        position - position to query
      • onCreateViewHolder

        @NonNull() RecyclerView.ViewHolder onCreateViewHolder(@NonNull() ViewGroup parent, int viewType)

        Called when RecyclerView needs a new ViewHolder of the given type to representan item.

        This new ViewHolder should be constructed with a new View that can represent the itemsof the given type. You can either create a new View manually or inflate it from an XMLlayout file.

        The new ViewHolder will be used to display items of the adapter using onBindViewHolder. Since it will be re-used to displaydifferent items in the data set, it is a good idea to cache references to sub views ofthe View to avoid unnecessary findViewById calls.

        Parameters:
        parent - The ViewGroup into which the new View will be added after it is bound toan adapter position.
        viewType - The view type of the new View.
      • onBindViewHolder

         void onBindViewHolder(@NonNull() RecyclerView.ViewHolder holder, int position)

        Called by RecyclerView to display the data at the specified position. This method shouldupdate the contents of the itemView to reflect the item at the givenposition.

        Note that unlike android.widget.ListView, RecyclerView will not call this methodagain if the position of the item changes in the data set unless the item itself isinvalidated or the new position cannot be determined. For this reason, you should onlyuse the position parameter while acquiring the related data item insidethis method and should not keep a copy of it. If you need the position of an item lateron (e.g. in a click listener), use getBindingAdapterPosition whichwill have the updated adapter position.Override onBindViewHolder instead if Adapter canhandle efficient partial bind.

        Parameters:
        holder - The ViewHolder which should be updated to represent the contents of theitem at the given position in the data set.
        position - The position of the item within the adapter's data set.
      • setHasStableIds

         void setHasStableIds(boolean hasStableIds)

        Calling this method is an error and will result in an UnsupportedOperationException.You should use the Config object passed into the ConcatAdapter to configure thisbehavior.

        Parameters:
        hasStableIds - Whether items in data set have unique identifiers or not.
      • getItemId

         long getItemId(int position)

        Return the stable ID for the item at position. If hasStableIds would return false this method should return NO_ID. The default implementationof this method returns NO_ID.

        Parameters:
        position - Adapter position to query
      • getItemCount

         int getItemCount()

        Returns the total number of items in the data set held by the adapter.

      • onFailedToRecycleView

         boolean onFailedToRecycleView(@NonNull() RecyclerView.ViewHolder holder)

        Called by the RecyclerView if a ViewHolder created by this Adapter cannot be recycleddue to its transient state. Upon receiving this callback, Adapter can clear theanimation(s) that effect the View's transient state and return true so thatthe View can be recycled. Keep in mind that the View in question is already removed fromthe RecyclerView.

        In some cases, it is acceptable to recycle a View although it has transient state. Mostof the time, this is a case where the transient state will be cleared in onBindViewHolder call when View is rebound to a new position.For this reason, RecyclerView leaves the decision to the Adapter and uses the returnvalue of this method to decide whether the View should be recycled or not.

        Note that when all animations are created by ItemAnimator, youshould never receive this callback because RecyclerView keeps those Views as childrenuntil their animations are complete. This callback is useful when children of the itemviews create animations which may not be easy to implement using an ItemAnimator.

        You should never fix this issue by callingholder.itemView.setHasTransientState(false); unless you've previously calledholder.itemView.setHasTransientState(true);. EachView.setHasTransientState(true) call must be matched by aView.setHasTransientState(false) call, otherwise, the state of the Viewmay become inconsistent. You should always prefer to end or cancel animations that aretriggering the transient state instead of handling it manually.

        Parameters:
        holder - The ViewHolder containing the View that could not be recycled due to itstransient state.
      • onViewAttachedToWindow

         void onViewAttachedToWindow(@NonNull() RecyclerView.ViewHolder holder)

        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 seenby the user. If the adapter previously freed any resources in onViewDetachedFromWindow those resources should be restored here.

        Parameters:
        holder - Holder of the view being attached
      • onViewDetachedFromWindow

         void onViewDetachedFromWindow(@NonNull() RecyclerView.ViewHolder holder)

        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 an Adapter's views may choose to cache views offscreen while theyare not visible, attaching and detaching them as appropriate.

        Parameters:
        holder - Holder of the view being detached
      • onViewRecycled

         void onViewRecycled(@NonNull() RecyclerView.ViewHolder holder)

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

        A view is recycled when a LayoutManager decides that it no longerneeds to be attached to its parent RecyclerView. This can be because it hasfallen out of visibility or a set of cached views represented by views stillattached to the parent RecyclerView. If an item view has large or expensive databound to it such as large bitmaps, this may be a good place to release thoseresources.

        RecyclerView calls this method right before clearing ViewHolder's internal data andsending it to RecycledViewPool. This way, if ViewHolder was holding valid informationbefore being recycled, you can call getBindingAdapterPosition to getits adapter position.

        Parameters:
        holder - The ViewHolder for the view being recycled
      • onAttachedToRecyclerView

         void onAttachedToRecyclerView(@NonNull() RecyclerView recyclerView)

        Called by RecyclerView when it starts observing this Adapter.

        Keep in mind that same adapter may be observed by multiple RecyclerViews.

        Parameters:
        recyclerView - The RecyclerView instance which started observing this adapter.
      • onDetachedFromRecyclerView

         void onDetachedFromRecyclerView(@NonNull() RecyclerView recyclerView)

        Called by RecyclerView when it stops observing this Adapter.

        Parameters:
        recyclerView - The RecyclerView instance which stopped observing this adapter.