Search in sources :

Example 6 with BackendlessFault

use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.

the class Cache method get.

public <T> void get(final String key, final AsyncCallback<T> callback) {
    final Type asyncCallbackType = ReflectionUtil.getCallbackGenericType(callback);
    ThreadPoolService.getPoolExecutor().execute(new Runnable() {

        @Override
        public void run() {
            try {
                T result = (T) get(key, (Class) asyncCallbackType);
                ResponseCarrier.getInstance().deliverMessage(new AsyncMessage<T>(result, callback));
            } catch (BackendlessException e) {
                ResponseCarrier.getInstance().deliverMessage(new AsyncMessage<T>(new BackendlessFault(e), callback));
            }
        }
    });
}
Also used : BackendlessException(com.backendless.exceptions.BackendlessException) IAdaptingType(weborb.types.IAdaptingType) Type(java.lang.reflect.Type) AsyncMessage(com.backendless.async.message.AsyncMessage) BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 7 with BackendlessFault

use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.

the class Geo method getGeopointCount.

public void getGeopointCount(BackendlessGeoQuery query, AsyncCallback<Integer> responder) {
    try {
        Object[] args = new Object[] { query };
        Invoker.invokeAsync(GEO_MANAGER_SERVER_ALIAS, "count", args, responder);
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 8 with BackendlessFault

use of com.backendless.exceptions.BackendlessFault 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 9 with BackendlessFault

use of com.backendless.exceptions.BackendlessFault in project Android-SDK by Backendless.

the class Geo method savePoint.

public void savePoint(GeoPoint geoPoint, AsyncCallback<GeoPoint> responder) {
    try {
        if (geoPoint == null)
            throw new IllegalArgumentException(ExceptionMessage.NULL_GEOPOINT);
        checkCoordinates(geoPoint.getLatitude(), geoPoint.getLongitude());
        String remoteMethod = geoPoint.getObjectId() == null ? "addPoint" : "updatePoint";
        Invoker.invokeAsync(GEO_MANAGER_SERVER_ALIAS, remoteMethod, new Object[] { geoPoint }, responder);
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 10 with BackendlessFault

use of com.backendless.exceptions.BackendlessFault 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)

Aggregations

BackendlessFault (com.backendless.exceptions.BackendlessFault)65 AnonymousObject (weborb.reader.AnonymousObject)15 NamedObject (weborb.reader.NamedObject)15 AsyncCallback (com.backendless.async.callback.AsyncCallback)11 Intent (android.content.Intent)10 View (android.view.View)10 TextView (android.widget.TextView)6 BackendlessCollection (com.backendless.BackendlessCollection)6 List (java.util.List)6 Typeface (android.graphics.Typeface)5 BackendlessDataQuery (com.backendless.persistence.BackendlessDataQuery)5 EditText (android.widget.EditText)4 CollectionAdaptingPolicy (com.backendless.core.responder.policy.CollectionAdaptingPolicy)4 BackendlessFile (com.backendless.files.BackendlessFile)4 ArrayList (java.util.ArrayList)4 Button (android.widget.Button)3 GeoPoint (com.backendless.geo.GeoPoint)3 ProgressDialog (android.app.ProgressDialog)2 DialogInterface (android.content.DialogInterface)2 Bitmap (android.graphics.Bitmap)2