ItemizedLayer synchronized API, fix #507

This commit is contained in:
Emux 2018-02-20 15:53:45 +02:00
parent e108e6e3d7
commit e85e056a0c
No known key found for this signature in database
GPG Key ID: 89C6921D7AF2BDD0
4 changed files with 18 additions and 17 deletions

View File

@ -17,6 +17,7 @@
- `Parameters.POLY_SYMBOL = true;` - `Parameters.POLY_SYMBOL = true;`
- Map fractional zoom [#487](https://github.com/mapsforge/vtm/issues/487) - Map fractional zoom [#487](https://github.com/mapsforge/vtm/issues/487)
- Render theme fallback internal resources [#477](https://github.com/mapsforge/vtm/issues/477) - Render theme fallback internal resources [#477](https://github.com/mapsforge/vtm/issues/477)
- Fix ItemizedLayer synchronization [#507](https://github.com/mapsforge/vtm/issues/507)
- Fix FadeStep alpha interpolation [#486](https://github.com/mapsforge/vtm/issues/486) - Fix FadeStep alpha interpolation [#486](https://github.com/mapsforge/vtm/issues/486)
- Fix libGDX flickering [#148](https://github.com/mapsforge/vtm/issues/148) [#149](https://github.com/mapsforge/vtm/issues/149) - Fix libGDX flickering [#148](https://github.com/mapsforge/vtm/issues/148) [#149](https://github.com/mapsforge/vtm/issues/149)
- JTS (LocationTech) [#484](https://github.com/mapsforge/vtm/issues/484) - JTS (LocationTech) [#484](https://github.com/mapsforge/vtm/issues/484)

View File

@ -179,7 +179,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
} }
@Override @Override
public boolean removeItem(final Item item) { public synchronized boolean removeItem(final Item item) {
boolean result = super.removeItem(item); boolean result = super.removeItem(item);
if (mItemWithBubble == item) { if (mItemWithBubble == item) {
hideBubble(); hideBubble();
@ -188,7 +188,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
} }
@Override @Override
public void removeAllItems() { public synchronized void removeAllItems() {
super.removeAllItems(); super.removeAllItems();
hideBubble(); hideBubble();
} }

View File

@ -2,7 +2,7 @@
* Copyright 2012 osmdroid authors: Nicolas Gramlich, Theodore Hong, Fred Eisele * Copyright 2012 osmdroid authors: Nicolas Gramlich, Theodore Hong, Fred Eisele
* *
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2017 devemux86 * Copyright 2016-2018 devemux86
* Copyright 2016 Stephan Leuschner * Copyright 2016 Stephan Leuschner
* Copyright 2016 Pedinel * Copyright 2016 Pedinel
* *
@ -81,53 +81,53 @@ public class ItemizedLayer<Item extends MarkerInterface> extends MarkerLayer<Ite
} }
@Override @Override
protected Item createItem(int index) { protected synchronized Item createItem(int index) {
return mItemList.get(index); return mItemList.get(index);
} }
@Override @Override
public int size() { public synchronized int size() {
return Math.min(mItemList.size(), mDrawnItemsLimit); return Math.min(mItemList.size(), mDrawnItemsLimit);
} }
public boolean addItem(Item item) { public synchronized boolean addItem(Item item) {
final boolean result = mItemList.add(item); final boolean result = mItemList.add(item);
populate(); populate();
return result; return result;
} }
public void addItem(int location, Item item) { public synchronized void addItem(int location, Item item) {
mItemList.add(location, item); mItemList.add(location, item);
} }
public boolean addItems(Collection<Item> items) { public synchronized boolean addItems(Collection<Item> items) {
final boolean result = mItemList.addAll(items); final boolean result = mItemList.addAll(items);
populate(); populate();
return result; return result;
} }
public List<Item> getItemList() { public synchronized List<Item> getItemList() {
return mItemList; return mItemList;
} }
public void removeAllItems() { public synchronized void removeAllItems() {
removeAllItems(true); removeAllItems(true);
} }
public void removeAllItems(boolean withPopulate) { public synchronized void removeAllItems(boolean withPopulate) {
mItemList.clear(); mItemList.clear();
if (withPopulate) { if (withPopulate) {
populate(); populate();
} }
} }
public boolean removeItem(Item item) { public synchronized boolean removeItem(Item item) {
final boolean result = mItemList.remove(item); final boolean result = mItemList.remove(item);
populate(); populate();
return result; return result;
} }
public Item removeItem(int position) { public synchronized Item removeItem(int position) {
final Item result = mItemList.remove(position); final Item result = mItemList.remove(position);
populate(); populate();
return result; return result;

View File

@ -6,7 +6,7 @@
* *
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 Stephan Leuschner * Copyright 2016 Stephan Leuschner
* Copyright 2016 devemux86 * Copyright 2016-2018 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@ -71,7 +71,7 @@ public abstract class MarkerLayer<Item extends MarkerInterface> extends Layer {
* should call this as soon as it has data, before anything else gets * should call this as soon as it has data, before anything else gets
* called. * called.
*/ */
public final void populate() { public final synchronized void populate() {
mMarkerRenderer.populate(size()); mMarkerRenderer.populate(size());
} }
@ -85,7 +85,7 @@ public abstract class MarkerLayer<Item extends MarkerInterface> extends Layer {
* *
* @param item * @param item
*/ */
public void setFocus(Item item) { public synchronized void setFocus(Item item) {
mFocusedItem = item; mFocusedItem = item;
} }
@ -93,7 +93,7 @@ public abstract class MarkerLayer<Item extends MarkerInterface> extends Layer {
* @return the currently-focused item, or null if no item is currently * @return the currently-focused item, or null if no item is currently
* focused. * focused.
*/ */
public Item getFocus() { public synchronized Item getFocus() {
return mFocusedItem; return mFocusedItem;
} }