从快速blox自定义对象中获取数据

时间:2017-09-14 14:44:06

标签: android quickblox quickblox-android

我第一次使用quick-blox并能够将数据提交给它的服务器。我使用下面的代码创建了自定义对象字段: -

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 {
                }
            }

现在我想从Quick blox自定义对象类中检索数据,但我找不到任何方法来实现这一点,我确实找到了一个链接: -

How to retrieve related records on Quickblox custom objects?

QBCustomObjectRequestBuilder 在我的代码中不起作用我是否需要为此添加任何其他依赖项?

我正在使用的家属: -

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'

请建议我从自定义对象中获取数据的方法

由于

1 个答案:

答案 0 :(得分:1)

答案很老,为当前用户获取自定义数据只需使用下一个代码:

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");
            }
        });