Handle Paging with RxJava

You could model it recursively: Observable<ApiResponse> getPageAndNext(int page) { return getResults(page) .concatMap(new Func1<ApiResponse, Observable<ApiResponse>>() { @Override public Observable<ApiResponse> call(ApiResponse response) { // Terminal case. if (response.next == null) { return Observable.just(response); } return Observable.just(response) .concatWith(getPageAndNext(response.next)); } }); } Then, to consume it, getPageAndNext(0) .concatMap(new Func1<ApiResponse, Observable<ResponseObject>>() { @Override public Observable<ResponseObject> call(ApiResponse response) { return Observable.from(response.results); … Read more

Retrofit GSON serialize Date from json string into java.util.date

Gson gson = new GsonBuilder() .setDateFormat(“yyyy-MM-dd’T’HH:mm:ss”) .create(); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(API_BASE_URL) .setConverter(new GsonConverter.create(gson)) .build(); Or the Kotlin equivalent: val gson = GsonBuilder().setDateFormat(“yyyy-MM-dd’T’HH:mm:ss”).create() RestAdapter restAdapter = Retrofit.Builder() .baseUrl(API_BASE_URL) .addConverterFactory(GsonConverterFactory.create(gson)) .build() .create(T::class.java) You can set your customized Gson parser to retrofit. More here: Retrofit Website Look at Ondreju’s response to see how to implement this … Read more

Retrofit 2 – URL Query Parameter

If you specify @GET(“foobar?a=5”), then any @Query(“b”) must be appended using &, producing something like foobar?a=5&b=7. If you specify @GET(“foobar”), then the first @Query must be appended using ?, producing something like foobar?b=7. That’s how Retrofit works. When you specify @GET(“foobar?”), Retrofit thinks you already gave some query parameter, and appends more query parameters using … Read more

Retrofit and GET using parameters

AFAIK, {…} can only be used as a path, not inside a query-param. Try this instead: public interface FooService { @GET(“/maps/api/geocode/json?sensor=false”) void getPositionByZip(@Query(“address”) String address, Callback<String> cb); } If you have an unknown amount of parameters to pass, you can use do something like this: public interface FooService { @GET(“/maps/api/geocode/json”) @FormUrlEncoded void getPositionByZip(@FieldMap Map<String, String> … Read more

particular title(fetched from api) using searchview?

You can achieve suggestions related to your search query using recyclerview and adapters. [1] Create new adapter and put your setMovieList() and getFilter() into it. [2] Set that adapter into recyclerview of suggestions and notify adapter when you get your arraylist of suggestions. check below code public void onResponse(retrofit2.Call<List<StartLearning.SlModel>> call, Response<List<StartLearning.SlModel>> response) { movieList = … Read more

Single Observable with Multiple Subscribers

After checking back with RxJava developer Dávid Karnok I’d like to propose a full explanation of what was going on here. share() is defined as publish().refCount(), i. e. the source Observable is first transformed to a ConnectableObservable by publish() but instead of having to call connect() “manually” that part is handled by refCount(). In particular, … Read more

How can Retrofit 2.0 parse nested JSON object?

Assuming your complete JSON looks like { “title”: “Recent Uploads tagged android”, “link”: “https://www.flickr.com/photos/tags/android/”, “description”: “”, “modified”: “2015-10-05T05:30:01Z”, “generator”: “https://www.flickr.com/”, “items”: [ { “member1”: “memeber value”, “member2”: “member value” }, { “member1”: “memeber value”, “member2”: “member value” } ] } So Pojo classes would be public class MainPojo { private String title; private String description; … Read more

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