@@ -21,203 +21,15 @@ dependencies {
2121
2222
2323## Setting Up in Kotlin
24- ``` kotlin
25- /* * ## First you will need to create service interactor object,
26- * as a proxy for Live Location services **/
27- private val liveLocationServiceInteractor =
28- object : LiveLocationServiceInteractorAbs () {
29-
30- /* * Define Your Context **/
31- override val context: Context = this @MainActivity
32-
33- /* * GPS Configuration Block **/
34- override val gpsConfig: GPSConfig =
35- object : GPSConfig {
36- override val samplingRate: Long = 10000
37- }
38-
39- /* * Notification Configuration Block **/
40- override val notificationConfig: NotificationConfig =
41- object : NotificationConfig {
42- override val foregroundServiceID: Int = 1003
43- override val notificationChannelID: String = CHANNEL_ID
44- override val notificationChannelName: String = CHANNEL_NAME
45- override val notificationChannelDescription: String = CHANNEL_DESCRIPTION
46- override val notificationPriority: Int = NotificationCompat .PRIORITY_DEFAULT
47- override val iconRes: Int? = null
48- }
49-
50- /* * Network Configuration Block **/
51- override val networkConfiguration: LiveLocationNetworkConfiguration =
52- object : LiveLocationNetworkConfiguration {
53- override val url: String = " http://websocket.company.com"
54- /* * You can define whether using Socket Communication or RESTFUL Api **/
55- override val networkMethod: NetworkMethod = NetworkMethod .RESTFULL
56- /* * You can put static payload such athorizations and other header what ever you needed **/
57- override val headers: HashMap <String , String > = hashMapOf(
58- " Header1" to " Bearer aasdasdadadadaa" ,
59- " Header2" to " Bearer 23423094029u40932"
60- )
61- /* * Add descriptor to your message **/
62- override val messageDescriptor: String by lazy {
63- val desc = hashMapOf<String , String >(
64- " userID" to userID.toString(),
65- " messagingToken" to messagingToken
66- )
67-
68- Gson ().toJson(desc)
69- }
70- }
71-
72- /* * Bellows are the interfaces you can use to get respond in realtime to your application **/
73- override fun onServiceStatusChanged (
74- serviceStatus : LiveLocationServiceInteractor .ServiceStatus
75- ) {
76- lifecycleScope.launch {
77- liveLocationRunning.emit(
78- when (serviceStatus) {
79- LiveLocationServiceInteractor .ServiceStatus .RUNNING ->
80- true
81-
82- LiveLocationServiceInteractor .ServiceStatus .DEAD ->
83- false
84- }
85- )
86- }
87- }
88-
89- override fun onError (
90- message : String?
91- ) {
92- lifecycleScope.launch {
93- liveLocationError.emit(
94- message
95- )
96- }
97- }
98-
99- override fun onReceiveUpdate (
100- latitude : Double ,
101- longitude : Double ,
102- accuracy : Float ,
103- updateTime : Long
104- ) {
105- lifecycleScope.launch {
106- location.emit(
107- LatLng (
108- latitude,
109- longitude
110- )
111- )
112- }
113- }
114-
115- }
116- ```
24+ See [ SetupKotlin.md] ( docs%2FSetupKotlin.md ) .
11725
11826## Setting Up in Java
119- ``` java
120- private String userID = " USER ID" ;
121- private String messagingToken = " Dummy Messaging Token" ;
122-
123- private LiveLocationServiceInteractor liveLocationServiceInteractor = new LiveLocationServiceInteractorAbs () {
124- @Override
125- public Context getContext () {
126- return Main2Activity . this ;
127- }
128-
129- @Override
130- public GPSConfig getGpsConfig () {
131- return new GPSConfig () {
132- @Override
133- public long getSamplingRate () {
134- return 10000 ;
135- }
136- };
137- }
27+ See [ SetupJava.md] ( docs%2FSetupJava.md ) .
13828
139- @Override
140- public NotificationConfig getNotificationConfig () {
141- return new NotificationConfig () {
142- @Override
143- public int getForegroundServiceID () {
144- return 1003 ;
145- }
146-
147- @Override
148- public String getNotificationChannelID () {
149- return CHANNEL_ID ;
150- }
151-
152- @Override
153- public String getNotificationChannelName () {
154- return CHANNEL_NAME ;
155- }
156-
157- @Override
158- public String getNotificationChannelDescription () {
159- return CHANNEL_DESCRIPTION ;
160- }
161-
162- @Override
163- public int getNotificationPriority () {
164- return NotificationCompat . PRIORITY_DEFAULT ;
165- }
166-
167- @Override
168- public Integer getIconRes () {
169- return null ;
170- }
171- };
172- }
173-
174- @Override
175- public LiveLocationNetworkConfiguration getNetworkConfiguration () {
176- return new LiveLocationNetworkConfiguration () {
177- @Override
178- public String getUrl () {
179- return " http://websocket.company.com;
180- }
181-
182- @Override
183- public NetworkMethod getNetworkMethod() {
184- return NetworkMethod.WEBSOCKET;
185- }
186-
187- @Override
188- public HashMap<String, String> getHeaders() {
189- HashMap<String, String> headers = new HashMap<>();
190- headers.put(" Header1 " , " Bearer aasdasdadadadaa" );
191- headers.put(" Header2 " , " Bearer 23423094029u40932" );
192- return headers;
193- }
194-
195- @Override
196- public String getMessageDescriptor() {
197- HashMap<String, String> desc = new HashMap<>();
198- desc.put(" userID" , String.valueOf(userID));
199- desc.put(" messagingToken" , messagingToken);
200- return new Gson().toJson(desc);
201- }
202- };
203- }
204-
205- @Override
206- public void onServiceStatusChanged(LiveLocationServiceInteractor.ServiceStatus serviceStatus) {
207- // TODO : Do what you need
208- }
209-
210- @Override
211- public void onError(String message) {
212- // TODO : Do what you need
213- }
214-
215- @Override
216- public void onReceiveUpdate(double latitude, double longitude, float accuracy, long updateTime) {
217- // TODO : Do what you need
218- }
219- };
220- ```
29+ ## Setup Alien
30+ If you are using alien technology such Xamarin/Unity, C++ and other non java platform,
31+ you can create a portal interaction using AlienPortal object.
32+ See [ SetupAlien.md] ( docs%2FSetupAlien.md ) .
22133
22234## Networking
22335This library will automatically sync your data to network, the body request will be
@@ -249,7 +61,7 @@ So the permission request should be done in 2 steps:
24961- You can use java or kotlin, the syntax won't have a lot different, you can contact me for more help.
25062
25163## Build AAR Libray
252- To build the library just run the `build- library. sh` in the project root directory.
64+ If you need the aar file, to build the library just run the ` build-library.sh ` in the project root directory.
25365
25466## Design and Developed by :
25567- [ Stefanus Ayudha] ( https://github.com/stefanusayudha )
0 commit comments