summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java32
1 files changed, 17 insertions, 15 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
index c195372d90..7221b71da3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
@@ -26,6 +26,7 @@ import com.mapbox.mapboxsdk.testapp.R;
import java.util.List;
import java.util.Locale;
+import com.mapbox.mapboxsdk.testapp.utils.IdleZoomListener;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
@@ -38,7 +39,8 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
private MapView mapView;
private MapboxMap mapboxMap;
private ActionBarDrawerToggle actionBarDrawerToggle;
- private int currentStyleIndex = 0;
+ private int currentStyleIndex;
+ private IdleZoomListener idleZoomListener;
private static final String[] STYLES = new String[] {
Style.MAPBOX_STREETS,
@@ -66,8 +68,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
-
- DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
actionBarDrawerToggle = new ActionBarDrawerToggle(this,
drawerLayout,
R.string.navigation_drawer_open,
@@ -79,7 +80,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void setupMapView(Bundle savedInstanceState) {
- mapView = (MapView) findViewById(R.id.mapView);
+ mapView = findViewById(R.id.mapView);
mapView.addOnDidFinishLoadingStyleListener(() -> {
if (mapboxMap != null) {
@@ -105,7 +106,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void setFpsView() {
- final TextView fpsView = (TextView) findViewById(R.id.fpsView);
+ final TextView fpsView = findViewById(R.id.fpsView);
mapboxMap.setOnFpsChangedListener(fps ->
fpsView.setText(String.format(Locale.US, "FPS: %4.2f", fps))
);
@@ -114,7 +115,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
private void setupNavigationView(List<Layer> layerList) {
Timber.v("New style loaded with JSON: %s", mapboxMap.getStyleJson());
final LayerListAdapter adapter = new LayerListAdapter(this, layerList);
- ListView listView = (ListView) findViewById(R.id.listView);
+ ListView listView = findViewById(R.id.listView);
listView.setAdapter(adapter);
listView.setOnItemClickListener((parent, view, position, id) -> {
Layer clickedLayer = adapter.getItem(position);
@@ -133,19 +134,17 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void closeNavigationView() {
- DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
drawerLayout.closeDrawers();
}
private void setupZoomView() {
- final TextView textView = (TextView) findViewById(R.id.textZoom);
- mapboxMap.setOnCameraChangeListener(position ->
- textView.setText(String.format(getString(R.string.debug_zoom), position.zoom))
- );
+ final TextView textView = findViewById(R.id.textZoom);
+ mapboxMap.addOnCameraIdleListener(idleZoomListener = new IdleZoomListener(mapboxMap, textView));
}
private void setupDebugChangeView() {
- FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug);
+ FloatingActionButton fabDebug = findViewById(R.id.fabDebug);
fabDebug.setOnClickListener(view -> {
if (mapboxMap != null) {
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive());
@@ -155,7 +154,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void setupStyleChangeView() {
- FloatingActionButton fabStyles = (FloatingActionButton) findViewById(R.id.fabStyles);
+ FloatingActionButton fabStyles = findViewById(R.id.fabStyles);
fabStyles.setOnClickListener(view -> {
if (mapboxMap != null) {
currentStyleIndex++;
@@ -205,6 +204,9 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null && idleZoomListener != null) {
+ mapboxMap.removeOnCameraIdleListener(idleZoomListener);
+ }
mapView.onDestroy();
}
@@ -246,8 +248,8 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
if (view == null) {
view = layoutInflater.inflate(android.R.layout.simple_list_item_2, parent, false);
ViewHolder holder = new ViewHolder(
- (TextView) view.findViewById(android.R.id.text1),
- (TextView) view.findViewById(android.R.id.text2)
+ view.findViewById(android.R.id.text1),
+ view.findViewById(android.R.id.text2)
);
view.setTag(holder);
}