From b42b8a08b2df4fb9bcd0be879f62ece6130b79a5 Mon Sep 17 00:00:00 2001 From: "mohit.trivedi" Date: Tue, 2 Apr 2019 16:31:46 +0530 Subject: [PATCH] Minor changes like add data listener --- README.md | 55 +++++++++---------- .../beaconwrapper/BLEBeaconWrapper.java | 21 ++----- .../beaconwrapper/BleBeaconListener.java | 5 +- 3 files changed, 34 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index f64593a..6094903 100644 --- a/README.md +++ b/README.md @@ -27,32 +27,31 @@ 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"); bleBeaconWrapper.getBeaconData(url, - DNAEntity.class, headerMap, 3000, new BleBeaconListener() { - @Override - public void onBeaconDataResult(List list) { - Log.d("BLE-RESPONSE", "Total : " + list.size()); - for (int i = 0; i < list.size(); i++) { - Log.d("BLE-RESPONSE", "Inside : " + list.get(i).getBeaconDetail().getBluetoothAddress() - + " | Accuracy : "+list.get(i).getBeaconDetail().getAccuracy()); - } - - } - - @Override - public void onError(String errorMsg) { - Log.d("BLE-RESPONSE", "" + errorMsg); - } - - @Override - public void onShowProgress() { - Log.d("BLE-RESPONSE", "onShowProgress"); - } - - @Override - public void onParsableDataResult(List parsableData) { - Log.d("BLE-RESPONSE", "onParsableDataResult"); - //Your json parsable data list - } - }); - + DNAEntity.class, headerMap, 3000, new BleBeaconListener() { + @Override + public void onBeaconDataResult(List list) { + Log.d("BLE-RESPONSE", "Total : " + list.size()); + for (int i = 0; i < list.size(); i++) { + Log.d("BLE-RESPONSE", "Inside : " + list.get(i).getBeaconDetail().getBluetoothAddress() + + " | Accuracy : "+list.get(i).getBeaconDetail().getAccuracy()); + } + + } + + @Override + public void onError(String errorMsg) { + Log.d("BLE-RESPONSE", "" + errorMsg); + } + + @Override + public void onShowProgress() { + Log.d("BLE-RESPONSE", "onShowProgress"); + } + + @Override + public void onParsableDataResult(List parsableData) { + Log.d("BLE-RESPONSE", "onParsableDataResult"); + //Your json parsable data list + } + }); diff --git a/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BLEBeaconWrapper.java b/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BLEBeaconWrapper.java index 333c26a..c0b76cf 100644 --- a/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BLEBeaconWrapper.java +++ b/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BLEBeaconWrapper.java @@ -2,15 +2,16 @@ import android.app.Activity; - import com.androidblebeaconwrapperlib.beacon.BeaconHelper; import com.androidblebeaconwrapperlib.beacon.BeaconResultEntity; import com.androidblebeaconwrapperlib.beacon.BeaconResultListener; +import com.androidblebeaconwrapperlib.beaconwrapper.BleBeaconListener; import com.androidblebeaconwrapperlib.network.NetworkManager; import com.androidblebeaconwrapperlib.network.RequestCallBackListener; import com.androidblebeaconwrapperlib.parse.FilterListener; import com.androidblebeaconwrapperlib.parse.ParserListClass; + import java.util.List; import java.util.Map; @@ -25,7 +26,6 @@ public class BLEBeaconWrapper { private long timeInterval; private Class t; private BleBeaconListener tBleBeaconListener; - private List parsableList; public BLEBeaconWrapper(Activity context) { @@ -47,14 +47,6 @@ public void getBeaconData(String url, Class t, Map headerData } - public void getBeaconData(String json, Class t, long timeInterval, - BleBeaconListener tBleBeaconListener) { - this.t = t; - this.timeInterval = timeInterval; - this.tBleBeaconListener = tBleBeaconListener; - parseClassFields(json); - } - public void getBeaconData(List list, long timeInterval, BleBeaconListener tBleBeaconListener) { this.timeInterval = timeInterval; @@ -72,7 +64,6 @@ public void beforeCallBack() { @Override public void onResponse(String responseString) { - tBleBeaconListener.onDismissProgress(); parseClassFields(responseString); } @@ -88,7 +79,7 @@ private void parseClassFields(String responseString) { parserListClass.parseData(t, responseString, new FilterListener() { @Override public void onResponse(List filteredData) { - BLEBeaconWrapper.this.parsableList = filteredData; + tBleBeaconListener.onParsableDataResult(filteredData); beaconWrapperOperation(filteredData); } @@ -99,10 +90,6 @@ public void onError(String errorMsg) { }); } - public List getParsableData() { - return this.parsableList; - } - public void stopBeaconUpdates() { beaconHelper.stopBeaconUpdates(); } @@ -111,7 +98,7 @@ private void beaconWrapperOperation(List filteredData) { beaconHelper.startBeaconUpdates(filteredData, timeInterval, new BeaconResultListener() { @Override public void onResult(List beaconResultEntities) { - tBleBeaconListener.onResult(beaconResultEntities); + tBleBeaconListener.onBeaconDataResult(beaconResultEntities); } @Override diff --git a/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BleBeaconListener.java b/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BleBeaconListener.java index f8fcf46..ad08a1a 100644 --- a/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BleBeaconListener.java +++ b/androidblebeaconwrapperlib/src/main/java/com/androidblebeaconwrapperlib/beaconwrapper/BleBeaconListener.java @@ -7,12 +7,13 @@ public interface BleBeaconListener { - void onResult(List beaconResultEntities); + void onBeaconDataResult(List beaconResultEntities); void onError(String errorMsg); void onShowProgress(); - void onDismissProgress(); + void onParsableDataResult(List parsableData); + }