-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: datastore and network module
- Loading branch information
Showing
42 changed files
with
303 additions
and
244 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
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
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
27 changes: 0 additions & 27 deletions
27
core/data/src/main/kotlin/com/zjutjh/ijh/data/impl/CampusInfoRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
core/data/src/main/kotlin/com/zjutjh/ijh/data/impl/CampusRepositoryImpl.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,28 @@ | ||
package com.zjutjh.ijh.data.impl | ||
|
||
import com.zjutjh.ijh.data.CampusRepository | ||
import com.zjutjh.ijh.datastore.IJhPreferenceDataSource | ||
import com.zjutjh.ijh.datastore.converter.asExternalModel | ||
import com.zjutjh.ijh.datastore.model.campusOrNull | ||
import com.zjutjh.ijh.model.CampusInfo | ||
import com.zjutjh.ijh.model.Term | ||
import com.zjutjh.ijh.network.CampusNetworkDataSource | ||
import com.zjutjh.ijh.network.model.asExternalModel | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class CampusRepositoryImpl @Inject constructor( | ||
private val network: CampusNetworkDataSource, | ||
private val local: IJhPreferenceDataSource | ||
) : CampusRepository { | ||
|
||
override val infoStream: Flow<CampusInfo?> = | ||
local.data.map { it.campusOrNull?.asExternalModel() } | ||
|
||
override suspend fun sync(): Pair<Int, Term> { | ||
val weJhInfo = network.getInfo().asExternalModel() | ||
local.setCampus(weJhInfo) | ||
return Pair(weJhInfo.year, weJhInfo.term) | ||
} | ||
} |
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.