From 3670c8a9145fbff9588038593d0eab31fdacfc83 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Wed, 6 Apr 2016 11:02:25 -0500 Subject: [android] #4609 - Restoring name of BulkMarkerActivity --- .../src/main/AndroidManifest.xml | 2 +- .../activity/annotation/AddMarkerActivity.java | 180 --------------------- .../activity/annotation/BulkMarkerActivity.java | 180 +++++++++++++++++++++ .../src/main/res/values/strings.xml | 4 +- 4 files changed, 183 insertions(+), 183 deletions(-) delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddMarkerActivity.java create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main') diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index c21594dba4..93f66819c2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -41,7 +41,7 @@ android:value="@string/category_infowindow" /> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddMarkerActivity.java deleted file mode 100644 index 628f969509..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddMarkerActivity.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.annotation; - -import android.app.ProgressDialog; -import android.content.Context; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.util.Log; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Spinner; - -import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil; -import com.mapbox.mapboxsdk.maps.MapView; - -import org.json.JSONException; - -import java.io.IOException; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; - -public class AddMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { - - private MapboxMap mMapboxMap; - private MapView mMapView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_marker_bulk); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayShowTitleEnabled(false); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.setAccessToken(getString(R.string.mapbox_access_token)); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(@NonNull MapboxMap mapboxMap) { - mMapboxMap = mapboxMap; - - if (actionBar != null) { - ArrayAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.bulk_marker_list, android.R.layout.simple_spinner_item); - spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - Spinner spinner = (Spinner) findViewById(R.id.spinner); - spinner.setAdapter(spinnerAdapter); - spinner.setOnItemSelectedListener(AddMarkerActivity.this); - } - } - }); - - } - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - int markersAmount = Integer.valueOf(getResources().getStringArray(R.array.bulk_marker_list)[position]); - new LoadBulkMarkerTask(this, mMapboxMap, markersAmount).execute(); - } - - @Override - public void onNothingSelected(AdapterView parent) { - // nothing selected, nothing to do! - } - - @Override - public void onResume() { - super.onResume(); - mMapView.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - mMapView.onPause(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mMapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mMapView.onLowMemory(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - private static class LoadBulkMarkerTask extends AsyncTask> { - - private static final String TAG = "LoadBulkMarkerTask"; - private MapboxMap mMapboxMap; - private Context mAppContext; - private ProgressDialog mProgressDialog; - private int mAmount; - - public LoadBulkMarkerTask(Context context, MapboxMap mapboxMap, int amount) { - mMapboxMap = mapboxMap; - mapboxMap.removeAnnotations(); - mProgressDialog = ProgressDialog.show(context, "Loading", "Fetching markers", false); - mAppContext = context.getApplicationContext(); - mAmount = amount; - } - - @Override - protected List doInBackground(Void... params) { - List markerOptions = new ArrayList<>(mAmount); - try { - DecimalFormat formatter = new DecimalFormat("#.#####"); - String json = GeoParseUtil.loadStringFromAssets(mAppContext, "points.geojson"); - List locations = GeoParseUtil.parseGeoJSONCoordinates(json); - - if (locations.size() < mAmount) { - mAmount = locations.size(); - } - - LatLng location; - for (int i = 0; i < mAmount; i++) { - location = locations.get(i); - markerOptions.add(new MarkerOptions() - .position(location) - .title("Marker") - .snippet(formatter.format(location.getLatitude()) + ", " + formatter.format(location.getLongitude()))); - } - - } catch (IOException | JSONException e) { - Log.e(TAG, "Could not add markers,", e); - } - return markerOptions; - } - - @Override - protected void onProgressUpdate(Integer... values) { - super.onProgressUpdate(values); - } - - @Override - protected void onPostExecute(List markerOptions) { - super.onPostExecute(markerOptions); - mMapboxMap.addMarkers(markerOptions); - mProgressDialog.hide(); - } - } -} \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java new file mode 100644 index 0000000000..ae3210c251 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java @@ -0,0 +1,180 @@ +package com.mapbox.mapboxsdk.testapp.activity.annotation; + +import android.app.ProgressDialog; +import android.content.Context; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Spinner; + +import com.mapbox.mapboxsdk.annotations.MarkerOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil; +import com.mapbox.mapboxsdk.maps.MapView; + +import org.json.JSONException; + +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { + + private MapboxMap mMapboxMap; + private MapView mMapView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_marker_bulk); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + final ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayShowTitleEnabled(false); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + } + + mMapView = (MapView) findViewById(R.id.mapView); + mMapView.setAccessToken(getString(R.string.mapbox_access_token)); + mMapView.onCreate(savedInstanceState); + mMapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(@NonNull MapboxMap mapboxMap) { + mMapboxMap = mapboxMap; + + if (actionBar != null) { + ArrayAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.bulk_marker_list, android.R.layout.simple_spinner_item); + spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + Spinner spinner = (Spinner) findViewById(R.id.spinner); + spinner.setAdapter(spinnerAdapter); + spinner.setOnItemSelectedListener(BulkMarkerActivity.this); + } + } + }); + + } + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + int markersAmount = Integer.valueOf(getResources().getStringArray(R.array.bulk_marker_list)[position]); + new LoadBulkMarkerTask(this, mMapboxMap, markersAmount).execute(); + } + + @Override + public void onNothingSelected(AdapterView parent) { + // nothing selected, nothing to do! + } + + @Override + public void onResume() { + super.onResume(); + mMapView.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + mMapView.onPause(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mMapView.onSaveInstanceState(outState); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mMapView.onLowMemory(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + private static class LoadBulkMarkerTask extends AsyncTask> { + + private static final String TAG = "LoadBulkMarkerTask"; + private MapboxMap mMapboxMap; + private Context mAppContext; + private ProgressDialog mProgressDialog; + private int mAmount; + + public LoadBulkMarkerTask(Context context, MapboxMap mapboxMap, int amount) { + mMapboxMap = mapboxMap; + mapboxMap.removeAnnotations(); + mProgressDialog = ProgressDialog.show(context, "Loading", "Fetching markers", false); + mAppContext = context.getApplicationContext(); + mAmount = amount; + } + + @Override + protected List doInBackground(Void... params) { + List markerOptions = new ArrayList<>(mAmount); + try { + DecimalFormat formatter = new DecimalFormat("#.#####"); + String json = GeoParseUtil.loadStringFromAssets(mAppContext, "points.geojson"); + List locations = GeoParseUtil.parseGeoJSONCoordinates(json); + + if (locations.size() < mAmount) { + mAmount = locations.size(); + } + + LatLng location; + for (int i = 0; i < mAmount; i++) { + location = locations.get(i); + markerOptions.add(new MarkerOptions() + .position(location) + .title("Marker") + .snippet(formatter.format(location.getLatitude()) + ", " + formatter.format(location.getLongitude()))); + } + + } catch (IOException | JSONException e) { + Log.e(TAG, "Could not add markers,", e); + } + return markerOptions; + } + + @Override + protected void onProgressUpdate(Integer... values) { + super.onProgressUpdate(values); + } + + @Override + protected void onPostExecute(List markerOptions) { + super.onPostExecute(markerOptions); + mMapboxMap.addMarkers(markerOptions); + mProgressDialog.hide(); + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index fcaa7e7090..c7aabc96d7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -11,7 +11,7 @@ Map Fragment - Add Markers + Add Markers In Bulk Animated Marker (experimental) Dynamic Marker Polyline @@ -52,7 +52,7 @@ Configure a max and min zoomlevel Learn how to handle the InfoWindow InfoWindow example with multiple open - Add Markers to a Map + Add Markers In Bulk to a Map Showcase the different animation types Center the camera around a bounds Update position and icon -- cgit v1.2.1