Skip to content

Commit cf43fb1

Browse files
committed
Fix crash when viewing line/polygons with no form style
* Return event default style or app default style for lines and polygons when parsing from form.
1 parent 6779971 commit cf43fb1

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ Adheres to [Semantic Versioning](http://semver.org/).
99

1010
##### Bug Fixes
1111

12+
## [7.1.6](https://github.com/ngageoint/mage-android/releases/tag/7.1.6)
13+
14+
##### Features
15+
16+
##### Bug Fixes
17+
* Return event default style or app default style for lines and polygons when parsing from form.
18+
1219
## [7.1.5](https://github.com/ngageoint/mage-android/releases/tag/7.1.5)
1320

1421
##### Features

mage/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
}
1212

1313
group 'mil.nga.giat.mage'
14-
version '7.1.5'
14+
version '7.1.6'
1515
ext {
1616
sourceRefspec = Grgit.open(currentDir: project.rootDir).head().id
1717

mage/src/main/java/mil/nga/giat/mage/form/FormJson.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Form(
3535
@SerializedName("primaryFeedField") val primaryFeedField: String?,
3636
@SerializedName("secondaryFeedField") val secondaryFeedField: String?,
3737
@SerializedName("fields") val fields: List<FormField<Any>>,
38-
@SerializedName("style") val style: JsonObject
38+
@SerializedName("style") val style: JsonObject?
3939
) {
4040
companion object {
4141
private val gson = GsonBuilder()

mage/src/main/java/mil/nga/giat/mage/map/annotation/ShapeStyle.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ShapeStyle: AnnotationStyle {
2727
context.resources.getValue(R.dimen.fill_default_stroke_width, defaultStrokeWidth, true)
2828
strokeWidth = defaultStrokeWidth.float * (context.resources.displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)
2929

30-
this.strokeColor = 0
30+
this.strokeColor = Color.BLACK
3131
this.fillColor = 0
3232
}
3333

@@ -141,7 +141,7 @@ class ShapeStyle: AnnotationStyle {
141141
}
142142

143143
fun fromForm(formState: FormState?, context: Context): ShapeStyle {
144-
val style = ShapeStyle(context)
144+
var style = ShapeStyle(context)
145145

146146
// Check for a style
147147
if (formState != null) {
@@ -167,7 +167,7 @@ class ShapeStyle: AnnotationStyle {
167167
}
168168
if (primaryValue != null) {
169169
// Check for a type within the style
170-
val primaryElement = jsonStyle[primaryValue.text]
170+
val primaryElement = jsonStyle?.get(primaryValue.text)
171171
if (primaryElement != null && !primaryElement.isJsonNull) {
172172

173173
// Found the type level style
@@ -183,9 +183,18 @@ class ShapeStyle: AnnotationStyle {
183183
}
184184
}
185185

186-
return fromJson(jsonStyle, context)
186+
if (jsonStyle != null) {
187+
style = fromJson(jsonStyle, context)
188+
} else {
189+
EventHelper.getInstance(context).read(formState.eventId)?.style?.let { jsonStyle ->
190+
JsonParser.parseString(jsonStyle)?.asJsonObjectOrNull()?.let { jsonObject ->
191+
style = fromJson(jsonObject, context)
192+
}
193+
}
194+
}
187195
}
188196

197+
189198
return style
190199
}
191200

0 commit comments

Comments
 (0)