2017-09-14 120 views
0

我第一次使用quick-blox並能夠將數據提交給它的服務器。我已經用波紋管代碼中創建自定義對象的字段: -從快速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 { 
       } 
      } 

現在我想要從快速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

這個答案已經很老了,爲獲取自定義的數據,當前用戶只需使用下面的代碼:

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