-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#25 use wrapper object and copy all relevant fields
- Loading branch information
ostrya
committed
Sep 9, 2020
1 parent
a31eb7b
commit 5cc371d
Showing
8 changed files
with
100 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/org/ostrya/presencepublisher/beacon/PresenceBeacon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.ostrya.presencepublisher.beacon; | ||
|
||
import org.altbeacon.beacon.Beacon; | ||
|
||
import java.util.Objects; | ||
|
||
public class PresenceBeacon { | ||
private static final String BEACON_FORMAT = "%s (%s)%n%s"; | ||
|
||
private final String address; | ||
private final String name; | ||
private final String type; | ||
private final int rssi; | ||
private final double distance; | ||
|
||
public PresenceBeacon(Beacon beacon) { | ||
Objects.requireNonNull(beacon); | ||
address = Objects.requireNonNull(beacon.getBluetoothAddress()); | ||
if (beacon.getBluetoothName() != null) { | ||
name = beacon.getBluetoothName(); | ||
} else { | ||
name = address; | ||
} | ||
type = Objects.requireNonNull(beacon.getParserIdentifier()); | ||
rssi = beacon.getRssi(); | ||
distance = beacon.getDistance(); | ||
} | ||
|
||
public static String beaconIdToAddress(String beaconId) { | ||
return beaconId.substring(beaconId.lastIndexOf('\n') + 1); | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public int getRssi() { | ||
return rssi; | ||
} | ||
|
||
public double getDistance() { | ||
return distance; | ||
} | ||
|
||
public String toBeaconId() { | ||
return String.format(BEACON_FORMAT, name, type, address); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
app/src/main/java/org/ostrya/presencepublisher/ui/util/BeaconIdHelper.java
This file was deleted.
Oops, something went wrong.