Skip to content

Commit d9d8c7a

Browse files
committed
Ats id added while listening TAGS
1 parent 918cdff commit d9d8c7a

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

ats-sdk/src/main/java/com/apporioinfolabs/ats_sdk/AtsTagListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
public interface AtsTagListener {
66
void onSuccess(String message); // 1
77
void onFailed(String message); // 2
8-
void onAdd(Location location); // 3
9-
void onChange(Location location); // 4
10-
void onRemove(Location location); // 5
8+
void onAdd(Location location, String atsId); // 3
9+
void onChange(Location location, String atsId); // 4
10+
void onRemove(Location location, String atsId); // 5
1111
}

ats-sdk/src/main/java/com/apporioinfolabs/ats_sdk/managers/SocketManager.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public void call(Object... args) {
284284
ModelResultChecker modelResultChecker = ATS.gson.fromJson(""+args[0],ModelResultChecker.class);
285285
if(modelResultChecker.getResult() == 1){
286286
ModelTagListener modelTagListener = ATS.gson.fromJson(""+args[0],ModelTagListener.class);
287-
handlerForAtsTagListener(""+modelResultChecker.getMessage(), atsTagListener,1);
287+
handlerForAtsTagListener(""+modelResultChecker.getMessage(),"", atsTagListener,1);
288288

289289
String tagListening = ATS.mBuilder.mApplication.getSharedPreferences(ATSConstants.PREFRENCES, Context.MODE_PRIVATE).getString(ATSConstants.KEYS.LISTEN_TAG,"NA");
290290
if(!tagListening.equals("NA")){ mSocket.off(""+modelTagListener.getResponse().get(0).getUls()); }
@@ -296,28 +296,29 @@ public void call(Object... args) {
296296
mSocket.on(modelTagListener.getResponse().get(0).getUls(), new Emitter.Listener() {
297297
@Override
298298
public void call(Object... args) {
299+
Log.e(TAG , "&& && "+args[0]);
299300
ModelEmitterbyTagData modelEmitterbyTagData = ATS.gson.fromJson(""+args[0],ModelEmitterbyTagData.class);
300301
if(modelEmitterbyTagData.getType().equals("ADD")){
301-
handlerForAtsTagListener(""+modelEmitterbyTagData.getData(), atsTagListener,3);
302+
handlerForAtsTagListener(""+modelEmitterbyTagData.getData(),modelEmitterbyTagData.getAts_id(), atsTagListener,3);
302303
}if(modelEmitterbyTagData.getType().equals("CHANGE")){
303-
handlerForAtsTagListener(""+modelEmitterbyTagData.getData(), atsTagListener,4);
304+
handlerForAtsTagListener(""+modelEmitterbyTagData.getData(),modelEmitterbyTagData.getAts_id(), atsTagListener,4);
304305
}if(modelEmitterbyTagData.getType().equals("REMOVE")){
305-
handlerForAtsTagListener(""+modelEmitterbyTagData.getData(), atsTagListener,5);
306+
handlerForAtsTagListener(""+modelEmitterbyTagData.getData(),modelEmitterbyTagData.getAts_id(), atsTagListener,5);
306307
}
307308

308309
}
309310
});
310311

311312
}else if(modelResultChecker.getResult() == 0){
312-
handlerForAtsTagListener(""+modelResultChecker.getMessage(), atsTagListener,2);
313+
handlerForAtsTagListener(""+modelResultChecker.getMessage(), "", atsTagListener,2);
313314
}
314315
}
315316
});
316317
}else{
317-
handlerForAtsTagListener("You are not connected with the server.", atsTagListener, 2);
318+
handlerForAtsTagListener("You are not connected with the server.", "", atsTagListener, 2);
318319
}
319320
}catch (Exception e){
320-
handlerForAtsTagListener("Exception: "+e.getMessage(), atsTagListener, 2);
321+
handlerForAtsTagListener("Exception: "+e.getMessage(), "", atsTagListener, 2);
321322
}
322323
}
323324

@@ -471,7 +472,7 @@ public void run() {
471472
}
472473

473474

474-
private static void handlerForAtsTagListener(final String message , final AtsTagListener atsTagListener , int type){
475+
private static void handlerForAtsTagListener(final String message, final String driverAtsid , final AtsTagListener atsTagListener , int type){
475476
if(type == 1){ // on success
476477
mHandler.post(new Runnable() {
477478
@Override
@@ -498,7 +499,7 @@ public void run() {
498499
location.setLongitude(Double.parseDouble(""+splitter[1]));
499500
location.setAccuracy(Float.parseFloat(""+splitter[2]));
500501
location.setBearing(Float.parseFloat(""+splitter[3]));
501-
atsTagListener.onAdd(location);
502+
atsTagListener.onAdd(location, ""+driverAtsid);
502503
}
503504
});
504505

@@ -512,7 +513,7 @@ public void run() {
512513
location.setLongitude(Double.parseDouble(""+splitter[1]));
513514
location.setAccuracy(Float.parseFloat(""+splitter[2]));
514515
location.setBearing(Float.parseFloat(""+splitter[3]));
515-
atsTagListener.onChange(location);
516+
atsTagListener.onChange(location, ""+driverAtsid);
516517
}
517518
});
518519

@@ -526,7 +527,7 @@ public void run() {
526527
location.setLongitude(Double.parseDouble(""+splitter[1]));
527528
location.setAccuracy(Float.parseFloat(""+splitter[2]));
528529
location.setBearing(Float.parseFloat(""+splitter[3]));
529-
atsTagListener.onRemove(location);
530+
atsTagListener.onRemove(location, ""+driverAtsid);
530531
}
531532
});
532533

ats-sdk/src/main/java/com/apporioinfolabs/ats_sdk/models/ModelEmitterbyTagData.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ public class ModelEmitterbyTagData {
44

55
/**
66
* type : CHANGE
7-
* data : 28.4123607_77.0440434_26.633_239.1835_1584084003151_18_1_AAAA_5e4e21de577d8b1accd4f76f
7+
* data : 28.4123757_77.0440817_17.54_0.0_1584094056507_6_1_AAAA_5e4e21de577d8b1accd4f76f
8+
* ats_id : f3254a3671d22b88_com.apporio.secondapp
89
*/
910

1011
private String type;
1112
private String data;
13+
private String ats_id;
1214

1315
public String getType() {
1416
return type;
@@ -25,4 +27,12 @@ public String getData() {
2527
public void setData(String data) {
2628
this.data = data;
2729
}
30+
31+
public String getAts_id() {
32+
return ats_id;
33+
}
34+
35+
public void setAts_id(String ats_id) {
36+
this.ats_id = ats_id;
37+
}
2838
}

0 commit comments

Comments
 (0)