从 quick blox 自定义对象中获取数据
Fetch data from quick blox custom objects
我是第一次使用 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 自定义对象 class 中检索数据,但我没有找到任何方法来实现这一点,我确实找到了一个 link :-
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'
请建议我一些从自定义对象中获取数据的方法
谢谢
那个答案很旧,要为当前用户获取自定义数据,只需使用下一个代码:
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");
}
});
我是第一次使用 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 自定义对象 class 中检索数据,但我没有找到任何方法来实现这一点,我确实找到了一个 link :-
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'
请建议我一些从自定义对象中获取数据的方法
谢谢
那个答案很旧,要为当前用户获取自定义数据,只需使用下一个代码:
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");
}
});