Create listener in openstreetmaplocalutil
This commit is contained in:
parent
b285ad96a2
commit
79958c26f9
3 changed files with 39 additions and 22 deletions
|
@ -93,8 +93,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
BASIC_TAGS.add(OSMSettings.OSMTagKey.OPENING_HOURS.getValue());
|
||||
}
|
||||
|
||||
private OnPoiChangedListener onPoiChangedListener;
|
||||
|
||||
private EditPoiData editPoiData;
|
||||
private ViewPager viewPager;
|
||||
private AutoCompleteTextView poiTypeEditText;
|
||||
|
@ -103,10 +101,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
private TextInputLayout poiTypeTextInputLayout;
|
||||
private View view;
|
||||
|
||||
public void setOnPoiChangedListener(OnPoiChangedListener listener) {
|
||||
this.onPoiChangedListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
@ -479,9 +473,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
if (getActivity() instanceof MapActivity) {
|
||||
((MapActivity) getActivity()).getMapView().refreshMap(true);
|
||||
}
|
||||
if (onPoiChangedListener != null) {
|
||||
onPoiChangedListener.onPoiChanged();
|
||||
}
|
||||
dismiss();
|
||||
} else {
|
||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
|
@ -627,16 +618,11 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
}
|
||||
|
||||
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();
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(KEY_AMENITY_NODE, node);
|
||||
args.putBoolean(IS_ADDING_POI, isAddingPoi);
|
||||
editPoiDialogFragment.setArguments(args);
|
||||
editPoiDialogFragment.setOnPoiChangedListener(listener);
|
||||
return editPoiDialogFragment;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
|||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private OnNodeCommittedListener listener;
|
||||
|
||||
public void setOnNodeCommittedListener(OnNodeCommittedListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInfo getEntityInfo(long id) {
|
||||
return null;
|
||||
|
@ -41,6 +47,9 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
|||
} else {
|
||||
plugin.getDBPOI().addOpenstreetmap(p);
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onNoteCommitted();
|
||||
}
|
||||
return newNode;
|
||||
}
|
||||
|
||||
|
@ -78,5 +87,9 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
|||
@Override
|
||||
public void closeChangeSet() {
|
||||
}
|
||||
|
||||
public interface OnNodeCommittedListener {
|
||||
void onNoteCommitted();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class OsmEditsFragment extends OsmAndListFragment
|
||||
implements SendPoiDialogFragment.ProgressDialogPoiUploader {
|
||||
implements SendPoiDialogFragment.ProgressDialogPoiUploader, OpenstreetmapLocalUtil.OnNodeCommittedListener {
|
||||
OsmEditingPlugin plugin;
|
||||
|
||||
private OsmEditsAdapter listAdapter;
|
||||
|
@ -98,10 +98,22 @@ public class OsmEditsFragment extends OsmAndListFragment
|
|||
updateSelectionTitle(actionMode);
|
||||
}
|
||||
});
|
||||
if (getMyApplication().getSettings().OFFLINE_EDITION.get()
|
||||
|| !getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
|
||||
plugin.getPoiModificationLocalUtil().setOnNodeCommittedListener(this);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (getMyApplication().getSettings().OFFLINE_EDITION.get()
|
||||
|| !getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
|
||||
plugin.getPoiModificationLocalUtil().setOnNodeCommittedListener(null);
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public android.widget.ArrayAdapter<?> getAdapter() {
|
||||
return listAdapter;
|
||||
}
|
||||
|
@ -409,6 +421,16 @@ public class OsmEditsFragment extends OsmAndListFragment
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoteCommitted() {
|
||||
getMyApplication().runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fetchData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
||||
private List<OsmPoint> dataPoints;
|
||||
|
||||
|
@ -530,12 +552,8 @@ public class OsmEditsFragment extends OsmAndListFragment
|
|||
OpenstreetmapPoint i = (OpenstreetmapPoint) getPointAfterModify(info);
|
||||
final Node entity = i.getEntity();
|
||||
refreshId = entity.getId();
|
||||
EditPoiDialogFragment.createInstance(entity, false, new EditPoiDialogFragment.OnPoiChangedListener() {
|
||||
@Override
|
||||
public void onPoiChanged() {
|
||||
fetchData();
|
||||
}
|
||||
}).show(getActivity().getSupportFragmentManager(), "edit_poi");
|
||||
EditPoiDialogFragment.createInstance(entity, false)
|
||||
.show(getActivity().getSupportFragmentManager(), "edit_poi");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue