androidquickbloxquickblox-android

Fetch data from quick blox custom objects


i am using quick-blox for the first time and able to submit data to it's server. i have created custom object fields by using bellow code :-

QBCustomObject qbCustomObject = QBCustomObjectsUtils.createCustomObject(licenseNumber, carModel, carColor, stateName, stateCodeLast[0], "NO");
        Performer<QBCustomObject> performer = QBCustomObjects.createObject(qbCustomObject);
        rx.Observable<QBCustomObject> observable =
                performer.convertTo(RxJavaPerformProcessor.INSTANCE);

        observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<QBCustomObject>() {
            @Override
            public void onCompleted() {
                AppUtils.dismissProgressDialog();
                Toaster.shortToast("Done");
                ((Activity) mContext).finish();
            }

            @Override
            public void onError(Throwable e) {
                if (QBCustomObjectsUtils.checkQBException(e)) {
                    AppUtils.dismissProgressDialog();
                    Toast.makeText(mContext, "Something went wrong !!!", Toast.LENGTH_SHORT).show();
                } else {
                }
            }

Now i want to retrieve data from Quick blox custom object class but i am not finding any way to achieve that , i do have found one link :-

How to retrieve related records on Quickblox custom objects?

But QBCustomObjectRequestBuilder is not working in my code do i need to add any additional dependency for this ?

Dependecies i am using :-

compile "com.quickblox:quickblox-android-sdk-extensions:3.3.1"
   compile "com.quickblox:quickblox-android-sdk-customobjects:3.3.1"
   compile 'com.quickblox:quickblox-android-sdk-chat:3.3.1'
   compile 'com.quickblox:quickblox-android-sdk-content:3.3.1'

Please suggest me some way to fetch data from Custom objects

Thanks


Solution

  • That answer is very old, for getting custom data for current user just use next code:

    QBRequestGetBuilder requestGetBuilder = new QBRequestGetBuilder();
    requestGetBuilder.setLimit(50);
    //set other parameters if need
    
    Performer<ArrayList<QBCustomObject>> performer = QBCustomObjects.getObjects(Consts.CLASS_NAME, requestGetBuilder);
    Observable<ArrayList<QBCustomObject>> observable = performer.convertTo(RxJavaPerformProcessor.INSTANCE);
    
    observable.subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<ArrayList<QBCustomObject>>() {
                @Override
                public void onCompleted() {
                }
    
                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, "onError " + e.getMessage());
                }
    
                @Override
                public void onNext(ArrayList<QBCustomObject> qbCustomObjects) {
                    //qbCustomObjects - objects, loaded from server
                    Log.i(TAG, "data loaded success, got " + qbCustomObjects.size() + " items");
                }
            });