Package 

Class FlexibleViewHolder

    • Method Summary

      Modifier and Type Method Description
      void onClick(View view)
      boolean onLongClick(View view)
      boolean onTouch(View view, MotionEvent event) Should be used only by the Handle View!
      void setFullSpan(boolean enabled) Support for StaggeredGridLayoutManager.
      void toggleActivation() Allows to change and see the activation status on the itemView and to perform animationon inner views.
      float getActivationElevation() Allows to set elevation while the view is activated.
      void scrollAnimators(@NonNull() List<Animator> animators, int position, boolean isForward) This method is automatically called by FlexibleAdapter to animate the View while the useractively scrolls the list (forward or backward).
      void onActionStateChanged(int position, int actionState) Here we handle the event of when the {@code ItemTouchHelper} first registers an itemas being moved or swiped.
      void onItemReleased(int position) Here we handle the event of when the ItemTouchHelper has completed the move or swipe.
      final boolean isDraggable()
      final boolean isSwipeable()
      View getFrontView()
      View getRearLeftView()
      View getRearRightView()
      • Methods inherited from class eu.davidea.viewholders.ContentViewHolder

        getContentView, getFlexibleAdapterPosition, setBackupPosition
      • Methods inherited from class androidx.recyclerview.widget.RecyclerView.ViewHolder

        getAbsoluteAdapterPosition, getAdapterPosition, getBindingAdapter, getBindingAdapterPosition, getItemId, getItemViewType, getLayoutPosition, getOldPosition, getPosition, isRecyclable, setIsRecyclable, toString
      • Methods inherited from class android.view.View.OnClickListener

        onClick
      • Methods inherited from class android.view.View.OnLongClickListener

        onLongClick, onLongClickUseDefaultHapticFeedback
      • Methods inherited from class android.view.View.OnTouchListener

        onTouch
      • Methods inherited from class java.lang.Object

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

      • FlexibleViewHolder

        FlexibleViewHolder(View view, FlexibleAdapter adapter)
        Default constructor.
        Parameters:
        view - The View being hosted in this ViewHolder
        adapter - Adapter instance of type FlexibleAdapter
      • FlexibleViewHolder

        FlexibleViewHolder(View view, FlexibleAdapter adapter, boolean stickyHeader)
        Constructor to configure the sticky behaviour of a view.
        Parameters:
        view - The View being hosted in this ViewHolder
        adapter - Adapter instance of type FlexibleAdapter
        stickyHeader - true if the View can be a Sticky Header, false otherwise
    • Method Detail

      • setFullSpan

         void setFullSpan(boolean enabled)

        Support for StaggeredGridLayoutManager.

        Parameters:
        enabled - true to enable full span size, false to disable
      • toggleActivation

        @CallSuper() void toggleActivation()

        Allows to change and see the activation status on the itemView and to perform animationon inner views.

        Important note! the selected background is visible if you added {@code android:background="?attr/selectableItemBackground"} in the item layout ANDcustomized the file {@code style.xml}.

        Alternatively, to set a background at runtime, you can use the new {@code DrawableUtils} from UI extension.

        Note: This method must be called every time we want the activation state visibleon the itemView, for instance: after a Click (to add the item to the selection list) orafter a LongClick (to activate the ActionMode) or during dragging (to show that we enabledthe Drag).

        If you follow the above instructions, it's not necessary to invalidate this view with {@code notifyItemChanged}: In this way {@code bindViewHolder} won't be called and innerviews can animate without interruptions, eventually you will see the animation runningon those inner views at the same time of selection activation.
      • getActivationElevation

         float getActivationElevation()

        Allows to set elevation while the view is activated.

        Override to return desired value of elevation on this itemView.

        Note: returned value must be in Pixel.
      • scrollAnimators

         void scrollAnimators(@NonNull() List<Animator> animators, int position, boolean isForward)

        This method is automatically called by FlexibleAdapter to animate the View while the useractively scrolls the list (forward or backward).

        Implement your logic for different animators based on position, selection and/ordirection.

        Use can take one of the predefined Animator from package UI class {@code AnimatorHelper} or create your own Animator(s), then add it to the list of animators.
        Parameters:
        animators - NonNull list of animators, which you should add new animators
        position - can be used to differentiate the Animators based on positions
        isForward - can be used to separate animation from top/bottom or from left/right scrolling
      • onActionStateChanged

        @CallSuper() void onActionStateChanged(int position, int actionState)

        Here we handle the event of when the {@code ItemTouchHelper} first registers an itemas being moved or swiped.

        In this implementation, View activation is automatically handled if dragged: The Itemwill be added to the selection list if not selected yet and mode MULTI is activated.

        Parameters:
        position - the position of the item touched
        actionState - one of ACTION_STATE_SWIPE orACTION_STATE_DRAG.
      • onItemReleased

        @CallSuper() void onItemReleased(int position)

        Here we handle the event of when the ItemTouchHelper has completed the move or swipe.

        In this implementation, View activation is automatically handled.

        In case of Drag, the state will be cleared depends by current selection mode!
        Parameters:
        position - the position of the item released