fix remove TerrainFragment from dashboard

This commit is contained in:
veliymolfar 2020-03-23 14:43:48 +02:00
parent 2ca51a525e
commit 1bffad23f1

View file

@ -565,7 +565,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
DashboardOnMap.staticVisible = visible; DashboardOnMap.staticVisible = visible;
DashboardOnMap.staticVisibleType = type; DashboardOnMap.staticVisibleType = type;
mapActivity.enableDrawer(); mapActivity.enableDrawer();
removeMapillaryFiltersFragment(); removeFragment(MapillaryFiltersFragment.TAG);
removeFragment(TerrainFragment.TAG);
if (visible) { if (visible) {
mapActivity.dismissCardDialog(); mapActivity.dismissCardDialog();
@ -782,6 +783,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop()); int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
updateListAdapter(); updateListAdapter();
((ListView) listView).setSelectionFromTop(index, top); ((ListView) listView).setSelectionFromTop(index, top);
} else if (visibleType == DashboardType.TERRAIN) {
Fragment terrainFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(TerrainFragment.TAG);
if (terrainFragment != null) {
mapActivity.getSupportFragmentManager().beginTransaction()
.detach(terrainFragment)
.attach(terrainFragment)
.commit();
}
} else { } else {
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
} }
@ -982,14 +991,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
.getFragmentTransaction().commit(); .getFragmentTransaction().commit();
} }
private void removeMapillaryFiltersFragment() { private void removeFragment(String tag) {
FragmentManager manager = mapActivity.getSupportFragmentManager(); FragmentManager manager = mapActivity.getSupportFragmentManager();
Fragment mapillaryFragment = manager.findFragmentByTag(MapillaryFiltersFragment.TAG); Fragment fragment = manager.findFragmentByTag(tag);
if (mapillaryFragment != null) { if (fragment != null) {
OsmandSettings settings = getMyApplication().getSettings(); OsmandSettings settings = getMyApplication().getSettings();
TransactionBuilder builder = new TransactionBuilder(manager, settings, mapActivity); TransactionBuilder builder = new TransactionBuilder(manager, settings, mapActivity);
builder.getFragmentTransaction() builder.getFragmentTransaction()
.remove(mapillaryFragment) .remove(fragment)
.commit(); .commit();
} }
} }