Search in sources :

Example 1 with CollectionAdaptingPolicy

use of com.backendless.core.responder.policy.CollectionAdaptingPolicy in project Android-SDK by Backendless.

the class Geo method getPoints.

public void getPoints(final BackendlessGeoQuery geoQuery, final AsyncCallback<List<GeoPoint>> responder) {
    try {
        checkGeoQuery(geoQuery);
        CollectionAdaptingPolicy<GeoPoint> adaptingPolicy = new CollectionAdaptingPolicy<GeoPoint>();
        Invoker.invokeAsync(GEO_MANAGER_SERVER_ALIAS, "getPoints", new Object[] { geoQuery }, new AsyncCallback<List<GeoPoint>>() {

            @Override
            public void handleResponse(List<GeoPoint> response) {
                if (geoQuery.getDpp() != null && geoQuery.getDpp() > 0)
                    setReferenceToCluster(response, geoQuery);
                if (responder != null)
                    responder.handleResponse(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                responder.handleFault(fault);
            }
        }, new AdaptingResponder<GeoPoint>(GeoPoint.class, adaptingPolicy));
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : CollectionAdaptingPolicy(com.backendless.core.responder.policy.CollectionAdaptingPolicy) BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 2 with CollectionAdaptingPolicy

use of com.backendless.core.responder.policy.CollectionAdaptingPolicy in project Android-SDK by Backendless.

the class Geo method getPoints.

public void getPoints(final GeoCluster geoCluster, final AsyncCallback<List<GeoPoint>> responder) {
    try {
        CollectionAdaptingPolicy<GeoPoint> adaptingPolicy = new CollectionAdaptingPolicy<GeoPoint>();
        Invoker.invokeAsync(GEO_MANAGER_SERVER_ALIAS, "loadGeoPoints", new Object[] { geoCluster.getObjectId(), geoCluster.getGeoQuery() }, new AsyncCallback<List<GeoPoint>>() {

            @Override
            public void handleResponse(List<GeoPoint> response) {
                if (responder != null)
                    responder.handleResponse(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                if (responder != null)
                    responder.handleFault(fault);
            }
        }, new AdaptingResponder<GeoPoint>(GeoPoint.class, adaptingPolicy));
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : CollectionAdaptingPolicy(com.backendless.core.responder.policy.CollectionAdaptingPolicy) BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 3 with CollectionAdaptingPolicy

use of com.backendless.core.responder.policy.CollectionAdaptingPolicy in project Android-SDK by Backendless.

the class Geo method relativeFind.

public void relativeFind(final BackendlessGeoQuery geoQuery, final AsyncCallback<List<SearchMatchesResult>> responder) {
    try {
        if (geoQuery == null)
            throw new IllegalArgumentException(ExceptionMessage.NULL_GEO_QUERY);
        if (geoQuery.getRelativeFindMetadata().isEmpty() || geoQuery.getRelativeFindPercentThreshold() == 0)
            throw new IllegalArgumentException(ExceptionMessage.INCONSISTENT_GEO_RELATIVE);
        CollectionAdaptingPolicy<SearchMatchesResult> adaptingPolicy = new CollectionAdaptingPolicy<>();
        Invoker.invokeAsync(GEO_MANAGER_SERVER_ALIAS, "relativeFind", new Object[] { geoQuery }, new AsyncCallback<List<SearchMatchesResult>>() {

            @Override
            public void handleResponse(List<SearchMatchesResult> response) {
                if (responder != null)
                    responder.handleResponse(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                if (responder != null)
                    responder.handleFault(fault);
            }
        }, new AdaptingResponder<>(SearchMatchesResult.class, adaptingPolicy));
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : CollectionAdaptingPolicy(com.backendless.core.responder.policy.CollectionAdaptingPolicy) BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 4 with CollectionAdaptingPolicy

use of com.backendless.core.responder.policy.CollectionAdaptingPolicy in project Android-SDK by Backendless.

the class Geo method getPoints.

public void getPoints(final String geofenceName, final BackendlessGeoQuery query, final AsyncCallback<List<GeoPoint>> responder) {
    try {
        checkGeoQuery(query);
        CollectionAdaptingPolicy<GeoPoint> adaptingPolicy = new CollectionAdaptingPolicy<>();
        Invoker.invokeAsync(GEO_MANAGER_SERVER_ALIAS, "getPoints", new Object[] { geofenceName, query }, new AsyncCallback<List<GeoPoint>>() {

            @Override
            public void handleResponse(List<GeoPoint> response) {
                if (responder != null)
                    responder.handleResponse(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                responder.handleFault(fault);
            }
        }, new AdaptingResponder<>(GeoPoint.class, adaptingPolicy));
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : CollectionAdaptingPolicy(com.backendless.core.responder.policy.CollectionAdaptingPolicy) BackendlessFault(com.backendless.exceptions.BackendlessFault)

Aggregations

CollectionAdaptingPolicy (com.backendless.core.responder.policy.CollectionAdaptingPolicy)4 BackendlessFault (com.backendless.exceptions.BackendlessFault)4