Fix history marker in groups
This commit is contained in:
parent
b7f8968e12
commit
f05e4073c3
1 changed files with 59 additions and 16 deletions
|
@ -72,6 +72,10 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
if (addGroupFragment != null) {
|
||||
((AddGroupBottomSheetDialogFragment) addGroupFragment).setListener(createAddGroupListener());
|
||||
}
|
||||
Fragment historyMarkerMenuFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(HistoryMarkerMenuBottomSheetDialogFragment.TAG);
|
||||
if (historyMarkerMenuFragment != null) {
|
||||
((HistoryMarkerMenuBottomSheetDialogFragment) historyMarkerMenuFragment).setListener(createHistoryMarkerMenuListener());
|
||||
}
|
||||
|
||||
final EmptyStateRecyclerView recyclerView = (EmptyStateRecyclerView) mainView.findViewById(R.id.list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
@ -226,6 +230,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof MapMarker) {
|
||||
MapMarker marker = (MapMarker) item;
|
||||
if (!marker.history) {
|
||||
WptPt wptPt = marker.wptPt;
|
||||
FavouritePoint favouritePoint = marker.favouritePoint;
|
||||
Object objectToShow;
|
||||
|
@ -244,6 +249,18 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
15, pointDescription, true, objectToShow);
|
||||
MapActivity.launchMapActivityMoveToTop(mapActivity);
|
||||
((DialogFragment) getParentFragment()).dismiss();
|
||||
} else {
|
||||
HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
|
||||
fragment.setUsedOnMap(false);
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_POSITION, pos);
|
||||
arguments.putString(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_NAME, marker.getName(mapActivity));
|
||||
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_COLOR_INDEX, marker.colorIndex);
|
||||
arguments.putLong(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_VISITED_DATE, marker.visitedDate);
|
||||
fragment.setArguments(arguments);
|
||||
fragment.setListener(createHistoryMarkerMenuListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), HistoryMarkerMenuBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -293,6 +310,32 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
return mainView;
|
||||
}
|
||||
|
||||
private HistoryMarkerMenuBottomSheetDialogFragment.HistoryMarkerMenuFragmentListener createHistoryMarkerMenuListener() {
|
||||
return new HistoryMarkerMenuBottomSheetDialogFragment.HistoryMarkerMenuFragmentListener() {
|
||||
@Override
|
||||
public void onMakeMarkerActive(int pos) {
|
||||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof MapMarker) {
|
||||
if (getMyApplication() != null) {
|
||||
getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory((MapMarker) item, 0);
|
||||
}
|
||||
updateAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteMarker(int pos) {
|
||||
Object item = adapter.getItem(pos);
|
||||
if (item instanceof MapMarker) {
|
||||
if (getMyApplication() != null) {
|
||||
getMyApplication().getMapMarkersHelper().removeMarker((MapMarker) item);
|
||||
}
|
||||
updateAdapter();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void setGroupIdToOpen(String groupIdToOpen) {
|
||||
this.groupIdToOpen = groupIdToOpen;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue