Search in sources :

Example 11 with BackendlessFault

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

the class Messaging method pollMessages.

protected void pollMessages(String channelName, String subscriptionId, final AsyncCallback<List<Message>> responder) {
    try {
        checkChannelName(channelName);
        if (subscriptionId == null)
            throw new IllegalArgumentException(ExceptionMessage.NULL_SUBSCRIPTION_ID);
        Invoker.invokeAsync(MESSAGING_MANAGER_SERVER_ALIAS, "pollMessages", new Object[] { channelName, subscriptionId }, new AsyncCallback<Object[]>() {

            @Override
            public void handleResponse(Object[] response) {
                if (responder != null)
                    responder.handleResponse(response.length == 0 ? new ArrayList<Message>() : Arrays.asList((Message[]) response));
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                if (responder != null)
                    responder.handleFault(fault);
            }
        });
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : ExceptionMessage(com.backendless.exceptions.ExceptionMessage) Message(com.backendless.messaging.Message) ArrayList(java.util.ArrayList) BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 12 with BackendlessFault

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

the class Messaging method publish.

public void publish(String channelName, Object message, PublishOptions publishOptions, DeliveryOptions deliveryOptions, final AsyncCallback<MessageStatus> responder) {
    try {
        channelName = getCheckedChannelName(channelName);
        if (message == null)
            throw new IllegalArgumentException(ExceptionMessage.NULL_MESSAGE);
        Invoker.invokeAsync(MESSAGING_MANAGER_SERVER_ALIAS, "publish", new Object[] { channelName, message, publishOptions, deliveryOptions }, responder);
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 13 with BackendlessFault

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

the class Messaging method subscribe.

public void subscribe(final String channelName, final AsyncCallback<List<Message>> subscriptionResponder, SubscriptionOptions subscriptionOptions, final int pollingInterval, final AsyncCallback<Subscription> responder) {
    try {
        checkChannelName(channelName);
        if (pollingInterval < 0)
            throw new IllegalArgumentException(ExceptionMessage.WRONG_POLLING_INTERVAL);
        subscribeForPollingAccess(channelName, subscriptionOptions, new AsyncCallback<String>() {

            @Override
            public void handleResponse(String subscriptionId) {
                Subscription subscription = new Subscription();
                subscription.setChannelName(channelName);
                subscription.setSubscriptionId(subscriptionId);
                if (pollingInterval != 0)
                    subscription.setPollingInterval(pollingInterval);
                subscription.onSubscribe(subscriptionResponder);
                if (responder != null)
                    responder.handleResponse(subscription);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                if (responder != null)
                    responder.handleFault(fault);
            }
        });
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 14 with BackendlessFault

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

the class Messaging method registerDeviceOnServer.

public void registerDeviceOnServer(String deviceToken, final List<String> channels, final long expiration, final AsyncCallback<String> responder) {
    try {
        if (deviceToken == null)
            throw new IllegalArgumentException(ExceptionMessage.NULL_DEVICE_TOKEN);
        DeviceRegistration deviceRegistration = new DeviceRegistration();
        deviceRegistration.setDeviceId(DEVICE_ID);
        deviceRegistration.setOs(OS);
        deviceRegistration.setOsVersion(OS_VERSION);
        deviceRegistration.setDeviceToken(deviceToken);
        deviceRegistration.setChannels(channels);
        if (expiration != 0)
            deviceRegistration.setExpiration(new Date(expiration));
        Invoker.invokeAsync(DEVICE_REGISTRATION_MANAGER_SERVER_ALIAS, "registerDevice", new Object[] { deviceRegistration }, new AsyncCallback<String>() {

            @Override
            public void handleResponse(String response) {
                if (responder != null)
                    responder.handleResponse(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                if (responder != null)
                    responder.handleFault(fault);
            }
        });
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : Date(java.util.Date) BackendlessFault(com.backendless.exceptions.BackendlessFault)

Example 15 with BackendlessFault

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

the class Persistence method remove.

protected <E> void remove(final E entity, final AsyncCallback<Long> responder) {
    try {
        if (entity == null)
            throw new IllegalArgumentException(ExceptionMessage.NULL_ENTITY);
        AsyncCallback<Object> removalCallback = new AsyncCallback<Object>() {

            @Override
            public void handleResponse(Object response) {
                FootprintsManager.getInstance().Inner.removeFootprintForObject(BackendlessSerializer.serializeToMap(entity), entity);
                if (responder == null)
                    return;
                responder.handleResponse(((Number) response).longValue());
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                if (responder != null)
                    responder.handleFault(fault);
            }
        };
        Map<String, Object> entityMap = BackendlessSerializer.serializeToMap(entity);
        FootprintsManager.getInstance().Inner.putMissingPropsToEntityMap(entity, entityMap);
        Invoker.invokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "remove", new Object[] { BackendlessSerializer.getSimpleName(entity.getClass()), entityMap }, removalCallback);
    } catch (Throwable e) {
        if (responder != null)
            responder.handleFault(new BackendlessFault(e));
    }
}
Also used : AsyncCallback(com.backendless.async.callback.AsyncCallback) 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