Skip to content

Commit 45f5990

Browse files
committed
Fix duplicate editor source
1 parent db11dea commit 45f5990

File tree

7 files changed

+8
-31
lines changed

7 files changed

+8
-31
lines changed

aat-android/src/main/kotlin/ch/bailu/aat/broadcaster/AndroidDispatcherFactory.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import ch.bailu.aat_lib.dispatcher.usage.UsageTrackerInterface
88

99
fun DispatcherInterface.addMapOverlaySources(appContext: AppContext, usageTrackers: UsageTrackerInterface) {
1010
this.addOverlaySources(appContext, usageTrackers)
11-
this.addSource(FixedOverlaySource.createDraftSource(appContext, usageTrackers))
1211
this.addSource(FixedOverlaySource.createPoiSource(appContext, usageTrackers))
1312
this.addSource(FixedOverlaySource.createBrouterSource(appContext, usageTrackers))
1413
this.addSource(FixedOverlaySource.createNominatimReverseSource(appContext, usageTrackers))

aat-android/src/main/kotlin/ch/bailu/aat/map/MapFactory.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class MapFactory(private val m: MapsForgeViewBase, activityContext: ActivityCont
6161
addMapOverlays(usageTracker)
6262

6363
m.add(EditorBarLayer(appContext, c, mc, d, iid, e))
64+
m.add(GpxDynLayer(s, mc, ser, d, iid))
6465
m.add(GpxDynLayer(s, mc, ser, d, InfoID.FILE_VIEW))
6566
m.add(GpxDynLayer(s, mc, ser, d, InfoID.TRACKER))
6667

aat-android/src/main/kotlin/ch/bailu/aat/map/layer/EditorBarLayer.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import ch.bailu.aat_lib.dispatcher.EditorSourceInterface
1515
import ch.bailu.aat_lib.gpx.GpxPoint
1616
import ch.bailu.aat_lib.map.MapContext
1717
import ch.bailu.aat_lib.map.edge.Position
18-
import ch.bailu.aat_lib.map.layer.gpx.GpxDynLayer
1918
import ch.bailu.aat_lib.preferences.StorageInterface
2019
import ch.bailu.aat_lib.resources.Res
2120

@@ -34,7 +33,6 @@ class EditorBarLayer(
3433
private val remove: View = bar.addImageButton(R.drawable.list_remove)
3534
private val up: View = bar.addImageButton(R.drawable.go_up)
3635
private val down: View = bar.addImageButton(R.drawable.go_down)
37-
private val content: GpxDynLayer = GpxDynLayer(appContext.storage, mcontext, appContext.services)
3836
private val selector = EditorNodeViewLayer(appContext, context, mcontext, edit)
3937
private val file: View = bar.addImageButton(R.drawable.edit_select_all_inverse)
4038
private val brouterController = BrouterController(appContext, edit)
@@ -45,7 +43,6 @@ class EditorBarLayer(
4543
ToolTip.set(up, Res.str().tt_edit_up())
4644
ToolTip.set(down, Res.str().tt_edit_down())
4745
dispatcher.addTarget(selector, iid)
48-
dispatcher.addTarget(content, iid)
4946
}
5047

5148
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
@@ -54,14 +51,12 @@ class EditorBarLayer(
5451
}
5552

5653
override fun drawInside(mcontext: MapContext) {
57-
content.drawInside(mcontext)
5854
if (isBarVisible) {
5955
selector.drawInside(mcontext)
6056
}
6157
}
6258

6359
override fun drawForeground(mcontext: MapContext) {
64-
content.drawForeground(mcontext)
6560
if (isBarVisible) {
6661
selector.drawForeground(mcontext)
6762
}
@@ -94,7 +89,6 @@ class EditorBarLayer(
9489
}
9590

9691
override fun onPreferencesChanged(storage: StorageInterface, key: String) {
97-
content.onPreferencesChanged(storage, key)
9892
selector.onPreferencesChanged(storage, key)
9993
}
10094

aat-lib/src/main/java/ch/bailu/aat_lib/dispatcher/source/EditorOrBackupSource.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class EditorOrBackupSource(appContext: AppContext, source: SourceInterface) :
5555
}
5656
}
5757

58-
5958
override val editor: EditorInterface
6059
get() = editorSource.editor
6160

aat-lib/src/main/java/ch/bailu/aat_lib/service/cache/gpx/ObjGpxEditable.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ import ch.bailu.aat_lib.util.fs.FileNameSplitter
1919
import ch.bailu.aat_lib.util.fs.FileUtil
2020
import ch.bailu.foc.Foc
2121

22-
class ObjGpxEditable(_id: String, private val _file: Foc, sc: AppContext) : ObjGpx(_id) {
22+
class ObjGpxEditable(id: String, private val file: Foc, sc: AppContext) : ObjGpx(id) {
2323
private var currentHandle = NULL
24-
val editor: GpxListEditor
24+
val editor: GpxListEditor = GpxListEditor(sc.broadcaster)
2525

2626
init {
27-
editor = GpxListEditor(sc.broadcaster)
2827
sc.services.getCacheService().addToBroadcaster(this)
2928
}
3029

3130
override fun onInsert(appContext: AppContext) {
32-
val handle = appContext.services.getCacheService().getObject(_file.path, ObjGpxStatic.Factory())
31+
val handle = appContext.services.getCacheService().getObject(file.path, ObjGpxStatic.Factory())
3332
currentHandle = handle as? ObjGpx ?: NULL
3433
editor.loadIntoEditor(currentHandle.getGpxList())
3534
}
@@ -49,7 +48,7 @@ class ObjGpxEditable(_id: String, private val _file: Foc, sc: AppContext) : ObjG
4948

5049
override fun onDownloaded(id: String, url: String, appContext: AppContext) {}
5150
override fun onChanged(id: String, appContext: AppContext) {
52-
if (id == _file.path) {
51+
if (id == file.path) {
5352
editor.loadIntoEditor(currentHandle.getGpxList())
5453
}
5554
}
@@ -192,7 +191,7 @@ class ObjGpxEditable(_id: String, private val _file: Foc, sc: AppContext) : ObjG
192191
}
193192

194193
override fun getFile(): Foc {
195-
return _file
194+
return file
196195
}
197196

198197
override fun getLoaded(): Boolean {

aat-lib/src/main/java/ch/bailu/aat_lib/service/editor/EditorHelper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ class EditorHelper(private val appContext: AppContext) :
5252
}
5353

5454
override fun getInfo(): GpxInformation {
55+
val handle = handle
5556
return if (handle is ObjGpxEditable) {
56-
(handle as ObjGpxEditable).editor
57+
handle.editor
5758
} else GpxInformation.NULL
5859
}
5960

aat-lib/src/main/java/ch/bailu/aat_lib/service/editor/GpxEditor.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public final class GpxEditor {
99

1010
private final EditorRing ring;
1111

12-
1312
public GpxEditor(GpxList list) {
1413
if (list.getPointList().size() > 0) {
1514
ring = new EditorRing((new NodeEditor((GpxPointNode) list.getPointList().getFirst(),
@@ -19,39 +18,30 @@ public GpxEditor(GpxList list) {
1918
}
2019
}
2120

22-
2321
public void select(GpxPointNode point, GpxList list) {
2422
ring.set(new NodeEditor(point, list));
2523
}
2624

27-
2825
public void clear() {
2926
ring.add(new NodeEditor());
3027
}
3128

32-
3329
public void unlinkSelectedNode() {
3430
ring.add(ring.get().unlink());
35-
3631
}
3732

38-
3933
public void insertNode(GpxPointInterface point) {
4034
ring.add(ring.get().insert(point));
41-
4235
}
4336

44-
4537
public void moveSelectedUp() {
4638
GpxPointInterface point = ring.get().getPoint();
4739

4840
ring.add(ring.get().unlink());
4941
ring.set(ring.get().previous());
5042
ring.set(ring.get().insert(point));
51-
5243
}
5344

54-
5545
public void moveSelectedDown() {
5646
GpxPointInterface point = ring.get().getPoint();
5747

@@ -61,32 +51,26 @@ public void moveSelectedDown() {
6151

6252
}
6353

64-
6554
public GpxList getList() {
6655
return ring.get().getList();
6756
}
6857

69-
7058
public GpxPointNode getSelectedPoint() {
7159
return ring.get().getPoint();
7260
}
7361

74-
7562
public void setType(GpxType type) {
7663
ring.get().getList().setType(type);
7764
}
7865

79-
8066
public boolean undo() {
8167
return ring.undo();
8268
}
8369

84-
8570
public boolean redo() {
8671
return ring.redo();
8772
}
8873

89-
9074
public void simplify() {
9175
ring.add(ring.get().simplify());
9276
}

0 commit comments

Comments
 (0)