retrofit2

Android Picasso image loading app crash when scrolling RecyclerView

对着背影说爱祢 提交于 2021-01-29 02:44:41
问题 I am using Retrofit to access this Webservice link: https://jsonplaceholder.typicode.com/photos When loading the items in a recyclerview without loading images, the app works fine. However, if I add Picasso code to load the images, the app crashes after scrolling 2 or three times. I get the following error: A/Looper: Could not make wake event fd: Too many open files OR these errors all together: E/Parcel: fcntl(F_DUPFD_CLOEXEC) failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 1,

Trying to get post from JsonPlaceHolder by retrofit, but response isn't showing methods

本小妞迷上赌 提交于 2021-01-28 11:01:45
问题 I'm new in retrofit, I'm trying to get single post from jsonplaceholder website, the problem is that I can't find getTitle, getBody, getId, and getUserId in onresponse method in callback. I typed (response.body.) , but getter methods doesn't appear. MainActivity public class MainActivity extends AppCompatActivity { TextView tvText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tvText=findViewById(R.id

Multiple retrofit2 requests using Flowable in Kotlin

左心房为你撑大大i 提交于 2021-01-28 10:47:26
问题 In order to improve my skills in kotlin, Rx, Retrofit2 I've decided to do a demo project. The demo project consist to display posts in a recycler view then display details of the post in a detail activity. I've encountered difficulties displaying data coming from different api call: the user name, the title, the body of the post and the number of comments of the post. My problem is that I would like to do multiple request and then have all the data needed in order to display them in the

Multiple retrofit2 requests using Flowable in Kotlin

孤街浪徒 提交于 2021-01-28 10:42:12
问题 In order to improve my skills in kotlin, Rx, Retrofit2 I've decided to do a demo project. The demo project consist to display posts in a recycler view then display details of the post in a detail activity. I've encountered difficulties displaying data coming from different api call: the user name, the title, the body of the post and the number of comments of the post. My problem is that I would like to do multiple request and then have all the data needed in order to display them in the

SocketException unsubscribing request without onError

孤人 提交于 2021-01-28 03:11:51
问题 I'm trying to make a request using RxJava and Retrofit(2.3). I'm expecting that in case of any error I can retry or show a message to the client. However, I notice that sometimes I have a SocketException which results in not calling onError, apparently the subscriber of the request just unsubscribes without calling anything else (not onComplete neither onError). Anyone knows why this is happening and how can I solve this in a generic way (without simply doing onUnsubscribe() and checking if

Retrofit2: convert JSON with dynamic keys to a Map<String, Model> with Model also containing those keys

北城余情 提交于 2021-01-27 18:52:37
问题 I'm using Retrofit 2 in combination with Gson and RxJava. My JSON data looks something like this: { "groups": { "1": { "name": "First group", "type": "some data", // ... more data }, "2": { "name": "Second group", "type": "some data", // ... more data }, "3": { "name": "Third group", "type": "some data", // ... more data } // 4, 5, 6, etc... }, // ... more data } In the example above the "keys" 1, 2, 3 are integers but they can also be unique strings. I want to map this JSON data to something

Multiple enqueue in retrofit causing out of memory error?

点点圈 提交于 2021-01-27 13:01:39
问题 Am doing my project using retrofit2. When my Call goes on failure i repeat same call again.Repeation of this call made my app to force close. When i look on log i got error log, which is given below. I felt this is caused by multiple enqueue to same Call. So i did that before enqueus i called cancel. But its not working. getting same force close. FATAL EXCEPTION: main Process: com.SocialMob, PID: 27846 java.lang.OutOfMemoryError: pthread_create (stack size 16384 bytes) failed: Try again at

Retrofit 2 disable encoding for post parameters

淺唱寂寞╮ 提交于 2021-01-27 04:11:48
问题 I am beginner in retrofit... I need send POST request with simple parameters name : value login[name] : some-name login[pw] : some-pw date : 2017-08-28T12:12:12+0200 so, I tried @FormUrlEncoded @POST(urlLogin) Call<Login> signIn(@Field("login[name]") String name, @Field("login[pw]") String pw, @Field("date") String date); that send to the server: login%5Bname%5D : some-name login%5Bpw%5D : some-pw date : 2017-08-28T21%3A11%3A57%2B0200 next @FormUrlEncoded @POST(urlLogin) Call<Login> signIn(

Retrofit 2 disable encoding for post parameters

牧云@^-^@ 提交于 2021-01-27 04:09:22
问题 I am beginner in retrofit... I need send POST request with simple parameters name : value login[name] : some-name login[pw] : some-pw date : 2017-08-28T12:12:12+0200 so, I tried @FormUrlEncoded @POST(urlLogin) Call<Login> signIn(@Field("login[name]") String name, @Field("login[pw]") String pw, @Field("date") String date); that send to the server: login%5Bname%5D : some-name login%5Bpw%5D : some-pw date : 2017-08-28T21%3A11%3A57%2B0200 next @FormUrlEncoded @POST(urlLogin) Call<Login> signIn(

Retrofit 2: How to set individual timeouts on specific requests?

自作多情 提交于 2021-01-21 03:37:19
问题 I have set a global timeout in my Retrofit adapter by doing OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setReadTimeout(20, TimeUnit.SECONDS); okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS); retrofit = new Retrofit.Builder() .client(okHttpClient) .build(); Great! But I would like to set an specific timeout for certain requests E.g. public interface MyAPI { @GET() Call<Void> notImportant (@Url String url); @GET Call<Void> veryImportant(@Url String url); So veryImportant