Class TicketDB

java.lang.Object
com.example.breeze_seas.TicketDB

public final class TicketDB extends Object
TicketDB loads ticket-tab data and isolates Firestore access from the UI layer.

Current integration scope: - uses the agreed device-based schema from events/{eventId}/participants/{deviceId} - supports live Firestore loading for the agreed participant statuses

Outstanding: - replace fallback display labels once the final event metadata contract is fully implemented

  • Method Details

    • getInstance

      @NonNull public static TicketDB getInstance()
      Returns the shared ticket data source used by the Tickets feature.
      Returns:
      Singleton TicketDB instance.
    • addListener

      public void addListener(@NonNull TicketDB.Listener listener)
      Registers a listener for ticket-list refresh events.
      Parameters:
      listener - Listener to add if it is not already registered.
    • removeListener

      public void removeListener(@NonNull TicketDB.Listener listener)
      Unregisters a listener that no longer needs ticket updates.
      Parameters:
      listener - Listener to remove.
    • refreshTickets

      public void refreshTickets(@NonNull android.content.Context context, @Nullable String preferredDeviceId)
      Reloads all ticket lists for the provided device-scoped entrant.

      If the preferred device id is unavailable, this falls back to the current Android device id.

      Parameters:
      context - Context used to resolve the Android device identifier fallback.
      preferredDeviceId - Preferred participant device id from the signed-in user session.
    • getActiveTickets

      @NonNull public List<TicketUIModel> getActiveTickets()
      Returns a snapshot of the current Active tab ticket list.
      Returns:
      Copy of the active-ticket list.
    • getAttendingTickets

      @NonNull public List<AttendingTicketUIModel> getAttendingTickets()
      Returns a snapshot of the current Attending tab ticket list.
      Returns:
      Copy of the attending-ticket list.
    • getPastTickets

      @NonNull public List<PastEventUIModel> getPastTickets()
      Returns a snapshot of the current Past tab ticket list.
      Returns:
      Copy of the past-ticket list.
    • acceptInvitation

      public void acceptInvitation(@NonNull TicketUIModel ticket)
      Accepts an active ticket that requires a user decision.

      Public-event invitations move into the attending state. Private-event invitations move into the waiting-list state because the entrant is only accepting the right to join the waitlist for that event and still needs to survive the draw before becoming attending.

      Parameters:
      ticket - Invited ticket being accepted.
    • declineInvitation

      public void declineInvitation(@NonNull TicketUIModel ticket)
      Declines an active ticket that requires a user decision.

      Public-event invitations move into the past-history state. Private-event invitations are simply removed because the entrant is declining the chance to join that private event's waitlist.

      Parameters:
      ticket - Invited ticket being declined.
    • leaveWaitlist

      public void leaveWaitlist(@NonNull TicketUIModel ticket)
      Removes the current entrant from an event's participant list.
      Parameters:
      ticket - Active ticket whose participant row should be deleted.