Skip to content

Commit 038a5dc

Browse files
committed
Port NodeEditor to kotlin
1 parent dff36cd commit 038a5dc

File tree

4 files changed

+274
-302
lines changed

4 files changed

+274
-302
lines changed

aat-android/src/main/kotlin/ch/bailu/aat/services/sensor/bluetooth_le/WheelCircumference.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class WheelCircumference(private val scontext: ServiceContext, private val revol
2929
if (newLocation != null) {
3030
currentLocation = newLocation
3131
if (currentLocation.getAccuracy() <= MIN_ACCURACY && revolution.isInitialized) {
32+
val previousLocation = previousLocation
3233
if (previousLocation == null) {
3334
reset(currentLocation)
3435
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ObjGpxEditable(id: String, private val file: Foc, sc: AppContext) : ObjGpx
5757
EditorInterface {
5858
private var editor = GpxEditor(GpxList.NULL_ROUTE)
5959
private var modified = false
60-
fun loadIntoEditor(list: GpxList?) {
60+
fun loadIntoEditor(list: GpxList) {
6161
editor = GpxEditor(list)
6262
modified = false
6363
modified(false)
Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,93 @@
1-
package ch.bailu.aat_lib.service.editor;
1+
package ch.bailu.aat_lib.service.editor
22

3-
import ch.bailu.aat_lib.gpx.GpxList;
4-
import ch.bailu.aat_lib.gpx.GpxPointNode;
5-
import ch.bailu.aat_lib.gpx.interfaces.GpxPointInterface;
6-
import ch.bailu.aat_lib.gpx.interfaces.GpxType;
3+
import ch.bailu.aat_lib.gpx.GpxList
4+
import ch.bailu.aat_lib.gpx.GpxPointNode
5+
import ch.bailu.aat_lib.gpx.interfaces.GpxPointInterface
6+
import ch.bailu.aat_lib.gpx.interfaces.GpxType
77

8-
public final class GpxEditor {
9-
10-
private final EditorRing ring;
11-
12-
public GpxEditor(GpxList list) {
13-
if (list.getPointList().size() > 0) {
14-
ring = new EditorRing((new NodeEditor((GpxPointNode) list.getPointList().getFirst(),
15-
list)));
16-
} else {
17-
ring = new EditorRing(new NodeEditor());
18-
}
8+
class GpxEditor(list: GpxList) {
9+
private val ring: EditorRing = if (list.pointList.size() > 0) {
10+
EditorRing(
11+
(NodeEditor(
12+
(list.pointList.first as GpxPointNode?)!!,
13+
list
14+
))
15+
)
16+
} else {
17+
EditorRing(NodeEditor())
1918
}
2019

21-
public void select(GpxPointNode point, GpxList list) {
22-
ring.set(new NodeEditor(point, list));
20+
fun select(point: GpxPointNode, list: GpxList) {
21+
ring.set(NodeEditor(point, list))
2322
}
2423

25-
public void clear() {
26-
ring.add(new NodeEditor());
24+
fun clear() {
25+
ring.add(NodeEditor())
2726
}
2827

29-
public void unlinkSelectedNode() {
30-
ring.add(ring.get().unlink());
28+
fun unlinkSelectedNode() {
29+
ring.add(ring.get().unlink())
3130
}
3231

33-
public void insertNode(GpxPointInterface point) {
34-
ring.add(ring.get().insert(point));
32+
fun insertNode(point: GpxPointInterface) {
33+
ring.add(ring.get().insert(point))
3534
}
3635

37-
public void moveSelectedUp() {
38-
GpxPointInterface point = ring.get().getPoint();
36+
fun moveSelectedUp() {
37+
val point: GpxPointInterface = ring.get().point
3938

40-
ring.add(ring.get().unlink());
41-
ring.set(ring.get().previous());
42-
ring.set(ring.get().insert(point));
39+
ring.add(ring.get().unlink())
40+
ring.set(ring.get().previous())
41+
ring.set(ring.get().insert(point))
4342
}
4443

45-
public void moveSelectedDown() {
46-
GpxPointInterface point = ring.get().getPoint();
47-
48-
ring.add(ring.get().unlink());
49-
ring.set(ring.get().next());
50-
ring.set(ring.get().insert(point));
44+
fun moveSelectedDown() {
45+
val point: GpxPointInterface = ring.get().point
5146

47+
ring.add(ring.get().unlink())
48+
ring.set(ring.get().next())
49+
ring.set(ring.get().insert(point))
5250
}
5351

54-
public GpxList getList() {
55-
return ring.get().getList();
56-
}
52+
val list: GpxList
53+
get() = ring.get().list
5754

58-
public GpxPointNode getSelectedPoint() {
59-
return ring.get().getPoint();
60-
}
55+
val selectedPoint: GpxPointNode
56+
get() = ring.get().point
6157

62-
public void setType(GpxType type) {
63-
ring.get().getList().setType(type);
58+
fun setType(type: GpxType) {
59+
ring.get().list.setType(type)
6460
}
6561

66-
public boolean undo() {
67-
return ring.undo();
62+
fun undo(): Boolean {
63+
return ring.undo()
6864
}
6965

70-
public boolean redo() {
71-
return ring.redo();
66+
fun redo(): Boolean {
67+
return ring.redo()
7268
}
7369

74-
public void simplify() {
75-
ring.add(ring.get().simplify());
70+
fun simplify() {
71+
ring.add(ring.get().simplify())
7672
}
7773

78-
public void fix() {
79-
ring.add(ring.get().fix());
74+
fun fix() {
75+
ring.add(ring.get().fix())
8076
}
8177

82-
public void inverse() {
83-
ring.add(ring.get().inverse());
78+
fun inverse() {
79+
ring.add(ring.get().inverse())
8480
}
8581

86-
public void attach(GpxList toAttach) {
87-
ring.add(ring.get().attach(toAttach));
82+
fun attach(toAttach: GpxList) {
83+
ring.add(ring.get().attach(toAttach))
8884
}
8985

90-
public void cutPreceding() {
91-
ring.add(ring.get().cutPreciding());
86+
fun cutPreceding() {
87+
ring.add(ring.get().cutPreceding())
9288
}
9389

94-
public void cutRemaining() {
95-
ring.add(ring.get().cutRemaining());
90+
fun cutRemaining() {
91+
ring.add(ring.get().cutRemaining())
9692
}
9793
}

0 commit comments

Comments
 (0)