Class DynamicTutorialsAdapter<V extends Fragment,T extends Tutorial<T,V>>

Type Parameters:
V - The type of the view or fragment this adapter will handle.
T - The type of the tutorial this adapter will handle.
All Implemented Interfaces:
StatefulAdapter

public class DynamicTutorialsAdapter<V extends Fragment,T extends Tutorial<T,V>> extends DynamicFragmentStateAdapter
A DynamicFragmentStateAdapter to display the supplied Tutorial.
  • Constructor Details

    • DynamicTutorialsAdapter

      public DynamicTutorialsAdapter(@NonNull FragmentActivity fragmentActivity)
      Constructor to initialize an object of this class.
      Parameters:
      fragmentActivity - The fragment activity to do the transactions.
  • Method Details

    • createFragment

      @NonNull public Fragment createFragment(int position)
      Specified by:
      createFragment in class FragmentStateAdapter
    • getItemCount

      public int getItemCount()
      Specified by:
      getItemCount in class RecyclerView.Adapter<FragmentViewHolder>
    • onAttachedToRecyclerView

      public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView)
      Overrides:
      onAttachedToRecyclerView in class DynamicFragmentStateAdapter
    • onSetupRecyclerView

      protected void onSetupRecyclerView()
      Description copied from class: DynamicFragmentStateAdapter
      This method will be called to setup the recycler view.
      Overrides:
      onSetupRecyclerView in class DynamicFragmentStateAdapter
    • setTutorials

      public void setTutorials(@NonNull Collection<? extends Tutorial<T,V>> tutorials)
      Set tutorials for this adapter.
      Parameters:
      tutorials - The collection of tutorials to be set.
    • addTutorial

      public boolean addTutorial(int location, @NonNull Tutorial<T,V> tutorial)
      Add tutorial to this adapter.
      Parameters:
      location - The index at which to add.
      tutorial - The tutorial to be added.
      Returns:
      true if the tutorial added successfully.
    • addTutorial

      public boolean addTutorial(@NonNull Tutorial<T,V> tutorial)
      Add tutorial to this adapter.
      Parameters:
      tutorial - The tutorial to be added.
      Returns:
      true if the tutorial added successfully.
    • addTutorials

      public boolean addTutorials(int location, @NonNull Collection<? extends Tutorial<T,V>> tutorials)
      Add a collection of tutorials to this adapter.
      Parameters:
      location - The index at which to add.
      tutorials - The collection of tutorials to be added.
      Returns:
      true if the tutorials added successfully.
    • addTutorials

      public boolean addTutorials(@NonNull Collection<? extends Tutorial<T,V>> tutorials)
      Add a collection of tutorials to this adapter.
      Parameters:
      tutorials - The collection of tutorials to be added.
      Returns:
      true if the tutorials added successfully.
    • clearTutorials

      public boolean clearTutorials()
      Remove all the tutorials from this adapter.
      Returns:
      true if the tutorials removed successfully.
    • getTutorials

      @NonNull public List<Tutorial<T,V>> getTutorials()
      Get the tutorials shown by this adapter.
      Returns:
      The tutorials shown by this adapter.
    • getTutorial

      @Nullable public Tutorial<T,V> getTutorial(int position)
      Returns the tutorial for a particular position.
      Parameters:
      position - The position to get the tutorial.
      Returns:
      The tutorial at the supplied position.
    • removeTutorial

      public boolean removeTutorial(@NonNull Tutorial<T,V> tutorial)
      Remove tutorial from this adapter.
      Parameters:
      tutorial - The tutorial to be removed.
      Returns:
      true if the tutorial removed successfully.
    • removeTutorials

      public boolean removeTutorials(@NonNull Collection<? extends Tutorial<T,V>> tutorials)
      Remove a collection of tutorials from this adapter.
      Parameters:
      tutorials - The collection of tutorials to be removed.
      Returns:
      true if the tutorials removed successfully.
    • retainTutorials

      public boolean retainTutorials(@NonNull Collection<? extends Tutorial<T,V>> tutorials)
      Retain a collection of tutorials to this adapter.
      Parameters:
      tutorials - The collection of tutorials to be retained.
      Returns:
      true if the tutorials retained successfully.