Package 

Class SelectableAdapter

    • Constructor Detail

      • SelectableAdapter

        SelectableAdapter()
    • Method Detail

      • enableLogs

         static void enableLogs(int level)

        Call this once, to enable or disable internal logs with custom level.Logs are disabled by default.

        Parameters:
        level - One of Level value
      • getFlexibleLayoutManager

         IFlexibleLayoutManager getFlexibleLayoutManager()

        Current instance of the wrapper class for LayoutManager suitable for FlexibleAdapter.LayoutManager must be already initialized in the RecyclerView.

        return wrapper class for any non-conventional LayoutManagers or {@code null} if not initialized.

      • setFlexibleLayoutManager

         void setFlexibleLayoutManager(IFlexibleLayoutManager flexibleLayoutManager)

        Allow to use a custom LayoutManager.

        Parameters:
        flexibleLayoutManager - the custom LayoutManager suitable for FlexibleAdapter
      • getMode

         int getMode()

        The current selection mode of the Adapter.

      • setMode

         void setMode(int mode)

        Sets the mode of the selection:

        • IDLE Default. Configures the adapter so that no item can be selected;
        • SINGLE configures the adapter to react at the single tap over an item(previous selection is cleared automatically);
        • MULTI configures the adapter to save the position to the list of theselected items.
        Parameters:
        mode - one of IDLE, SINGLE, MULTI
      • isSelected

         boolean isSelected(int position)

        Indicates if the item, at the provided position, is selected.

        Parameters:
        position - Position of the item to check.
      • isSelectable

         abstract boolean isSelectable(int position)

        Checks if the current item has the property {@code selectable = true}.

        Parameters:
        position - the current position of the item to check
      • toggleSelection

         void toggleSelection(int position)

        Toggles the selection status of the item at a given position.

        The behaviour depends on the selection mode previously set with setMode.

        The Activated State of the ItemView is automatically set in toggleActivation called in {@code onClick} event

        Usage:

        • If you don't want any item to be selected/activated at all, just don't call this method.
        • To have actually the item visually selected you need to add a custom Selector Drawableto the background of the View, via {@code DrawableUtils} or via layout's item:android:background="?attr/selectableItemBackground", pointing to a custom Drawablein the style.xml (note: prefix ?android:attrdoesn't work).
        Parameters:
        position - Position of the item to toggle the selection status for.
      • addSelection

         final boolean addSelection(int position)

        Adds the selection status for the given position without notifying the change.

        Parameters:
        position - Position of the item to add the selection status for.
      • removeSelection

         final boolean removeSelection(int position)

        Removes the selection status for the given position without notifying the change.

        Parameters:
        position - Position of the item to remove the selection status for.
      • selectAll

         void selectAll(Array<Integer> viewTypes)

        Sets the selection status for all items which the ViewTypes are included in the specified array.

        Parameters:
        viewTypes - The ViewTypes for which we want the selection, pass nothing to select all
      • clearSelection

         void clearSelection()

        Clears the selection status for all items one by one and it doesn't stop animations in the items.

        Note 1: Items are not rebound, so an eventual animation is not stopped!Note 2: This method use {@code java.util.Iterator} on synchronized collection toavoid {@code java.util.ConcurrentModificationException}.

      • onSaveInstanceState

         void onSaveInstanceState(Bundle outState)

        Saves the state of the current selection on the items.

        Parameters:
        outState - Current state
      • onRestoreInstanceState

         void onRestoreInstanceState(Bundle savedInstanceState)

        Restores the previous state of the selection on the items.

        Parameters:
        savedInstanceState - Previous state
      • setFastScroller

         void setFastScroller(@Nullable() FastScroller fastScroller)

        Sets up the FastScroller with automatic fetch of accent color.

        IMPORTANT: Call this method after the adapter is added to the RecyclerView.

        NOTE: If the device has at least Lollipop, the Accent color is fetched, otherwisefor previous version, the default value is used.
        Parameters:
        fastScroller - instance of FastScroller
      • onFastScrollerStateChange

         void onFastScrollerStateChange(boolean scrolling)

        Triggered when FastScroller State is changed.

        Parameters:
        scrolling - true if the user is actively scrolling, false when idle