-
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.
fix(PnX-SI/gn_mobile_occtax#133): synchronize taxa list IDs...
- Loading branch information
Showing
13 changed files
with
587 additions
and
318 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
26 changes: 26 additions & 0 deletions
26
datasync/src/main/java/fr/geonature/datasync/api/model/TaxrefList.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,26 @@ | ||
package fr.geonature.datasync.api.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* _GeoNature_ taxa list result. | ||
* | ||
* @author S. Grimault | ||
*/ | ||
data class TaxrefListListResult( | ||
val data: List<TaxrefList>, | ||
val count: Int | ||
) | ||
|
||
|
||
/** | ||
* _GeoNature_ taxa list definition. | ||
* | ||
* @author S. Grimault | ||
*/ | ||
data class TaxrefList( | ||
@SerializedName("id_liste") val id: Long, | ||
@SerializedName("code_liste") val code: String, | ||
@SerializedName("nom_liste") val name: String, | ||
@SerializedName("desc_liste") val description: String | ||
) |
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
26 changes: 24 additions & 2 deletions
26
...nc/src/main/java/fr/geonature/datasync/sync/repository/ISynchronizeLocalDataRepository.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,36 @@ | ||
package fr.geonature.datasync.sync.repository | ||
|
||
import androidx.work.WorkInfo | ||
import fr.geonature.datasync.sync.DataSyncStatus | ||
import kotlinx.coroutines.channels.SendChannel | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
/** | ||
* Synchronize local data. | ||
* | ||
* @author S. Grimault | ||
*/ | ||
interface ISynchronizeLocalDataRepository { | ||
interface ISynchronizeLocalDataRepository<in Params> { | ||
|
||
suspend operator fun invoke(): Flow<DataSyncStatus> | ||
suspend operator fun invoke(params: Params): Flow<DataSyncStatus> | ||
|
||
companion object { | ||
|
||
/** | ||
* Sends synchronization status to the given channel and throw exception if its current status | ||
* is [WorkInfo.State.FAILED] to cancel the current transaction. | ||
*/ | ||
suspend fun sendOrThrow( | ||
channel: SendChannel<DataSyncStatus>, | ||
dataSyncStatus: DataSyncStatus | ||
) { | ||
channel.send(dataSyncStatus) | ||
|
||
if (dataSyncStatus.state == WorkInfo.State.FAILED) { | ||
delay(500) | ||
throw java.lang.Exception(dataSyncStatus.syncMessage) | ||
} | ||
} | ||
} | ||
} |
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.