QuickBlox / quickblox-android-sdk-releases

This repository contains binary distributions of Android products released by QuickBlox.
BSD 3-Clause "New" or "Revised" License
31 stars 15 forks source link

"OutOfBoundsException" when retrieving "Location" custom data from "QBDialog" #3

Closed regmoraes closed 8 years ago

regmoraes commented 8 years ago

I have a method that creates a "QBDialog" and attaches a "Location" custom data to it:

List<Double> myLocation = new ArrayList<>();
        myLocation.add(locationManager.getLastLocation().getLatitude());
        myLocation.add(locationManager.getLastLocation().getLongitude());

        QBDialogCustomData data = new QBDialogCustomData("JsRoom");
        data.putLocation("room_location", myLocation);

        final QBDialog qbDialog = new QBDialog();
        qbDialog.setName("Test");
        qbDialog.setType(QBDialogType.PUBLIC_GROUP);
        qbDialog.setCustomData(data);

        try {

            subscriber.onNext(
                    QBChatService
                            .getInstance()
                            .getGroupChatManager()
                            .createDialog(qbDialog));

            subscriber.onCompleted();

        } catch (QBResponseException e) {

            subscriber.onError(e);
        }

But when I try to retrieve the Location by calling room.getCustomData().getLocation("room_location") I get this error even if the getLocation() returns a non null response:

java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
 at java.util.ArrayList.set(ArrayList.java:481)
 at com.quickblox.core.model.QBBaseCustomObject.getLocation(QBBaseCustomObject.java:291)

Maybe it's something wrong with the Quickblox SDK during creation of the Array that returns the location values.

soulfly commented 8 years ago

Could you please also post here REST logs from logcat We need to check what you are getting from the backend in a response

soulfly commented 8 years ago

Hi there,

can you try this patch https://sdk.quickblox.com/android/artifacts/artifacts_customdata_location_fix.zip

we found one strange thing in the behaviour and made the patch

soulfly commented 8 years ago

Fixed with Android 2.5.2 http://quickblox.com/developers/Android#Framework_changelog