-
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
14 changed files
with
175 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,15 @@ import fr.geonature.maps.settings.MapSettings | |
* | ||
* @author [S. Grimault](mailto:[email protected]) | ||
*/ | ||
data class AppSettings(var mapSettings: MapSettings? = null) : IAppSettings { | ||
data class AppSettings( | ||
var areaObservationDuration: Int = DEFAULT_AREA_OBSERVATION_DURATION, | ||
var mapSettings: MapSettings? = null | ||
) : IAppSettings { | ||
|
||
private constructor(source: Parcel) : this(source.readParcelable(MapSettings::class.java.classLoader) as MapSettings?) | ||
private constructor(source: Parcel) : this( | ||
source.readInt(), | ||
source.readParcelable(MapSettings::class.java.classLoader) as MapSettings? | ||
) | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
|
@@ -22,34 +28,44 @@ data class AppSettings(var mapSettings: MapSettings? = null) : IAppSettings { | |
dest: Parcel?, | ||
flags: Int | ||
) { | ||
dest?.writeParcelable( | ||
dest?.also { | ||
it.writeInt(areaObservationDuration) | ||
it.writeParcelable( | ||
mapSettings, | ||
0 | ||
) | ||
) | ||
} | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as AppSettings | ||
if (other !is AppSettings) return false | ||
|
||
if (areaObservationDuration != other.areaObservationDuration) return false | ||
if (mapSettings != other.mapSettings) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return mapSettings.hashCode() | ||
var result = areaObservationDuration | ||
result = 31 * result + (mapSettings?.hashCode() ?: 0) | ||
|
||
return result | ||
} | ||
|
||
companion object CREATOR : Parcelable.Creator<AppSettings> { | ||
override fun createFromParcel(parcel: Parcel): AppSettings { | ||
return AppSettings(parcel) | ||
} | ||
companion object { | ||
const val DEFAULT_AREA_OBSERVATION_DURATION = 365 | ||
|
||
@JvmField | ||
val CREATOR: Parcelable.Creator<AppSettings> = object : Parcelable.Creator<AppSettings> { | ||
override fun createFromParcel(parcel: Parcel): AppSettings { | ||
return AppSettings(parcel) | ||
} | ||
|
||
override fun newArray(size: Int): Array<AppSettings?> { | ||
return arrayOfNulls(size) | ||
override fun newArray(size: Int): Array<AppSettings?> { | ||
return arrayOfNulls(size) | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -11,7 +11,8 @@ import fr.geonature.occtax.settings.AppSettings | |
* | ||
* @author [S. Grimault](mailto:[email protected]) | ||
*/ | ||
class OnAppSettingsJsonReaderListenerImpl : AppSettingsJsonReader.OnAppSettingsJsonReaderListener<AppSettings> { | ||
class OnAppSettingsJsonReaderListenerImpl : | ||
AppSettingsJsonReader.OnAppSettingsJsonReaderListener<AppSettings> { | ||
|
||
override fun createAppSettings(): AppSettings { | ||
return AppSettings() | ||
|
@@ -23,10 +24,13 @@ class OnAppSettingsJsonReaderListenerImpl : AppSettingsJsonReader.OnAppSettingsJ | |
appSettings: AppSettings | ||
) { | ||
when (keyName) { | ||
"area_observation_duration" -> appSettings.areaObservationDuration = reader.nextInt() | ||
"map" -> { | ||
if (reader.peek() == JsonToken.BEGIN_OBJECT) { | ||
readMapSettings(reader, | ||
appSettings) | ||
readMapSettings( | ||
reader, | ||
appSettings | ||
) | ||
} else { | ||
reader.skipValue() | ||
} | ||
|
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
Oops, something went wrong.