[android] minor reference app fixes

This commit is contained in:
Łukasz Paczos
2018-08-24 19:53:56 +02:00
committed by Łukasz Paczos
parent 3ca20500bd
commit 794ba54a27
9 changed files with 79 additions and 33 deletions

View File

@@ -266,6 +266,9 @@
<meta-data
android:name="@string/category"
android:value="@string/category_basic" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
</activity>
<activity
android:name=".activity.offline.OfflineActivity"
@@ -706,6 +709,9 @@
<meta-data
android:name="@string/category"
android:value="@string/category_maplayout" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
</activity>
<!-- TextureView -->
@@ -716,6 +722,9 @@
<meta-data
android:name="@string/category"
android:value="@string/category_textureview" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
</activity>
<activity
android:name=".activity.textureview.TextureViewResizeActivity"
@@ -724,6 +733,9 @@
<meta-data
android:name="@string/category"
android:value="@string/category_textureview" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
</activity>
<activity
android:name=".activity.textureview.TextureViewTransparentBackgroundActivity"
@@ -743,6 +755,9 @@
<meta-data
android:name="@string/category"
android:value="@string/category_textureview" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
</activity>
<activity
android:name=".activity.maplayout.LocalGlyphActivity"

View File

@@ -68,7 +68,7 @@ public class PolylineActivity extends AppCompatActivity {
mapboxMap.setOnPolylineClickListener(polyline -> Toast.makeText(
PolylineActivity.this,
"You clicked on polygon with id = " + polyline.getId(),
"You clicked on polyline with id = " + polyline.getId(),
Toast.LENGTH_SHORT
).show());

View File

@@ -43,13 +43,15 @@ public class PressForMarkerActivity extends AppCompatActivity {
mapboxMap = map;
resetMap();
mapboxMap.setOnMapLongClickListener(point -> addMarker(point));
mapboxMap.addOnMapLongClickListener(point -> addMarker(point));
mapboxMap.setOnMapClickListener(point -> addMarker(point));
mapboxMap.addOnMapClickListener(point -> addMarker(point));
if (savedInstanceState != null) {
markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
mapboxMap.addMarkers(markerList);
if (markerList != null) {
mapboxMap.addMarkers(markerList);
}
}
});
}

View File

@@ -61,12 +61,18 @@ public class LatLngBoundsActivity extends AppCompatActivity implements View.OnCl
}
private void initMap() {
disableGestures();
addMarkers();
initFab();
initBottomSheet();
moveToBounds(bottomSheet.getMeasuredHeight(), BOUNDS_PADDING_DIVIDER_SMALL, ANIMATION_DURATION_SHORT);
}
private void disableGestures() {
mapboxMap.getUiSettings().setTiltGesturesEnabled(false);
mapboxMap.getUiSettings().setRotateGesturesEnabled(false);
}
private void addMarkers() {
for (LatLng location : LOCATIONS) {
mapboxMap.addMarker(new MarkerOptions().position(location));

View File

@@ -1,6 +1,8 @@
package com.mapbox.mapboxsdk.testapp.activity.feature;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
@@ -9,7 +11,7 @@ import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.testapp.R;
@@ -27,7 +29,6 @@ import static com.mapbox.mapboxsdk.style.expressions.Expression.neq;
public class QuerySourceFeaturesActivity extends AppCompatActivity {
public MapView mapView;
private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -38,31 +39,45 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
QuerySourceFeaturesActivity.this.mapboxMap = mapboxMap;
JsonObject properties = new JsonObject();
properties.addProperty("key1", "value1");
final GeoJsonSource source = new GeoJsonSource("test-source",
FeatureCollection.fromFeatures(new Feature[] {
Feature.fromGeometry(Point.fromLngLat(0, 0), properties)
Feature.fromGeometry(Point.fromLngLat(17.1, 51), properties),
Feature.fromGeometry(Point.fromLngLat(17.2, 51), properties),
Feature.fromGeometry(Point.fromLngLat(17.3, 51), properties),
Feature.fromGeometry(Point.fromLngLat(17.4, 51), properties),
}));
mapboxMap.addSource(source);
mapboxMap.addLayer(new CircleLayer("test-layer", source.getId()).withFilter(neq(get("key1"), literal("value1"))));
Expression visible = eq(get("key1"), literal("value1"));
Expression invisible = neq(get("key1"), literal("value1"));
CircleLayer layer = new CircleLayer("test-layer", source.getId())
.withFilter(visible);
mapboxMap.addLayer(layer);
// Add a click listener
mapboxMap.setOnMapClickListener(point -> {
mapboxMap.addOnMapClickListener(point -> {
// Query
List<Feature> features = source.querySourceFeatures(eq(get("key1"), literal("value1")));
Toast.makeText(QuerySourceFeaturesActivity.this, String.format("Found %s features",
features.size()), Toast.LENGTH_SHORT).show();
});
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
fab.setOnClickListener(view -> {
Expression visibility = layer.getFilter();
if (visibility != null && visibility.equals(visible)) {
layer.setFilter(invisible);
fab.setImageResource(R.drawable.ic_layers_clear);
} else {
layer.setFilter(visible);
fab.setImageResource(R.drawable.ic_layers);
}
});
});
}
public MapboxMap getMapboxMap() {
return mapboxMap;
}
@Override

View File

@@ -97,7 +97,7 @@ public class DoubleMapActivity extends AppCompatActivity {
uiSettings.setAttributionEnabled(false);
uiSettings.setLogoEnabled(false);
mapboxMap.setOnMapClickListener(point -> {
mapboxMap.addOnMapClickListener(point -> {
// test if we can open 2 activities after each other
Toast.makeText(mapViewMini.getContext(), "Creating a new Activity instance",Toast.LENGTH_SHORT).show();
startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));

View File

@@ -64,14 +64,12 @@ public class MapSnapshotterReuseActivity extends AppCompatActivity implements Ma
}
private LatLngBounds getRandomBounds() {
return new LatLngBounds.Builder()
.include(new LatLng(
randomInRange(-5, 5),
randomInRange(-5, 5)))
.include(new LatLng(
randomInRange(5, 10),
randomInRange(5, 10))
).build();
return LatLngBounds.from(
randomInRange(5, 10),
randomInRange(-5, 5),
randomInRange(-5, 5),
randomInRange(5, 10)
);
}
private CameraPosition getRandomCameraPosition() {

View File

@@ -94,7 +94,7 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
}
private void addSymbolClickListener() {
mapboxMap.setOnMapClickListener(point -> {
mapboxMap.addOnMapClickListener(point -> {
PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
List<Feature> features = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID);
if (!features.isEmpty()) {

View File

@@ -1,16 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="0"
app:mapbox_cameraTargetLng="0"
app:mapbox_cameraZoom="16"/>
app:mapbox_cameraTargetLat="51"
app:mapbox_cameraTargetLng="17.25"
app:mapbox_cameraZoom="8" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_layers"
app:backgroundTint="@android:color/white" />
</android.support.design.widget.CoordinatorLayout>