Dagger + Retrofit. Adding auth headers at runtime

I personally created an okhttp3.Interceptor that does that for me, which I update once I have the required token. It looks something like: @Singleton public class MyServiceInterceptor implements Interceptor { private String sessionToken; @Inject public MyServiceInterceptor() { } public void setSessionToken(String sessionToken) { this.sessionToken = sessionToken; } @Override public Response intercept(Chain chain) throws IOException { … Read more

Retrofit2.0 gets MalformedJsonException while the json seems correct?

Finally I solved my problem which is not related to the json lenient mode, something wrong with my POST response (there some other non json output before the json data). Here is the response from JakeWharton regarding how to set Gson lenient mode: make sure that you have:compile ‘com.google.code.gson:gson:2.6.1’ Gson gson = new GsonBuilder() .setLenient() … Read more

How use Kotlin enum with Retrofit?

enum class VehicleEnumEntity(val value: String) { @SerializedName(“vehicle”) CAR(“vehicle”), @SerializedName(“motorcycle”) MOTORCYCLE(“motorcycle”), @SerializedName(“van”) VAN(“van”), @SerializedName(“motorhome”) MOTORHOME(“motorhome”), @SerializedName(“other”) OTHER(“other”) } Source

IllegalArgumentException: Could not locate call adapter for rx.Observable RxJava, Retrofit2

Be sure to add implementation ‘com.squareup.retrofit2:adapter-rxjava2:2.4.0’ or whatever version you are using to your dependencies, and then configure retrofit with that converter: Retrofit retrofit = new Retrofit.Builder() .baseUrl(endpoint) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .build(); Updated RxJavaCallAdapterFactory was renamed to RxJava2CallAdapterFactory. Changed the snipped above.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)