Skip to content

Commit

Permalink
More wore to remove MGRS bottom sheet jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
newmanw committed Jan 15, 2018
1 parent 4add570 commit 073a14c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions mage/src/main/java/mil/nga/giat/mage/map/MapFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -272,16 +273,14 @@ 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);
mgrs100dKmTextView = (TextView) mgrsBottomSheet.findViewById(R.id.mgrs_grid_zone);
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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 073a14c

Please sign in to comment.