Skip to content

Commit

Permalink
Minor changes like add data listener
Browse files Browse the repository at this point in the history
  • Loading branch information
MohitAndroid committed Apr 2, 2019
1 parent 823a3fb commit b42b8a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 47 deletions.
55 changes: 27 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<DNAEntity>() {
@Override
public void onBeaconDataResult(List<BeaconResultEntity> 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<DNAEntity> parsableData) {
Log.d("BLE-RESPONSE", "onParsableDataResult");
//Your json parsable data list
}
});

DNAEntity.class, headerMap, 3000, new BleBeaconListener<DNAEntity>() {
@Override
public void onBeaconDataResult(List<BeaconResultEntity> 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<DNAEntity> parsableData) {
Log.d("BLE-RESPONSE", "onParsableDataResult");
//Your json parsable data list
}
});
</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -25,7 +26,6 @@ public class BLEBeaconWrapper<T> {
private long timeInterval;
private Class<T> t;
private BleBeaconListener<T> tBleBeaconListener;
private List<T> parsableList;


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

}

public void getBeaconData(String json, Class<T> t, long timeInterval,
BleBeaconListener<T> tBleBeaconListener) {
this.t = t;
this.timeInterval = timeInterval;
this.tBleBeaconListener = tBleBeaconListener;
parseClassFields(json);
}

public void getBeaconData(List<T> list, long timeInterval,
BleBeaconListener<T> tBleBeaconListener) {
this.timeInterval = timeInterval;
Expand All @@ -72,7 +64,6 @@ public void beforeCallBack() {

@Override
public void onResponse(String responseString) {
tBleBeaconListener.onDismissProgress();
parseClassFields(responseString);
}

Expand All @@ -88,7 +79,7 @@ private void parseClassFields(String responseString) {
parserListClass.parseData(t, responseString, new FilterListener<T>() {
@Override
public void onResponse(List<T> filteredData) {
BLEBeaconWrapper.this.parsableList = filteredData;
tBleBeaconListener.onParsableDataResult(filteredData);
beaconWrapperOperation(filteredData);
}

Expand All @@ -99,10 +90,6 @@ public void onError(String errorMsg) {
});
}

public List<T> getParsableData() {
return this.parsableList;
}

public void stopBeaconUpdates() {
beaconHelper.stopBeaconUpdates();
}
Expand All @@ -111,7 +98,7 @@ private void beaconWrapperOperation(List<T> filteredData) {
beaconHelper.startBeaconUpdates(filteredData, timeInterval, new BeaconResultListener() {
@Override
public void onResult(List<BeaconResultEntity> beaconResultEntities) {
tBleBeaconListener.onResult(beaconResultEntities);
tBleBeaconListener.onBeaconDataResult(beaconResultEntities);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

public interface BleBeaconListener<T> {

void onResult(List<BeaconResultEntity> beaconResultEntities);
void onBeaconDataResult(List<BeaconResultEntity> beaconResultEntities);

void onError(String errorMsg);

void onShowProgress();

void onDismissProgress();
void onParsableDataResult(List<T> parsableData);


}

0 comments on commit b42b8a0

Please sign in to comment.