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 {
33 public abstract void addLocationListener(LocationListener listener);
34
49 public abstract void removeLocationListener(LocationListener listener);
50
66 public abstract void setLocationId(int locationId);
67
82 public abstract int getLocationId();
83
87 public abstract void commitChanges();
88
89 public abstract void revertChanges();
90
109 public abstract void setLocationUpdateInterval(int interval);
110
111 private static final class CppProxy extends LocationManager
112 {
113 private final long nativeRef;
114 private final AtomicBoolean destroyed = new AtomicBoolean(false);
115
116 private CppProxy(long nativeRef)
117 {
118 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
119 this.nativeRef = nativeRef;
120 }
121
122 private native void nativeDestroy(long nativeRef);
123 public void _djinni_private_destroy()
124 {
125 boolean destroyed = this.destroyed.getAndSet(true);
126 if (!destroyed) nativeDestroy(this.nativeRef);
127 }
128 protected void finalize() throws java.lang.Throwable
129 {
130 _djinni_private_destroy();
131 super.finalize();
132 }
133
134 // LocationManager methods
135
136 @Override
137 public void addLocationListener(LocationListener listener)
138 {
139 assert !this.destroyed.get() : "trying to use a destroyed object";
140 native_addLocationListener(this.nativeRef, listener);
141 }
142 private native void native_addLocationListener(long _nativeRef, LocationListener listener);
143
144 @Override
145 public void removeLocationListener(LocationListener listener)
146 {
147 assert !this.destroyed.get() : "trying to use a destroyed object";
148 native_removeLocationListener(this.nativeRef, listener);
149 }
150 private native void native_removeLocationListener(long _nativeRef, LocationListener listener);
151
152 @Override
153 public void setLocationId(int locationId)
154 {
155 assert !this.destroyed.get() : "trying to use a destroyed object";
156 native_setLocationId(this.nativeRef, locationId);
157 }
158 private native void native_setLocationId(long _nativeRef, int locationId);
159
160 @Override
161 public int getLocationId()
162 {
163 assert !this.destroyed.get() : "trying to use a destroyed object";
164 return native_getLocationId(this.nativeRef);
165 }
166 private native int native_getLocationId(long _nativeRef);
167
168 @Override
169 public void commitChanges()
170 {
171 assert !this.destroyed.get() : "trying to use a destroyed object";
172 native_commitChanges(this.nativeRef);
173 }
174 private native void native_commitChanges(long _nativeRef);
175
176 @Override
177 public void revertChanges()
178 {
179 assert !this.destroyed.get() : "trying to use a destroyed object";
180 native_revertChanges(this.nativeRef);
181 }
182 private native void native_revertChanges(long _nativeRef);
183
184 @Override
185 public void setLocationUpdateInterval(int interval)
186 {
187 assert !this.destroyed.get() : "trying to use a destroyed object";
188 native_setLocationUpdateInterval(this.nativeRef, interval);
189 }
190 private native void native_setLocationUpdateInterval(long _nativeRef, int interval);
191 }
192}