Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中返回多个改装调用时更改UI_Android_Service_Retrofit - Fatal编程技术网

在Android中返回多个改装调用时更改UI

在Android中返回多个改装调用时更改UI,android,service,retrofit,Android,Service,Retrofit,我在Activity中启动了一项服务,在该服务中,我打了三个改装电话来发布数据。一切正常。但我想要两样东西 在所有三个调用返回时从服务中显示/隐藏ProgressBar 了解所有三个改装呼叫都已返回(成功或失败) 在第一部分中,我使用了LocalBroadcastManager。但对于第二部分,我不知道该用什么。我怎么知道所有三个改装电话都已返回?以下是我迄今为止所做工作的逻辑 void onHandleIntent(){ AppDB appDB = AppDB.getDatabase(MyS

我在Activity中启动了一项服务,在该服务中,我打了三个改装电话来发布数据。一切正常。但我想要两样东西

  • 在所有三个调用返回时从服务中显示/隐藏ProgressBar
  • 了解所有三个改装呼叫都已返回(成功或失败)
  • 在第一部分中,我使用了LocalBroadcastManager。但对于第二部分,我不知道该用什么。我怎么知道所有三个改装电话都已返回?以下是我迄今为止所做工作的逻辑

    void onHandleIntent(){
    
    AppDB appDB = AppDB.getDatabase(MyService.this);
        Dao policeDutyDao = appDB.getDao1();
    
        ArrayList<POJO1> pojo1Notes =
                (ArrayList<POJO1>)policeDutyDao.getPojo1NotesBySyncStatus("0");
        ArrayList<POJO1> pojo2Notes =
                (ArrayList<POJO2>)policeDutyDao.getPojo2NotesBySyncStatus("0");
    
        GeneralDataObject generalDataObject = new GeneralDataObject();
        generalDataObject.setPojo1Notes(pojo1Notes);
        generalDataObject.setPojo2Notes(pojo2Notes);
    
        sendDataToServer(generalDataObject);
    }
    
    void sendDataToServer(GeneralDataObject obj){
        sendPojo1Notes(obj.getPojo1Notes());
        sendPojo2Notes(obj.getPojo2Notes());
    }
    
    void sendPojo1Notes(){
           RetrofitDataService service = RetrofitClientInstance.getRetrofitInstance().create(RetrofitDataService.class);
           Call<Object> call = service.postPojoOneNote(inputParams);
           call.enqueue(new Callback<Object>() {
               @Override
               public void onResponse(Call<Object> call, final Response<Object> response) {
                   if(response != null) {
                       if (response.body() != null) {
                           if (response.isSuccessful()) {
                               Log.d(Constants.TAG, "onResponse: PostReview() ===== SUCCESS");
                           }
                       }
                   }
               }
               @Override
               public void onFailure(Call<Object> call, Throwable t) {
                   Log.d(Constants.TAG, "onResponse: PostReview()" + t.toString());
               }
           });
    }
    
    void sendPojo2Notes(){
           RetrofitDataService service = RetrofitClientInstance.getRetrofitInstance().create(RetrofitDataService.class);
           Call<Object> call = service.postPojoTwoNote(inputParams);
           call.enqueue(new Callback<Object>() {
               @Override
               public void onResponse(Call<Object> call, final Response<Object> response) {
                   if(response != null) {
                       if (response.body() != null) {
                           if (response.isSuccessful()) {
                               Log.d(Constants.TAG, "onResponse: PostReview() ===== SUCCESS");
                           }
                       }
                   }
               }
               @Override
               public void onFailure(Call<Object> call, Throwable t) {
                   Log.d(Constants.TAG, "onResponse: PostReview()" + t.toString());
               }
           });
    }
    
    void onHandleIntent(){
    AppDB AppDB=AppDB.getDatabase(MyService.this);
    Dao policydutyao=appDB.getDao1();
    ArrayList Pojo1注释=
    (ArrayList)policidutydao.getPojo1NotesBySyncStatus(“0”);
    ArrayList pojo2Notes酒店=
    (ArrayList)policidutydao.getPojo2NotesBySyncStatus(“0”);
    GeneralDataObject GeneralDataObject=新的GeneralDataObject();
    setPojo1Notes(pojo1Notes);
    generalDataObject.setPojo2Notes(pojo2Notes);
    sendDataToServer(generalDataObject);
    }
    void sendDataToServer(GeneralDataObject obj){
    sendPojo1Notes(obj.getPojo1Notes());
    sendPojo2Notes(obj.getPojo2Notes());
    }
    void sendPojo1Notes(){
    RefughtDataService service=RefughtClientInstance.GetRefughtInstance().create(RefughtDataService.class);
    Call Call=service.postpoJonenote(inputParams);
    call.enqueue(新回调(){
    @凌驾
    公共void onResponse(呼叫、最终响应){
    if(响应!=null){
    if(response.body()!=null){
    if(response.issusccessful()){
    Log.d(Constants.TAG,“onResponse:PostReview()====SUCCESS”);
    }
    }
    }
    }
    @凌驾
    失败时公共无效(调用调用,可丢弃的t){
    Log.d(Constants.TAG,“onResponse:PostReview()”+t.toString());
    }
    });
    }
    void sendPojo2Notes(){
    RefughtDataService service=RefughtClientInstance.GetRefughtInstance().create(RefughtDataService.class);
    Call Call=service.postpojotwonte(输入参数);
    call.enqueue(新回调(){
    @凌驾
    公共void onResponse(呼叫、最终响应){
    if(响应!=null){
    if(response.body()!=null){
    if(response.issusccessful()){
    Log.d(Constants.TAG,“onResponse:PostReview()====SUCCESS”);
    }
    }
    }
    }
    @凌驾
    失败时公共无效(调用调用,可丢弃的t){
    Log.d(Constants.TAG,“onResponse:PostReview()”+t.toString());
    }
    });
    }
    

    省略了许多详细的代码,因此共享逻辑在更高级别上是有意义的。感谢您的任何意见:)

    展示您的做法far@P.Juni ... 我在第二部分面临的问题。除了打了三个改装电话,我什么也没做(因为我什么都不知道)。你想让我展示代码吗?是的,你使用协同程序吗?@P.Juni。。。。代码共享。不,我用的是Java。