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