This commit is contained in:
PavelRatushny 2017-10-13 14:47:38 +03:00
parent f1a656efba
commit 987e45a0da
2 changed files with 28 additions and 3 deletions

View file

@ -93,6 +93,8 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
BASIC_TAGS.add(OSMSettings.OSMTagKey.OPENING_HOURS.getValue()); BASIC_TAGS.add(OSMSettings.OSMTagKey.OPENING_HOURS.getValue());
} }
private OnPoiChangedListener onPoiChangedListener;
private EditPoiData editPoiData; private EditPoiData editPoiData;
private ViewPager viewPager; private ViewPager viewPager;
private AutoCompleteTextView poiTypeEditText; private AutoCompleteTextView poiTypeEditText;
@ -101,6 +103,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
private TextInputLayout poiTypeTextInputLayout; private TextInputLayout poiTypeTextInputLayout;
private View view; private View view;
public void setOnPoiChangedListener(OnPoiChangedListener listener) {
this.onPoiChangedListener = listener;
}
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
@ -473,6 +479,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
if (getActivity() instanceof MapActivity) { if (getActivity() instanceof MapActivity) {
((MapActivity) getActivity()).getMapView().refreshMap(true); ((MapActivity) getActivity()).getMapView().refreshMap(true);
} }
if (onPoiChangedListener != null) {
onPoiChangedListener.onPoiChanged();
}
dismiss(); dismiss();
} else { } else {
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
@ -618,11 +627,16 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
} }
public static EditPoiDialogFragment createInstance(Node node, boolean isAddingPoi) { public static EditPoiDialogFragment createInstance(Node node, boolean isAddingPoi) {
return createInstance(node, isAddingPoi, (OnPoiChangedListener) null);
}
public static EditPoiDialogFragment createInstance(Node node, boolean isAddingPoi, OnPoiChangedListener listener) {
EditPoiDialogFragment editPoiDialogFragment = new EditPoiDialogFragment(); EditPoiDialogFragment editPoiDialogFragment = new EditPoiDialogFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putSerializable(KEY_AMENITY_NODE, node); args.putSerializable(KEY_AMENITY_NODE, node);
args.putBoolean(IS_ADDING_POI, isAddingPoi); args.putBoolean(IS_ADDING_POI, isAddingPoi);
editPoiDialogFragment.setArguments(args); editPoiDialogFragment.setArguments(args);
editPoiDialogFragment.setOnPoiChangedListener(listener);
return editPoiDialogFragment; return editPoiDialogFragment;
} }
@ -835,4 +849,8 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
public interface OnFragmentActivatedListener { public interface OnFragmentActivatedListener {
void onFragmentActivated(); void onFragmentActivated();
} }
public interface OnPoiChangedListener {
void onPoiChanged();
}
} }

View file

@ -323,6 +323,10 @@ public class OsmEditsFragment extends OsmAndListFragment
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
fetchData();
}
private void fetchData() {
ArrayList<OsmPoint> dataPoints = new ArrayList<>(); ArrayList<OsmPoint> dataPoints = new ArrayList<>();
List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints(); List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints(); List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
@ -351,7 +355,6 @@ public class OsmEditsFragment extends OsmAndListFragment
} else { } else {
listAdapter.setNewList(dataPoints); listAdapter.setNewList(dataPoints);
} }
} }
private void showBugDialog(final OsmNotesPoint point) { private void showBugDialog(final OsmNotesPoint point) {
@ -527,8 +530,12 @@ public class OsmEditsFragment extends OsmAndListFragment
OpenstreetmapPoint i = (OpenstreetmapPoint) getPointAfterModify(info); OpenstreetmapPoint i = (OpenstreetmapPoint) getPointAfterModify(info);
final Node entity = i.getEntity(); final Node entity = i.getEntity();
refreshId = entity.getId(); refreshId = entity.getId();
EditPoiDialogFragment.createInstance(entity, false) EditPoiDialogFragment.createInstance(entity, false, new EditPoiDialogFragment.OnPoiChangedListener() {
.show(getActivity().getSupportFragmentManager(), "edit_poi"); @Override
public void onPoiChanged() {
fetchData();
}
}).show(getActivity().getSupportFragmentManager(), "edit_poi");
return true; return true;
} }
}); });