-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: loadWifiList and reScanAndLoadWifiList not returning a JSON arra…
…y but a string (#104) Co-authored-by: Elias Lecomte <elias.lecomte@inthepocket.com>
- Loading branch information
1 parent
4f76b75
commit 9dce618
Showing
5 changed files
with
57 additions
and
70 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
34 changes: 34 additions & 0 deletions
34
android/src/main/java/com/reactlibrary/mappers/WifiScanResultsMapper.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,34 @@ | ||
package com.reactlibrary.mappers; | ||
|
||
import android.net.wifi.ScanResult; | ||
|
||
import com.facebook.react.bridge.WritableArray; | ||
import com.facebook.react.bridge.WritableMap; | ||
import com.facebook.react.bridge.WritableNativeArray; | ||
import com.facebook.react.bridge.WritableNativeMap; | ||
|
||
import java.util.List; | ||
|
||
public class WifiScanResultsMapper { | ||
private WifiScanResultsMapper() { | ||
} | ||
|
||
public static WritableArray mapWifiScanResults(final List<ScanResult> scanResults) { | ||
final WritableArray wifiArray = new WritableNativeArray(); | ||
|
||
for (ScanResult result : scanResults) { | ||
final WritableMap wifiObject = new WritableNativeMap(); | ||
if (!result.SSID.equals("")) { | ||
wifiObject.putString("SSID", result.SSID); | ||
wifiObject.putString("BSSID", result.BSSID); | ||
wifiObject.putString("capabilities", result.capabilities); | ||
wifiObject.putInt("frequency", result.frequency); | ||
wifiObject.putInt("level", result.level); | ||
wifiObject.putDouble("timestamp", result.timestamp); | ||
wifiArray.pushMap(wifiObject); | ||
} | ||
} | ||
|
||
return wifiArray; | ||
} | ||
} |
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