retrofit2

RXJava. Identify when all obervables inside for loop are finished

房东的猫 提交于 2021-02-08 07:41:07
问题 I want to perform the following. I have a list of transactions which i want to update by making 2 api requests (i am using retrofit2), for each transactions and then saving the result into a database(using the observer). After some searching i decided to use zip operator to combine the 2 requests but the issue that i'm have is that i cannot identify when the whole process is finished to update the UI. Code looks like this. for (Transaction realmTransaction : allTransactions) { Observable<Map

Download POST method's PDF response using retrofit 2

时光毁灭记忆、已成空白 提交于 2021-02-08 06:46:34
问题 I am new to android and JSON using retrofit. I am using retrofit 2 with my project. This is one of post API and it gives a pdf as the response. @POST("examples/campaign_report_new.php") Call<ResponseBody> getAddressTrackingReport(@Body ModelCredentialsAddressTracking credentials); I used the below code to do this function and I stuck in the response method to download and show that pdf. private void downloadPdf() { ModelCredentialsAddressTracking credentials = new

Download POST method's PDF response using retrofit 2

无人久伴 提交于 2021-02-08 06:46:32
问题 I am new to android and JSON using retrofit. I am using retrofit 2 with my project. This is one of post API and it gives a pdf as the response. @POST("examples/campaign_report_new.php") Call<ResponseBody> getAddressTrackingReport(@Body ModelCredentialsAddressTracking credentials); I used the below code to do this function and I stuck in the response method to download and show that pdf. private void downloadPdf() { ModelCredentialsAddressTracking credentials = new

How to handle multiple data sources with rxjava?

社会主义新天地 提交于 2021-02-08 03:46:53
问题 This is the case: I have the domain layer to provide data fetching interface for business logics, and I have 2 data sources: local database and remote network. It works like this: Request all users: DataRepository.getInstance().getUsers(); In DataRepository, there are 2 sources: LocalDataSource.getUsers() which fetches all users from local database, if there is no data then ignore this request. RemoteDataSource.getUsers() which requests latest user list from our server(Even if there is data

How to handle multiple data sources with rxjava?

蹲街弑〆低调 提交于 2021-02-08 03:46:25
问题 This is the case: I have the domain layer to provide data fetching interface for business logics, and I have 2 data sources: local database and remote network. It works like this: Request all users: DataRepository.getInstance().getUsers(); In DataRepository, there are 2 sources: LocalDataSource.getUsers() which fetches all users from local database, if there is no data then ignore this request. RemoteDataSource.getUsers() which requests latest user list from our server(Even if there is data

How to receive a Json array (“result”) with retrofit2

只谈情不闲聊 提交于 2021-02-07 20:39:19
问题 I know how to receive arrays when they are this type: [ { "username": "luis", "job": "developer", "age": 23 } ] my problem is when I must receive an array with a specific name like this: {"result":[{"userid":"1","username":"Luis","job":"developer","age":"23"}]} in this case I must receive the array above with the name "result" using retrofit2. Can anyone please help me I'm new at Retrofit. This is what I have tried: MainActivity apiInterface = ApiClient.getApiClient().create(ApiInterface

How can I call multiple requests at the same time in Retrofit 2

与世无争的帅哥 提交于 2021-02-07 13:15:58
问题 I have two different REST method, and I want to call them at the same time. How can I do this in Retrofit 2 ? I can call them one by one of course, but is there any suggested method in retrofit ? I expect something like: Call<...> call1 = myService.getCall1(); Call<...> call2 = myService.getCall2(); MagicRetrofit.call (call1,call2,new Callback(...) {...} ); // and this calls them at the same time, but give me result with one method 回答1: I would take a look at using RxJava with Retrofit. I

How can I call multiple requests at the same time in Retrofit 2

六月ゝ 毕业季﹏ 提交于 2021-02-07 13:15:49
问题 I have two different REST method, and I want to call them at the same time. How can I do this in Retrofit 2 ? I can call them one by one of course, but is there any suggested method in retrofit ? I expect something like: Call<...> call1 = myService.getCall1(); Call<...> call2 = myService.getCall2(); MagicRetrofit.call (call1,call2,new Callback(...) {...} ); // and this calls them at the same time, but give me result with one method 回答1: I would take a look at using RxJava with Retrofit. I

How can I call multiple requests at the same time in Retrofit 2

孤街醉人 提交于 2021-02-07 13:15:41
问题 I have two different REST method, and I want to call them at the same time. How can I do this in Retrofit 2 ? I can call them one by one of course, but is there any suggested method in retrofit ? I expect something like: Call<...> call1 = myService.getCall1(); Call<...> call2 = myService.getCall2(); MagicRetrofit.call (call1,call2,new Callback(...) {...} ); // and this calls them at the same time, but give me result with one method 回答1: I would take a look at using RxJava with Retrofit. I

Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension;

ぃ、小莉子 提交于 2021-02-06 15:29:39
问题 I'm using RxJava with Retrofit on the newest preview of AndroidStudio. My project has java 1.8 suport enabled like this: compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } But when the code is compiled and run I'm getting this error, as soon as the request is made, even if I have the onError handler: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension; at io.reactivex.plugins.RxJavaPlugins.onError