[android] #2726 - moved utility classes to separate package
This commit is contained in:
@@ -31,6 +31,7 @@ import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Sprite;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
|
||||
import com.mapbox.mapboxsdk.utils.ApiAccess;
|
||||
import com.mapbox.mapboxsdk.views.MapView;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
@@ -466,8 +467,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private void addPolyline() {
|
||||
try {
|
||||
String geojsonStr = Util.loadStringFromAssets(this, "small_line.geojson");
|
||||
List<LatLng> latLngs = Util.parseGeoJSONCoordinates(geojsonStr);
|
||||
String geojsonStr = GeoParseUtil.loadStringFromAssets(this, "small_line.geojson");
|
||||
List<LatLng> latLngs = GeoParseUtil.parseGeoJSONCoordinates(geojsonStr);
|
||||
MapView map = mMapView;
|
||||
map.addPolyline(new PolylineOptions()
|
||||
.add(latLngs.toArray(new LatLng[latLngs.size()]))
|
||||
@@ -481,8 +482,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private void addPolygon() {
|
||||
try {
|
||||
String geojsonStr = Util.loadStringFromAssets(this, "small_poly.geojson");
|
||||
List<LatLng> latLngs = Util.parseGeoJSONCoordinates(geojsonStr);
|
||||
String geojsonStr = GeoParseUtil.loadStringFromAssets(this, "small_poly.geojson");
|
||||
List<LatLng> latLngs = GeoParseUtil.parseGeoJSONCoordinates(geojsonStr);
|
||||
MapView map = mMapView;
|
||||
ArrayList<PolygonOptions> opts = new ArrayList<>();
|
||||
opts.add(new PolygonOptions()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
package com.mapbox.mapboxsdk.testapp.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
@@ -18,7 +18,7 @@ import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Util {
|
||||
public class GeoParseUtil {
|
||||
|
||||
public static String loadStringFromAssets(final Context context, final String fileName) throws IOException {
|
||||
if (TextUtils.isEmpty(fileName)) {
|
||||
@@ -55,6 +55,7 @@ public class Util {
|
||||
double lng = coordinates.getDouble(0);
|
||||
double lat = coordinates.getDouble(1);
|
||||
latLngs.add(new LatLng(lat, lng));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
package com.mapbox.mapboxsdk.testapp.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
Reference in New Issue
Block a user