Java Code Examples for io.particle.android.sdk.utils.Funcy#findFirstMatch()

The following examples show how to use io.particle.android.sdk.utils.Funcy#findFirstMatch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnsureSoftApNotVisible.java    From particle-android with Apache License 2.0 6 votes vote down vote up
private boolean isSoftApVisible() {
    List<SSID> scansPlusConnectedSsid = list();

    SSID currentlyConnected = wifiFacade.getCurrentlyConnectedSSID();
    if (currentlyConnected != null) {
        scansPlusConnectedSsid.add(currentlyConnected);
    }

    scansPlusConnectedSsid.addAll(
            Funcy.transformList(wifiFacade.getScanResults(),
                    Funcy.notNull(),
                    SSID::from)
    );

    log.d("scansPlusConnectedSsid: " + scansPlusConnectedSsid);
    log.d("Soft AP we're looking for: " + softApName);

    SSID firstMatch = Funcy.findFirstMatch(scansPlusConnectedSsid, matchesSoftApSSID);
    log.d("Matching SSID result: '" + firstMatch + "'");
    return firstMatch != null;
}
 
Example 2
Source File: EnsureSoftApNotVisible.java    From spark-setup-android with Apache License 2.0 6 votes vote down vote up
private boolean isSoftApVisible() {
    List<SSID> scansPlusConnectedSsid = list();

    SSID currentlyConnected = wifiFacade.getCurrentlyConnectedSSID();
    if (currentlyConnected != null) {
        scansPlusConnectedSsid.add(currentlyConnected);
    }

    scansPlusConnectedSsid.addAll(
            Funcy.transformList(wifiFacade.getScanResults(),
                    Funcy.notNull(),
                    SSID::from)
    );

    log.d("scansPlusConnectedSsid: " + scansPlusConnectedSsid);
    log.d("Soft AP we're looking for: " + softApName);

    SSID firstMatch = Funcy.findFirstMatch(scansPlusConnectedSsid, matchesSoftApSSID);
    log.d("Matching SSID result: '" + firstMatch + "'");
    return firstMatch != null;
}
 
Example 3
Source File: ParticleCloud.java    From spark-sdk-android with Apache License 2.0 5 votes vote down vote up
@WorkerThread
public boolean userOwnsDevice(@NonNull String deviceId) throws ParticleCloudException {
    String idLower = deviceId.toLowerCase();
    try {
        List<SimpleDevice> devices = mainApi.getDevices();
        SimpleDevice firstMatch = Funcy.findFirstMatch(devices,
                testTarget -> idLower.equals(testTarget.id.toLowerCase())
        );
        return firstMatch != null;
    } catch (RetrofitError error) {
        throw new ParticleCloudException(error);
    }
}