Merge pull request #4582 from osmandapp/osm_edits_fix

Fix #4564
This commit is contained in:
Alexey 2017-10-14 16:39:07 +03:00 committed by GitHub
commit 9ef2f74f0c
2 changed files with 44 additions and 3 deletions

View file

@ -11,6 +11,9 @@ import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
public final static Log LOG = PlatformUtil.getLog(OpenstreetmapLocalUtil.class);
@ -21,6 +24,18 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
this.plugin = plugin;
}
private List<OnNodeCommittedListener> listeners = new ArrayList<>();
public void addNodeCommittedListener(OnNodeCommittedListener listener) {
if (!listeners.contains(listener)) {
listeners.add(listener);
}
}
public void removeNodeCommittedListener(OnNodeCommittedListener listener) {
listeners.remove(listener);
}
@Override
public EntityInfo getEntityInfo(long id) {
return null;
@ -41,6 +56,9 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
} else {
plugin.getDBPOI().addOpenstreetmap(p);
}
for (OnNodeCommittedListener listener : listeners) {
listener.onNoteCommitted();
}
return newNode;
}
@ -78,5 +96,9 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
@Override
public void closeChangeSet() {
}
public interface OnNodeCommittedListener {
void onNoteCommitted();
}
}

View file

@ -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,16 @@ public class OsmEditsFragment extends OsmAndListFragment
updateSelectionTitle(actionMode);
}
});
plugin.getPoiModificationLocalUtil().addNodeCommittedListener(this);
return view;
}
@Override
public void onDestroyView() {
plugin.getPoiModificationLocalUtil().removeNodeCommittedListener(this);
super.onDestroyView();
}
public android.widget.ArrayAdapter<?> getAdapter() {
return listAdapter;
}
@ -323,6 +329,10 @@ public class OsmEditsFragment extends OsmAndListFragment
@Override
public void onResume() {
super.onResume();
fetchData();
}
private void fetchData() {
ArrayList<OsmPoint> dataPoints = new ArrayList<>();
List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
@ -351,7 +361,6 @@ public class OsmEditsFragment extends OsmAndListFragment
} else {
listAdapter.setNewList(dataPoints);
}
}
private void showBugDialog(final OsmNotesPoint point) {
@ -406,6 +415,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;