Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
import android.graphics.RectF;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import com.google.gson.JsonElement;
import com.mapbox.geojson.Feature;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.NavUtils;
import timber.log.Timber;

import java.util.List;
import java.util.Map;

import timber.log.Timber;

/**
* Test activity showcasing using the query rendered features API to count features in a rectangle.
*/
Expand Down Expand Up @@ -93,7 +93,7 @@ protected void onStart() {

if (mapboxMap != null) {
// Regression test for #14394
mapboxMap.queryRenderedFeatures(new PointF(0,0));
mapboxMap.queryRenderedFeatures(new PointF(0, 0));
}
}

Expand Down Expand Up @@ -132,4 +132,23 @@ public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// activity uses singleInstance for testing purposes
// code below provides a default navigation when using the app
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
public void onBackPressed() {
// activity uses singleInstance for testing purposes
// code below provides a default navigation when using the app
NavUtils.navigateHome(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,46 @@ import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.maps.SupportMapFragment
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.utils.NavUtils
import kotlinx.android.synthetic.main.activity_backstack_fragment.*

/**
* Test activity showcasing using the MapFragment API as part of a backstacked fragment.
*/
class FragmentBackStackActivity : AppCompatActivity() {

private lateinit var mapFragment: SupportMapFragment
private lateinit var mapFragment: SupportMapFragment

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_backstack_fragment)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_backstack_fragment)

mapFragment = SupportMapFragment.newInstance()
mapFragment.getMapAsync { initMap(it) }
mapFragment = SupportMapFragment.newInstance()
mapFragment.getMapAsync { initMap(it) }

supportFragmentManager.beginTransaction().apply {
add(R.id.container, mapFragment)
}.commit()
supportFragmentManager.beginTransaction().apply {
add(R.id.container, mapFragment)
}.commit()

button.setOnClickListener { handleClick(it) }
}

private fun initMap(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.SATELLITE) {
mapboxMap.setPadding(300, 300, 300, 300)
}
}
button.setOnClickListener { handleClick(it) }
}

private fun handleClick(button: View) {
supportFragmentManager.beginTransaction().apply {
replace(R.id.container, NestedViewPagerActivity.ItemAdapter.EmptyFragment())
addToBackStack("map_empty_fragment")
}.commit()
private fun initMap(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.SATELLITE) {
mapboxMap.setPadding(300, 300, 300, 300)
}
}

private fun handleClick(button: View) {
supportFragmentManager.beginTransaction().apply {
replace(R.id.container, NestedViewPagerActivity.ItemAdapter.EmptyFragment())
addToBackStack("map_empty_fragment")
}.commit()
}

override fun onBackPressed() {
// activity uses singleInstance for testing purposes
// code below provides a default navigation when using the app
NavUtils.navigateHome(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.NavUtils;

/**
* Test activity showcasing a simple MapView without any MapboxMap interaction.
Expand Down Expand Up @@ -65,4 +67,23 @@ protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// activity uses singleInstance for testing purposes
// code below provides a default navigation when using the app
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
public void onBackPressed() {
// activity uses singleInstance for testing purposes
// code below provides a default navigation when using the app
NavUtils.navigateHome(this);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.mapbox.mapboxsdk.testapp.activity.textureview;

import android.view.MenuItem;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.activity.maplayout.DebugModeActivity;
import com.mapbox.mapboxsdk.testapp.utils.NavUtils;

/**
* Test activity showcasing the different debug modes and allows to cycle between the default map styles.
Expand All @@ -15,4 +17,24 @@ protected MapboxMapOptions setupMapboxMapOptions() {
mapboxMapOptions.textureMode(true);
return mapboxMapOptions;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// activity uses singleInstance for testing purposes
// code below provides a default navigation when using the app
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}


@Override
public void onBackPressed() {
// activity uses singleInstance for testing purposes
// code below provides a default navigation when using the app
NavUtils.navigateHome(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mapbox.mapboxsdk.testapp.utils;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.NonNull;
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity;

public class NavUtils {

public static void navigateHome(@NonNull Activity context) {
context.startActivity(new Intent(context, FeatureOverviewActivity.class));
context.finish();
}
}