Skip to content

Commit b42b8a0

Browse files
committed
Minor changes like add data listener
1 parent 823a3fb commit b42b8a0

3 files changed

Lines changed: 34 additions & 47 deletions

File tree

README.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,31 @@
2727
headerMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36");
2828

2929
bleBeaconWrapper.getBeaconData(url,
30-
DNAEntity.class, headerMap, 3000, new BleBeaconListener<DNAEntity>() {
31-
@Override
32-
public void onBeaconDataResult(List<BeaconResultEntity> list) {
33-
Log.d("BLE-RESPONSE", "Total : " + list.size());
34-
for (int i = 0; i < list.size(); i++) {
35-
Log.d("BLE-RESPONSE", "Inside : " + list.get(i).getBeaconDetail().getBluetoothAddress()
36-
+ " | Accuracy : "+list.get(i).getBeaconDetail().getAccuracy());
37-
}
38-
39-
}
40-
41-
@Override
42-
public void onError(String errorMsg) {
43-
Log.d("BLE-RESPONSE", "" + errorMsg);
44-
}
45-
46-
@Override
47-
public void onShowProgress() {
48-
Log.d("BLE-RESPONSE", "onShowProgress");
49-
}
50-
51-
@Override
52-
public void onParsableDataResult(List<DNAEntity> parsableData) {
53-
Log.d("BLE-RESPONSE", "onParsableDataResult");
54-
//Your json parsable data list
55-
}
56-
});
57-
30+
DNAEntity.class, headerMap, 3000, new BleBeaconListener<DNAEntity>() {
31+
@Override
32+
public void onBeaconDataResult(List<BeaconResultEntity> list) {
33+
Log.d("BLE-RESPONSE", "Total : " + list.size());
34+
for (int i = 0; i < list.size(); i++) {
35+
Log.d("BLE-RESPONSE", "Inside : " + list.get(i).getBeaconDetail().getBluetoothAddress()
36+
+ " | Accuracy : "+list.get(i).getBeaconDetail().getAccuracy());
37+
}
38+
39+
}
40+
41+
@Override
42+
public void onError(String errorMsg) {
43+
Log.d("BLE-RESPONSE", "" + errorMsg);
44+
}
45+
46+
@Override
47+
public void onShowProgress() {
48+
Log.d("BLE-RESPONSE", "onShowProgress");
49+
}
50+
51+
@Override
52+
public void onParsableDataResult(List<DNAEntity> parsableData) {
53+
Log.d("BLE-RESPONSE", "onParsableDataResult");
54+
//Your json parsable data list
55+
}
56+
});
5857
</pre>

androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BLEBeaconWrapper.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
import android.app.Activity;
44

5-
65
import com.androidblebeaconwrapperlib.beacon.BeaconHelper;
76
import com.androidblebeaconwrapperlib.beacon.BeaconResultEntity;
87
import com.androidblebeaconwrapperlib.beacon.BeaconResultListener;
8+
import com.androidblebeaconwrapperlib.beaconwrapper.BleBeaconListener;
99
import com.androidblebeaconwrapperlib.network.NetworkManager;
1010
import com.androidblebeaconwrapperlib.network.RequestCallBackListener;
1111
import com.androidblebeaconwrapperlib.parse.FilterListener;
1212
import com.androidblebeaconwrapperlib.parse.ParserListClass;
1313

14+
1415
import java.util.List;
1516
import java.util.Map;
1617

@@ -25,7 +26,6 @@ public class BLEBeaconWrapper<T> {
2526
private long timeInterval;
2627
private Class<T> t;
2728
private BleBeaconListener<T> tBleBeaconListener;
28-
private List<T> parsableList;
2929

3030

3131
public BLEBeaconWrapper(Activity context) {
@@ -47,14 +47,6 @@ public void getBeaconData(String url, Class<T> t, Map<String, String> headerData
4747

4848
}
4949

50-
public void getBeaconData(String json, Class<T> t, long timeInterval,
51-
BleBeaconListener<T> tBleBeaconListener) {
52-
this.t = t;
53-
this.timeInterval = timeInterval;
54-
this.tBleBeaconListener = tBleBeaconListener;
55-
parseClassFields(json);
56-
}
57-
5850
public void getBeaconData(List<T> list, long timeInterval,
5951
BleBeaconListener<T> tBleBeaconListener) {
6052
this.timeInterval = timeInterval;
@@ -72,7 +64,6 @@ public void beforeCallBack() {
7264

7365
@Override
7466
public void onResponse(String responseString) {
75-
tBleBeaconListener.onDismissProgress();
7667
parseClassFields(responseString);
7768
}
7869

@@ -88,7 +79,7 @@ private void parseClassFields(String responseString) {
8879
parserListClass.parseData(t, responseString, new FilterListener<T>() {
8980
@Override
9081
public void onResponse(List<T> filteredData) {
91-
BLEBeaconWrapper.this.parsableList = filteredData;
82+
tBleBeaconListener.onParsableDataResult(filteredData);
9283
beaconWrapperOperation(filteredData);
9384
}
9485

@@ -99,10 +90,6 @@ public void onError(String errorMsg) {
9990
});
10091
}
10192

102-
public List<T> getParsableData() {
103-
return this.parsableList;
104-
}
105-
10693
public void stopBeaconUpdates() {
10794
beaconHelper.stopBeaconUpdates();
10895
}
@@ -111,7 +98,7 @@ private void beaconWrapperOperation(List<T> filteredData) {
11198
beaconHelper.startBeaconUpdates(filteredData, timeInterval, new BeaconResultListener() {
11299
@Override
113100
public void onResult(List<BeaconResultEntity> beaconResultEntities) {
114-
tBleBeaconListener.onResult(beaconResultEntities);
101+
tBleBeaconListener.onBeaconDataResult(beaconResultEntities);
115102
}
116103

117104
@Override

androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BleBeaconListener.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
public interface BleBeaconListener<T> {
99

10-
void onResult(List<BeaconResultEntity> beaconResultEntities);
10+
void onBeaconDataResult(List<BeaconResultEntity> beaconResultEntities);
1111

1212
void onError(String errorMsg);
1313

1414
void onShowProgress();
1515

16-
void onDismissProgress();
16+
void onParsableDataResult(List<T> parsableData);
17+
1718

1819
}

0 commit comments

Comments
 (0)