retrofit2

Adapter FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? [duplicate]

陌路散爱 提交于 2019-12-13 03:09:25
问题 This question already has answers here : Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? (2 answers) Calling startActivity() from outside of an Activity context (24 answers) Closed 2 years ago . Users albums will be opened when the user is clicked. User's website http://jsonplaceholder.typicode.com/users and album's website http://jsonplaceholder.typicode.com/albums. I want to use intent MainActivity from

Android : Unable to upload multipart Image file using Retrofit 2.0.0 beta 2

痞子三分冷 提交于 2019-12-13 02:47:30
问题 Hi I am unable to upload an image using retrofit 2.0.0-beta2. It gives me "Image missing" error. Although I checked that file exist in system and also if I show in an Image view it is showing properly. URL on which it needs to be uploaded : http://mywebsite.com/signature/upload/ So my BASE_URL is = http://mywebsite.com/ my .gradle file has this : compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' compile 'com.squareup.okhttp:logging

JSON data not showing in the Recylerview MVVM

南笙酒味 提交于 2019-12-13 01:16:05
问题 I'm trying to parse Json in Recyclerview using Data binding. When I run the app it's only showing blank screen with no error/crashes. Json data: { "msg":[ "football", "cricket", "baseball", "rugby", "gulf" ], "status":"success" } The Api interface SportsApi { /** * Get the Sports from the API */ @GET("/sports") fun getSports(): Observable<Sports> } The adaperclass: class PostListAdapter: RecyclerView.Adapter<PostListAdapter.ViewHolder>() { private lateinit var postList:Sports override fun

Android: infinite scroll with rx-java using repeatWhen, takeUntil and filter with retrofit

核能气质少年 提交于 2019-12-12 20:53:42
问题 I am using Retrofit 2.2 with RxJava. The pagination works like this: I get the first batch of data, I have to request the second batch of data with the same params except one which is the lastUpdated date and then if I get empty or the same batch of data it means there are no more items. I have found this great article https://medium.com/@v.danylo/server-polling-and-retrying-failed-operations-with-retrofit-and-rxjava-8bcc7e641a5a#.40aeibaja on how to do it. So my code is: private Observable

Retrofit2 Okhttp3 catch TimeOut

女生的网名这么多〃 提交于 2019-12-12 18:36:15
问题 I got a client like this: public enum RestClient { INSTANCE; private static final int CONNECTION_TIMEOUT = 10; private static final int READ_TIMEOUT = 30; private static final int WRITE_TIMEOUT = 30; private final Rest restClient; private RestClient() { restClient = new Retrofit.Builder() .baseUrl(App.getContext().getResources().getString(R.string.EP)) .addConverterFactory(JacksonConverterFactory.create()) .client(new okhttp3.OkHttpClient.Builder() .connectTimeout(CONNECTION_TIMEOUT, TimeUnit

How to get http response status in synchronous retrofit 2

懵懂的女人 提交于 2019-12-12 17:32:29
问题 I am getting the response from the server all right, using retrofit 2.0.1, Is there any way to get the HTTP response status, without using Asynchronous method? Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://192.168.8.4/********/***/") .addConverterFactory(GsonConverterFactory.create()) .build(); RequestInterface request = retrofit.create(RequestInterface.class); HotelDetail hd; Call<HotelDetail> call1 = request.getIndividualHotel("1"); hd = call1.execute().body(); 回答1: You can

Retrofit2 SocketTimeOutException

丶灬走出姿态 提交于 2019-12-12 17:31:13
问题 I setup for Retrofit : private Interceptor interceptor = new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (!NetworkUtil.isNetworkAvailable()) { request = request.newBuilder() .cacheControl(CacheControl.FORCE_CACHE) .build(); } Response response = chain.proceed(request); //Exception here if (NetworkUtil.isNetworkAvailable()) { String cacheControl = request.cacheControl().toString(); response = response.newBuilder()

Retrofit2: ClassCastException: java.util.ArrayList cannot be cast to retrofit2.Call

允我心安 提交于 2019-12-12 16:33:27
问题 please help with Retrofit2. I'm very new in Retrofit. I create simple server application. The application manage list of Journals: add Journal in the in-memory list and return Journal by id. There is an Journal.java: public class Journal { private AtomicInteger getNewId = new AtomicInteger(0); @SerializedName("id") @Expose private Integer id; @SerializedName("name") @Expose private String name; public Journal(String name) { this.id = getNewId.incrementAndGet(); this.name = name;} public

How to download a pdf file with Retrofit 2

纵饮孤独 提交于 2019-12-12 15:21:18
问题 I'm having difficulty downloading a pdf file with retrofit. My code produces a file, but it is the wrong size and when the pdf opens it is blank. This is how my php webservice returns a pdf file. ** * @param Slim\Slim $app * @param String $pdf */ function respondWithPDF($app, $pdf) { $res = $app->response(); $res['Content-Description'] = 'File Transfer'; $res['Content-Type'] = 'application/octet-stream'; $res['Content-Disposition'] ='attachment; filename=' . basename($pdf); $res['Content

Android Sqlite multi threading save data with DBFlow + Retrofit

吃可爱长大的小学妹 提交于 2019-12-12 14:23:21
问题 I'm using DBFlow to save into the database and Retrofit to call my web service. My retrofit class is the same class as my Database table. But I have a problem when 2 threads or more are launched at the same time to save my data into the table. The insert into my table duplicate my data and the primary key is duplicated too. Then my thread is stopped because it crashes. Have you a solution for that ? Class for Retrofit and DBFlow @Table(database = LocalDB.class) @Root(name = "picture_infos")