Skip to content

Add a method to update the cached sequence whenever necessary. #2993

@shobhitagarwal1612

Description

@shobhitagarwal1612

// TODO: Add a method to update the cached sequence whenever necessary.
// Issue URL: https://github.com/google/ground-android/issues/2993


  }

  /**
   * Generates the task sequence based on whether a task should be included or not.
   *
   * This determines the order of tasks to be presented to the user, taking into account any
   * overrides specified by [taskValueOverride].
   *
   * @param taskValueOverride An optional pair where the first element is the task ID and the second
   *   element is the [TaskData] to override the default task data. If null, no override is applied.
   * @return A [Sequence] of [Task] objects representing the ordered tasks.
   */
  fun generateTaskSequence(taskValueOverride: Pair<String, TaskData?>? = null): Sequence<Task> =
    tasks.filter { task -> shouldIncludeTask(task, taskValueOverride) }.asSequence()

  fun getTaskSequence(): Sequence<Task> {
    if (!isSequenceInitialized) {
      taskSequence = generateTaskSequence()
      isSequenceInitialized = true
    }
    return taskSequence
  }

  // TODO: Add a method to update the cached sequence whenever necessary.
  // Issue URL: https://github.com/google/ground-android/issues/2993

  /**
   * Checks if the specified task is the first task in the displayed sequence.
   *

Metadata

Metadata

Labels

type: frRequest for new feature

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions