Loading...
Searching...
No Matches
LocationManager.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class LocationManager {
25 public abstract void addLocationListener(LocationListener listener);
26
33 public abstract void removeLocationListener(LocationListener listener);
34
42 public abstract void setLocationId(int locationId);
43
50 public abstract int getLocationId();
51
55 public abstract void commitChanges();
56
57 public abstract void revertChanges();
58
67 public abstract void setLocationUpdateInterval(int interval);
68
69 private static final class CppProxy extends LocationManager
70 {
71 private final long nativeRef;
72 private final AtomicBoolean destroyed = new AtomicBoolean(false);
73
74 private CppProxy(long nativeRef)
75 {
76 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
77 this.nativeRef = nativeRef;
78 }
79
80 private native void nativeDestroy(long nativeRef);
81 public void _djinni_private_destroy()
82 {
83 boolean destroyed = this.destroyed.getAndSet(true);
84 if (!destroyed) nativeDestroy(this.nativeRef);
85 }
86 protected void finalize() throws java.lang.Throwable
87 {
88 _djinni_private_destroy();
89 super.finalize();
90 }
91
92 // LocationManager methods
93
94 @Override
95 public void addLocationListener(LocationListener listener)
96 {
97 assert !this.destroyed.get() : "trying to use a destroyed object";
98 native_addLocationListener(this.nativeRef, listener);
99 }
100 private native void native_addLocationListener(long _nativeRef, LocationListener listener);
101
102 @Override
103 public void removeLocationListener(LocationListener listener)
104 {
105 assert !this.destroyed.get() : "trying to use a destroyed object";
106 native_removeLocationListener(this.nativeRef, listener);
107 }
108 private native void native_removeLocationListener(long _nativeRef, LocationListener listener);
109
110 @Override
111 public void setLocationId(int locationId)
112 {
113 assert !this.destroyed.get() : "trying to use a destroyed object";
114 native_setLocationId(this.nativeRef, locationId);
115 }
116 private native void native_setLocationId(long _nativeRef, int locationId);
117
118 @Override
119 public int getLocationId()
120 {
121 assert !this.destroyed.get() : "trying to use a destroyed object";
122 return native_getLocationId(this.nativeRef);
123 }
124 private native int native_getLocationId(long _nativeRef);
125
126 @Override
127 public void commitChanges()
128 {
129 assert !this.destroyed.get() : "trying to use a destroyed object";
130 native_commitChanges(this.nativeRef);
131 }
132 private native void native_commitChanges(long _nativeRef);
133
134 @Override
135 public void revertChanges()
136 {
137 assert !this.destroyed.get() : "trying to use a destroyed object";
138 native_revertChanges(this.nativeRef);
139 }
140 private native void native_revertChanges(long _nativeRef);
141
142 @Override
143 public void setLocationUpdateInterval(int interval)
144 {
145 assert !this.destroyed.get() : "trying to use a destroyed object";
146 native_setLocationUpdateInterval(this.nativeRef, interval);
147 }
148 private native void native_setLocationUpdateInterval(long _nativeRef, int interval);
149 }
150}