-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move default method to an abstract class so that we can downgrade
- Loading branch information
ÃÂâÃÂÃÂÃÂÃÂosanaÃÂâÃÂÃÂÃÂÃÂ
committed
Aug 27, 2018
1 parent
56470d3
commit eb5e999
Showing
4 changed files
with
34 additions
and
26 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
31 changes: 31 additions & 0 deletions
31
services-geojson/src/main/java/com/mapbox/geojson/GeometryGeoJson.java
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,31 @@ | ||
package com.mapbox.geojson; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
import com.google.gson.GsonBuilder; | ||
import com.mapbox.geojson.gson.GeoJsonAdapterFactory; | ||
import com.mapbox.geojson.gson.GeometryDeserializer; | ||
import com.mapbox.geojson.gson.PointDeserializer; | ||
|
||
/** | ||
* This is a utility class that helps create a Geometry instance from a JSON string. | ||
* @since 3.5.0 | ||
*/ | ||
public class GeometryGeoJson { | ||
|
||
/** | ||
* Create a new instance of Geometry class by passing in a formatted valid JSON String. | ||
* | ||
* @param json a formatted valid JSON string defining a GeoJson Geometry | ||
* @return a new instance of Geometry class defined by the values passed inside | ||
* this static factory method | ||
* @since 3.5.0 | ||
*/ | ||
static Geometry fromJson(@NonNull String json) { | ||
GsonBuilder gson = new GsonBuilder(); | ||
gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); | ||
gson.registerTypeAdapter(Point.class, new PointDeserializer()); | ||
gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer()); | ||
return gson.create().fromJson(json, Geometry.class); | ||
} | ||
} |
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