-
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5482 from streetcomplete/viewmodels
ViewModels (a start)
- Loading branch information
Showing
31 changed files
with
699 additions
and
401 deletions.
There are no files selected for viewing
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
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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/de/westnordost/streetcomplete/data/AllEditTypes.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.westnordost.streetcomplete.data | ||
|
||
import de.westnordost.streetcomplete.data.osm.edits.EditType | ||
|
||
class AllEditTypes( | ||
registries: List<ObjectTypeRegistry<out EditType>> | ||
) : AbstractCollection<EditType>() { | ||
|
||
private val byName = registries.flatten().associateByTo(LinkedHashMap()) { it.name } | ||
|
||
override val size: Int get() = byName.size | ||
|
||
override fun iterator(): Iterator<EditType> = byName.values.iterator() | ||
|
||
fun getByName(typeName: String): EditType? = byName[typeName] | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/de/westnordost/streetcomplete/data/AllEditTypesModule.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.westnordost.streetcomplete.data | ||
|
||
import de.westnordost.streetcomplete.data.overlays.OverlayRegistry | ||
import de.westnordost.streetcomplete.data.quest.QuestTypeRegistry | ||
import org.koin.dsl.module | ||
|
||
val allEditTypesModule = module { | ||
single { | ||
AllEditTypes(listOf( | ||
get<QuestTypeRegistry>(), | ||
get<OverlayRegistry>() | ||
)) | ||
} | ||
} |
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
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
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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/de/westnordost/streetcomplete/screens/about/AboutScreenModule.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.westnordost.streetcomplete.screens.about | ||
|
||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
|
||
val aboutScreenModule = module { | ||
viewModel<LogsViewModel> { LogsViewModelImpl(get()) } | ||
} |
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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/de/westnordost/streetcomplete/screens/about/LogsViewModel.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.westnordost.streetcomplete.screens.about | ||
|
||
import androidx.lifecycle.ViewModel | ||
import de.westnordost.streetcomplete.data.logs.LogMessage | ||
import de.westnordost.streetcomplete.data.logs.LogsFilters | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
abstract class LogsViewModel : ViewModel() { | ||
abstract val filters: StateFlow<LogsFilters> | ||
abstract val logs: StateFlow<List<LogMessage>> | ||
|
||
abstract fun setFilters(filters: LogsFilters) | ||
} |
Oops, something went wrong.