-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kyle Corry <kylecorry31@gmail.com>
- Loading branch information
1 parent
eac61f4
commit 8449964
Showing
13 changed files
with
319 additions
and
97 deletions.
There are no files selected for viewing
27 changes: 25 additions & 2 deletions
27
app/src/main/java/com/kylecorry/trail_sense/tools/field_guide/domain/FieldGuidePage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
package com.kylecorry.trail_sense.tools.field_guide.domain | ||
|
||
import com.kylecorry.trail_sense.shared.data.Identifiable | ||
import com.kylecorry.trail_sense.shared.withId | ||
|
||
data class FieldGuidePage( | ||
override val id: Long, | ||
val name: String, | ||
val images: List<String> = emptyList(), | ||
val tags: List<FieldGuidePageTag> = emptyList(), | ||
val directTags: List<FieldGuidePageTag> = emptyList(), | ||
val notes: String? = null, | ||
|
||
// User specific fields (not exported) | ||
val sightings: List<Sighting> = emptyList(), | ||
) : Identifiable | ||
) : Identifiable { | ||
val tags: List<FieldGuidePageTag> by lazy { | ||
val tagQueue = directTags.toMutableList() | ||
val tags = mutableListOf<FieldGuidePageTag>() | ||
while (tagQueue.isNotEmpty()) { | ||
val tag = tagQueue.removeAt(0) | ||
if (tags.any { it.id == tag.id }) { | ||
continue | ||
} | ||
tags.add(tag) | ||
val parent = tag.parentId?.let { FieldGuidePageTag.entries.withId(it) } | ||
if (parent != null) { | ||
tagQueue.add(parent) | ||
} | ||
} | ||
|
||
if (tags.none { it.type == FieldGuidePageTagType.Classification }) { | ||
tags.add(FieldGuidePageTag.Other) | ||
} | ||
|
||
tags | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.