Skip to content

Commit 335256c

Browse files
places bubble wrap style (#477)
1 parent cabdc2e commit 335256c

File tree

6 files changed

+56
-1
lines changed

6 files changed

+56
-1
lines changed

mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlacePickerActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class PlacePickerActivity extends Activity implements
5858
}
5959

6060
mapView = (MapView) findViewById(R.id.mz_map_view);
61-
mapView.getMapAsync(this);
61+
presenter.getMapAsync(mapView, this);
6262

6363
final PlaceDialogFragment fragment =
6464
(PlaceDialogFragment) getFragmentManager().findFragmentByTag(PlaceDialogFragment.TAG);

mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlacePickerPresenter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.mapzen.places.api.internal;
22

3+
import com.mapzen.android.graphics.MapView;
4+
import com.mapzen.android.graphics.OnMapReadyCallback;
35
import com.mapzen.places.api.Place;
46

57
import java.util.Map;
@@ -8,6 +10,13 @@
810
* Interface for managing state associated with the {@link PlacePickerViewController}.
911
*/
1012
interface PlacePickerPresenter {
13+
14+
/**
15+
* Get a reference to {@link com.mapzen.android.graphics.MapzenMap}.
16+
* @param mapView
17+
*/
18+
void getMapAsync(MapView mapView, OnMapReadyCallback callback);
19+
1120
/**
1221
* Sets the presenter's controller. Must be called before any other methods in the interface
1322
* can be called.

mapzen-places-api/src/main/java/com/mapzen/places/api/internal/PlacePickerPresenterImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.mapzen.places.api.internal;
22

3+
import com.mapzen.android.graphics.MapView;
4+
import com.mapzen.android.graphics.OnMapReadyCallback;
35
import com.mapzen.places.api.Place;
46

57
import android.util.Log;
@@ -25,6 +27,10 @@ class PlacePickerPresenterImpl implements PlacePickerPresenter {
2527
detailFetcher = fetcher;
2628
}
2729

30+
@Override public void getMapAsync(MapView mapView, OnMapReadyCallback callback) {
31+
mapView.getMapAsync(new PlacesBubbleWrapStyle(), callback);
32+
}
33+
2834
@Override public void setController(PlacePickerViewController controller) {
2935
this.controller = controller;
3036
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.mapzen.places.api.internal;
2+
3+
import com.mapzen.android.graphics.model.BubbleWrapStyle;
4+
5+
/**
6+
* Style used for place picker UI. Sets highest label level as default label level.
7+
*/
8+
class PlacesBubbleWrapStyle extends BubbleWrapStyle {
9+
10+
@Override public int getDefaultLabelLevel() {
11+
return 11;
12+
}
13+
}

mapzen-places-api/src/test/java/com/mapzen/places/api/internal/PlacePickerPresenterTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.mapzen.places.api.internal;
22

3+
import com.mapzen.android.graphics.MapView;
4+
import com.mapzen.android.graphics.OnMapReadyCallback;
35
import com.mapzen.places.api.Place;
46

57
import org.junit.Before;
@@ -8,6 +10,10 @@
810
import java.util.HashMap;
911

1012
import static org.assertj.core.api.Assertions.assertThat;
13+
import static org.mockito.Matchers.any;
14+
import static org.mockito.Matchers.eq;
15+
import static org.mockito.Mockito.mock;
16+
import static org.mockito.Mockito.verify;
1117

1218
public class PlacePickerPresenterTest {
1319

@@ -20,6 +26,13 @@ public class PlacePickerPresenterTest {
2026
presenter.setController(controller);
2127
}
2228

29+
@Test public void getMapAsync_shouldLoadPlacesBubbleWrapStyle() throws Exception {
30+
MapView mapView = mock(MapView.class);
31+
OnMapReadyCallback callback = mock(OnMapReadyCallback.class);
32+
presenter.getMapAsync(mapView, callback);
33+
verify(mapView).getMapAsync(any(PlacesBubbleWrapStyle.class), eq(callback));
34+
}
35+
2336
@Test public void onLabelPicked_shouldShowDialog() {
2437
HashMap<String, String> properties = new HashMap<>();
2538
properties.put("name", "Hanjan");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.mapzen.places.api.internal;
2+
3+
import org.junit.Test;
4+
5+
import static org.assertj.core.api.Assertions.assertThat;
6+
7+
public class PlacesBubbleWrapStyleTest {
8+
9+
PlacesBubbleWrapStyle bubbleWrap = new PlacesBubbleWrapStyle();
10+
11+
@Test public void shouldReturnCorrectLabelLevel() throws Exception {
12+
assertThat(bubbleWrap.getDefaultLabelLevel()).isEqualTo(11);
13+
}
14+
}

0 commit comments

Comments
 (0)