Skip to content

Commit 368a644

Browse files
committed
-revert previous changes
1 parent eb00581 commit 368a644

5 files changed

Lines changed: 23 additions & 47 deletions

File tree

androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beacon/BeaconHelper.java

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,9 @@ public class BeaconHelper<T> {
3333
private boolean isOnlyBeaconStuff;
3434
private List<IBeacon> iBeacons;
3535

36-
private BeaconHelper(Activity context) {
36+
public BeaconHelper(Activity context) {
3737
this.context = context;
38-
}
39-
40-
public static BeaconHelper getInstance(Activity context) {
41-
return new BeaconHelper(context);
42-
}
43-
44-
public void startBeaconUpdates(List<T> data, long timeInterval, BeaconResultListener beaconResultListener) {
45-
this.isOnlyBeaconStuff = false;
46-
this.beaconResultListener = beaconResultListener;
47-
this.data = data;
48-
49-
beaconKeySerializer = BeaconKeySerializer.getInstance();
38+
beaconKeySerializer = new BeaconKeySerializer();
5039
beaconResultEntities = new ArrayList<>();
5140
bluetoothManager =
5241
(BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
@@ -55,8 +44,15 @@ public void startBeaconUpdates(List<T> data, long timeInterval, BeaconResultList
5544
oldKeys = new ArrayList<>();
5645
newKeys = new ArrayList<>();
5746
mHandler = new Handler();
47+
iBeacons = new ArrayList<>();
5848
timer = new Timer();
49+
isOnlyBeaconStuff = false;
50+
}
5951

52+
public void startBeaconUpdates(List<T> data, long timeInterval, BeaconResultListener beaconResultListener) {
53+
this.isOnlyBeaconStuff = false;
54+
this.beaconResultListener = beaconResultListener;
55+
this.data = data;
6056
try {
6157
String validationErrorMsg = checkValidation();
6258
if (!TextUtils.isEmpty(validationErrorMsg)) {
@@ -92,14 +88,6 @@ public void run() {
9288
public void startBeaconUpdates(long timeInterval, BeaconListener beaconListener) {
9389
this.isOnlyBeaconStuff = true;
9490
this.beaconListener = beaconListener;
95-
96-
bluetoothManager =
97-
(BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
98-
mBluetoothAdapter = bluetoothManager.getAdapter();
99-
mHandler = new Handler();
100-
iBeacons = new ArrayList<>();
101-
timer = new Timer();
102-
10391
try {
10492
String validationErrorMsg = checkValidation();
10593
if (!TextUtils.isEmpty(validationErrorMsg)) {
@@ -190,7 +178,7 @@ public void run() {
190178
};
191179

192180
private void getOnlyBeaconData(IBeacon iBeacon) {
193-
try {
181+
try{
194182
boolean isAdd = true;
195183
for (int i = 0; i < iBeacons.size(); i++) {
196184
if (iBeacons.get(i).getBluetoothAddress().equals(iBeacon.getBluetoothAddress())) {
@@ -207,7 +195,7 @@ private void getOnlyBeaconData(IBeacon iBeacon) {
207195
if (isAdd) {
208196
iBeacons.add(iBeacon);
209197
}
210-
} catch (Exception e) {
198+
}catch (Exception e){
211199
displayBeaconError(e.getMessage());
212200
}
213201

@@ -261,7 +249,6 @@ private void getBeaconFilteredData(IBeacon iBeacon) {
261249
private void displayError(String msg) {
262250
this.beaconResultListener.onError(msg);
263251
}
264-
265252
private void displayBeaconError(String msg) {
266253
this.beaconListener.onError(msg);
267254
}

androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beacon/BeaconKeySerializer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99
public class BeaconKeySerializer {
1010
List<FieldTypeEntity> fieldTypeEntities;
1111

12-
private BeaconKeySerializer() {
12+
public BeaconKeySerializer() {
1313
fieldTypeEntities = new ArrayList<>();
1414
}
1515

16-
public static BeaconKeySerializer getInstance(){
17-
return new BeaconKeySerializer();
18-
}
19-
2016
public List<FieldTypeEntity> getBeaconAnnotationDetails(Object object) throws BeaconKeySerializeException {
2117
try {
2218
if (object == null) {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ public class BLEBeaconWrapper<T> {
3232

3333
public BLEBeaconWrapper(Activity context) {
3434
this.context = context;
35-
networkManager = NetworkManager.getInstance();
36-
parserListClass = ParserListClass.getInstance();
37-
beaconHelper = BeaconHelper.getInstance(this.context);
35+
networkManager = new NetworkManager();
36+
parserListClass = new ParserListClass();
37+
beaconHelper = new BeaconHelper(this.context);
3838
}
3939

40-
4140
public void getBeaconData(String url, Class<T> t, Map<String, String> headerData,
4241
long timeInterval, BleBeaconListener<T> tBleBeaconListener) {
4342

@@ -119,7 +118,7 @@ public void onError(String errorMsg) {
119118
}
120119

121120
private void BeaconOnlyWrapper() {
122-
beaconHelper.startBeaconUpdates(timeInterval, new BeaconListener() {
121+
beaconHelper.startBeaconUpdates( timeInterval, new BeaconListener() {
123122
@Override
124123
public void onResult(List<IBeacon> beaconResultEntities) {
125124
tBeaconListener.onResult(beaconResultEntities);

androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/network/NetworkManager.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
public class NetworkManager {
2121

2222

23-
private NetworkManager() {
24-
}
25-
26-
public static NetworkManager getInstance(){
27-
return new NetworkManager();
23+
public NetworkManager() {
2824
}
2925

3026
public void getRequest(String baseUrl, Map<String, String> headerData,

androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/parse/ParserListClass.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ public class ParserListClass<T> {
2626
private static final String JSON_OBJECT = "jsonObject";
2727
private static final String JSON_ARRAY = "jsonArray";
2828
private int count = 0;
29+
private List<T> parableObjects;
2930
private String jsonString;
3031
private FilterListener<T> filterListener;
3132

32-
private ParserListClass() {
33+
public ParserListClass() {
34+
rootFields = new ArrayList<>();
35+
count = 0;
36+
gson = new Gson();
37+
parableObjects = new ArrayList<>();
3338
}
3439

35-
public static ParserListClass getInstance(){
36-
return new ParserListClass();
37-
}
3840

3941
private void setFields() throws ParseFilterException {
40-
rootFields = new ArrayList<>();
4142
try {
4243
for (Field field : t.getDeclaredFields()) {
4344
field.setAccessible(true);
@@ -79,9 +80,6 @@ public void parseData(Class<T> t, String jsonString, FilterListener<T> filterLis
7980
this.filterListener = filterListener;
8081
this.jsonString = jsonString;
8182

82-
count = 0;
83-
gson = new Gson();
84-
8583
if (!TextUtils.isEmpty(this.jsonString) && this.t != null &&
8684
this.filterListener != null) {
8785
setFields();

0 commit comments

Comments
 (0)