From 073a14c4b91612dbee9522383e97bafd20ec246c Mon Sep 17 00:00:00 2001 From: William Newman Date: Mon, 15 Jan 2018 13:04:46 -0700 Subject: [PATCH] More wore to remove MGRS bottom sheet jitter --- .../java/mil/nga/giat/mage/map/MapFragment.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mage/src/main/java/mil/nga/giat/mage/map/MapFragment.java b/mage/src/main/java/mil/nga/giat/mage/map/MapFragment.java index 2321e2287..7c7cdb562 100644 --- a/mage/src/main/java/mil/nga/giat/mage/map/MapFragment.java +++ b/mage/src/main/java/mil/nga/giat/mage/map/MapFragment.java @@ -206,6 +206,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, OnMapCl private FloatingActionButton zoomToLocationButton; private LocationService locationService; + private boolean showMgrs; private TileOverlay mgrsTileOverlay; private BottomSheetBehavior mgrsBottomSheetBehavior; private View mgrsBottomSheet; @@ -272,6 +273,7 @@ public void onClick(View v) { mapView.getMapAsync(this); mgrsBottomSheet = view.findViewById(R.id.mgrs_bottom_sheet); + mgrsBottomSheetBehavior = BottomSheetBehavior.from(mgrsBottomSheet); mgrsCursor = view.findViewById(R.id.mgrs_grid_cursor); mgrsTextView = (TextView) mgrsBottomSheet.findViewById(R.id.mgrs_code); mgrsGzdTextView = (TextView) mgrsBottomSheet.findViewById(R.id.mgrs_gzd_zone); @@ -279,9 +281,6 @@ public void onClick(View v) { mgrsEastingTextView = (TextView) mgrsBottomSheet.findViewById(R.id.mgrs_easting); mgrsNorthingTextView = (TextView) mgrsBottomSheet.findViewById(R.id.mgrs_northing); - mgrsBottomSheetBehavior = BottomSheetBehavior.from(mgrsBottomSheet); - mgrsBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); - // Initialize the GeoPackage cache with a GeoPackage manager GeoPackageManager geoPackageManager = GeoPackageFactory.getManager(getActivity().getApplicationContext()); geoPackageCache = new GeoPackageCache(geoPackageManager); @@ -437,15 +436,9 @@ public void onClick(View v) { map.setLocationSource(null); } - boolean showMgrs = preferences.getBoolean(getResources().getString(R.string.showMGRSKey), false); mgrsCursor.setVisibility(showMgrs ? View.VISIBLE : View.GONE); if (showMgrs) { mgrsTileOverlay = map.addTileOverlay(new TileOverlayOptions().tileProvider(new MGRSTileProvider(getContext()))); - mgrsBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); - mgrsBottomSheetBehavior.setHideable(false); - } else { - mgrsBottomSheetBehavior.setHideable(true); - mgrsBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); } ((AppCompatActivity) getActivity()).getSupportActionBar().setSubtitle(getFilterTitle()); @@ -518,6 +511,12 @@ public void onResume() { } mapView.onResume(); + + // Don't wait for map to show up to init these values, otherwise bottomsheet will jitter + showMgrs = preferences.getBoolean(getResources().getString(R.string.showMGRSKey), false); + mgrsBottomSheetBehavior.setHideable(showMgrs ? false : true); + mgrsBottomSheetBehavior.setState(showMgrs ? BottomSheetBehavior.STATE_COLLAPSED : BottomSheetBehavior.STATE_HIDDEN); + initializeMap(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {