-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,004 additions
and
242 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Submodule gn_mobile_core
updated
33 files
Submodule gn_mobile_maps
added at
306547
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gn_mobile_maps/maps |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import android.util.JsonToken | |
import fr.geonature.commons.input.AbstractInput | ||
import fr.geonature.commons.input.io.InputJsonReader | ||
import fr.geonature.commons.util.IsoDateUtils | ||
import fr.geonature.maps.jts.geojson.io.GeoJsonReader | ||
import fr.geonature.occtax.input.Input | ||
import fr.geonature.occtax.input.InputTaxon | ||
import java.util.Date | ||
|
@@ -14,15 +15,17 @@ import java.util.Date | |
* | ||
* @author [S. Grimault](mailto:[email protected]) | ||
*/ | ||
class OnInputJsonReaderListenerImpl : InputJsonReader.OnInputJsonReaderListener { | ||
class OnInputJsonReaderListenerImpl : InputJsonReader.OnInputJsonReaderListener<Input> { | ||
|
||
override fun createInput(): AbstractInput { | ||
private val geoJsonReader = GeoJsonReader() | ||
|
||
override fun createInput(): Input { | ||
return Input() | ||
} | ||
|
||
override fun readAdditionalInputData(reader: JsonReader, | ||
keyName: String, | ||
input: AbstractInput) { | ||
input: Input) { | ||
when (keyName) { | ||
"geometry" -> readGeometry(reader, | ||
input) | ||
|
@@ -33,12 +36,14 @@ class OnInputJsonReaderListenerImpl : InputJsonReader.OnInputJsonReaderListener | |
} | ||
|
||
private fun readGeometry(reader: JsonReader, | ||
input: AbstractInput) { | ||
reader.beginObject() | ||
|
||
// TODO: read geometry object | ||
|
||
reader.endObject() | ||
input: Input) { | ||
when (reader.peek()) { | ||
JsonToken.NULL -> reader.nextNull() | ||
JsonToken.BEGIN_OBJECT -> { | ||
input.geometry = geoJsonReader.readGeometry(reader) | ||
} | ||
else -> reader.skipValue() | ||
} | ||
} | ||
|
||
private fun readProperties(reader: JsonReader, | ||
|
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,38 +1,46 @@ | ||
package fr.geonature.occtax.input.io | ||
|
||
import android.util.JsonWriter | ||
import fr.geonature.commons.input.AbstractInput | ||
import fr.geonature.commons.input.AbstractInputTaxon | ||
import fr.geonature.commons.input.io.InputJsonWriter | ||
import fr.geonature.commons.util.IsoDateUtils | ||
import fr.geonature.maps.jts.geojson.io.GeoJsonWriter | ||
import fr.geonature.occtax.input.Input | ||
|
||
/** | ||
* Default implementation of [InputJsonWriter.OnInputJsonWriterListener]. | ||
* | ||
* @author [S. Grimault](mailto:[email protected]) | ||
*/ | ||
class OnInputJsonWriterListenerImpl : InputJsonWriter.OnInputJsonWriterListener { | ||
class OnInputJsonWriterListenerImpl : InputJsonWriter.OnInputJsonWriterListener<Input> { | ||
|
||
private val geoJsonWriter = GeoJsonWriter() | ||
|
||
override fun writeAdditionalInputData(writer: JsonWriter, | ||
input: AbstractInput) { | ||
input: Input) { | ||
writeGeometry(writer, | ||
input) | ||
writeProperties(writer, | ||
input) | ||
} | ||
|
||
private fun writeGeometry(writer: JsonWriter, | ||
input: AbstractInput) { | ||
input: Input) { | ||
writer.name("geometry") | ||
.beginObject() | ||
|
||
// TODO: write geometry object | ||
val geometry = input.geometry | ||
|
||
writer.endObject() | ||
if (geometry == null) { | ||
writer.nullValue() | ||
} | ||
else { | ||
geoJsonWriter.writeGeometry(writer, | ||
geometry) | ||
} | ||
} | ||
|
||
private fun writeProperties(writer: JsonWriter, | ||
input: AbstractInput) { | ||
input: Input) { | ||
writer.name("properties") | ||
.beginObject() | ||
|
||
|
@@ -54,7 +62,7 @@ class OnInputJsonWriterListenerImpl : InputJsonWriter.OnInputJsonWriterListener | |
} | ||
|
||
private fun writeDate(writer: JsonWriter, | ||
input: AbstractInput) { | ||
input: Input) { | ||
val dateToIsoString = IsoDateUtils.toIsoDateString(input.date) | ||
writer.name("date_min") | ||
.value(dateToIsoString) | ||
|
@@ -63,7 +71,7 @@ class OnInputJsonWriterListenerImpl : InputJsonWriter.OnInputJsonWriterListener | |
} | ||
|
||
private fun writeInputObserverIds(writer: JsonWriter, | ||
input: AbstractInput) { | ||
input: Input) { | ||
writer.name("observers") | ||
.beginArray() | ||
|
||
|
@@ -74,7 +82,7 @@ class OnInputJsonWriterListenerImpl : InputJsonWriter.OnInputJsonWriterListener | |
} | ||
|
||
private fun writeInputTaxa(writer: JsonWriter, | ||
input: AbstractInput) { | ||
input: Input) { | ||
writer.name("t_occurrences_occtax") | ||
.beginArray() | ||
|
||
|
53 changes: 53 additions & 0 deletions
53
occtax/src/main/java/fr/geonature/occtax/settings/AppSettings.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,53 @@ | ||
package fr.geonature.occtax.settings | ||
|
||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import fr.geonature.commons.settings.IAppSettings | ||
import fr.geonature.maps.settings.MapSettings | ||
|
||
/** | ||
* Global internal settings. | ||
* | ||
* @author [S. Grimault](mailto:[email protected]) | ||
*/ | ||
data class AppSettings(var mapSettings: MapSettings? = null) : IAppSettings { | ||
|
||
private constructor(source: Parcel) : this(source.readParcelable(MapSettings::class.java.classLoader) as MapSettings) | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
override fun writeToParcel(dest: Parcel?, | ||
flags: Int) { | ||
dest?.writeParcelable( | ||
mapSettings, | ||
0 | ||
) | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as AppSettings | ||
|
||
if (mapSettings != other.mapSettings) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return mapSettings.hashCode() | ||
} | ||
|
||
companion object CREATOR : Parcelable.Creator<AppSettings> { | ||
override fun createFromParcel(parcel: Parcel): AppSettings { | ||
return AppSettings(parcel) | ||
} | ||
|
||
override fun newArray(size: Int): Array<AppSettings?> { | ||
return arrayOfNulls(size) | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
occtax/src/main/java/fr/geonature/occtax/settings/io/OnAppSettingsJsonReaderListenerImpl.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,40 @@ | ||
package fr.geonature.occtax.settings.io | ||
|
||
import android.util.JsonReader | ||
import android.util.JsonToken | ||
import fr.geonature.commons.settings.io.AppSettingsJsonReader | ||
import fr.geonature.maps.settings.io.MapSettingsReader | ||
import fr.geonature.occtax.settings.AppSettings | ||
|
||
/** | ||
* Default implementation of [AppSettingsJsonReader.OnAppSettingsJsonReaderListener]. | ||
* | ||
* @author [S. Grimault](mailto:[email protected]) | ||
*/ | ||
class OnAppSettingsJsonReaderListenerImpl : AppSettingsJsonReader.OnAppSettingsJsonReaderListener<AppSettings> { | ||
|
||
override fun createAppSettings(): AppSettings { | ||
return AppSettings() | ||
} | ||
|
||
override fun readAdditionalAppSettingsData(reader: JsonReader, | ||
keyName: String, | ||
appSettings: AppSettings) { | ||
when (keyName) { | ||
"map" -> { | ||
if (reader.peek() == JsonToken.BEGIN_OBJECT) { | ||
readMapSettings(reader, | ||
appSettings) | ||
} | ||
else { | ||
reader.skipValue() | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun readMapSettings(reader: JsonReader, | ||
appSettings: AppSettings) { | ||
appSettings.mapSettings = MapSettingsReader().read(reader) | ||
} | ||
} |
Oops, something went wrong.