Class RepositoryToArrayAdapter<T extends DatabaseObject>

java.lang.Object
com.example.skeddly.business.database.repository.adapter.RepositoryToArrayAdapter<T>
Type Parameters:
T - The type of object that this adapter shall manage.

public class RepositoryToArrayAdapter<T extends DatabaseObject> extends Object
This classes uses the given repositories to supply data to an ArrayAdapter. If multiple repos are provided, you can switch between which is shown in the ArrayAdapter.
  • Constructor Details

    • RepositoryToArrayAdapter

      public RepositoryToArrayAdapter(List<GenericRepository<T>> repositories, android.widget.ArrayAdapter<T> adapter, boolean realtimeUpdates)
      Create a new RepositoryToArrayAdapter with multiple repositories. Real time updates are an option via the boolean.

      Warning: If using the real time updates, the caller must ensure to remove the real time listener via the removeListener() method once updates are no longer required. This can be done inside the onDestroyView() function for example.

      Parameters:
      repositories - The repositories that shall be queried for data
      adapter - The adapter to add data to
      realtimeUpdates - Whether we should use real time updates for data.
    • RepositoryToArrayAdapter

      public RepositoryToArrayAdapter(GenericRepository<T> repository, android.widget.ArrayAdapter<T> adapter, boolean realtimeUpdates)
      Create a new RepositoryToArrayAdapter with a single repository. Real time updates are an option via the boolean.

      Warning: If using the real time updates, the caller must ensure to remove the real time listener via the removeListener() method once updates are no longer required. This can be done inside the onDestroyView() function for example.

      Parameters:
      repository - The repository that shall be queried for data
      adapter - The adapter to add data to
      realtimeUpdates - Whether we should use real time updates for data.
  • Method Details

    • switchDataset

      public void switchDataset(GenericRepository<T> repository) throws IllegalArgumentException
      Switch to a new dataset given by the repository. If the repository does not exist in the ones managed by this adapter, an exception is thrown.
      Parameters:
      repository - The repository who we should switch to showing in the array adapter
      Throws:
      IllegalArgumentException - If the repository passed is not managed by this adapter.
    • removeListener

      public void removeListener()
      Removes the real time listener if one is present. If one is not present, or the listener has already been removed, nothing happens.