diff --git a/app/src/main/java/fishrungames/yelpmapapp/CoordinatesRecord.kt b/app/src/main/java/fishrungames/yelpmapapp/CoordinatesRecord.kt new file mode 100755 index 0000000..1f9c0c5 --- /dev/null +++ b/app/src/main/java/fishrungames/yelpmapapp/CoordinatesRecord.kt @@ -0,0 +1,8 @@ +package fishrungames.yelpmapapp + +/** + * Created by mephi on 10.06.2017. + */ + +data class CoordinatesRecord(val latitude: Double, + val longitude: Double) diff --git a/app/src/main/java/fishrungames/yelpmapapp/HandleResponseAsyncTask.kt b/app/src/main/java/fishrungames/yelpmapapp/HandleResponseAsyncTask.kt index e69e0f3..5fc16e9 100755 --- a/app/src/main/java/fishrungames/yelpmapapp/HandleResponseAsyncTask.kt +++ b/app/src/main/java/fishrungames/yelpmapapp/HandleResponseAsyncTask.kt @@ -2,6 +2,8 @@ package fishrungames.yelpmapapp import android.os.AsyncTask import com.google.gson.JsonObject +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken /** @@ -12,6 +14,7 @@ import com.google.gson.JsonObject class HandleResponseAsyncTask(val onUpdateMapMarkers : ((Map) -> Unit)) : AsyncTask>() { + override fun doInBackground(vararg response : JsonObject): Map { val newMapMarkers = mutableMapOf() @@ -19,17 +22,12 @@ class HandleResponseAsyncTask(val onUpdateMapMarkers : ((Map() {}.type - var mapMarker = MapMarkerRecord(id, name, image_url, latitude, longitude) + val mapMarkerRecord = Gson().fromJson(businessElement, mapMarkerRecordType) - newMapMarkers[name] = mapMarker + newMapMarkers[mapMarkerRecord.name] = mapMarkerRecord } diff --git a/app/src/main/java/fishrungames/yelpmapapp/MapMarkerClusterItem.kt b/app/src/main/java/fishrungames/yelpmapapp/MapMarkerClusterItem.kt index 79c59ca..48e0aab 100755 --- a/app/src/main/java/fishrungames/yelpmapapp/MapMarkerClusterItem.kt +++ b/app/src/main/java/fishrungames/yelpmapapp/MapMarkerClusterItem.kt @@ -11,7 +11,7 @@ import com.google.android.gms.maps.model.LatLng class MapMarkerClusterItem(inMapMarkerRecord : MapMarkerRecord) : ClusterItem { - private val mPosition = LatLng(inMapMarkerRecord.lat, inMapMarkerRecord.lon) + private val mPosition = LatLng(inMapMarkerRecord.coordinates.latitude, inMapMarkerRecord.coordinates.longitude) val mapMarkerRecord = inMapMarkerRecord diff --git a/app/src/main/java/fishrungames/yelpmapapp/MapMarkerRecord.kt b/app/src/main/java/fishrungames/yelpmapapp/MapMarkerRecord.kt index 8dd1599..a9bfb7a 100755 --- a/app/src/main/java/fishrungames/yelpmapapp/MapMarkerRecord.kt +++ b/app/src/main/java/fishrungames/yelpmapapp/MapMarkerRecord.kt @@ -5,10 +5,10 @@ package fishrungames.yelpmapapp */ + data class MapMarkerRecord ( val id: String, val name: String, - val imageUrl: String, - val lat: Double, - val lon: Double + val image_url: String, + val coordinates: CoordinatesRecord )