In my Android app, Wordpress Rest api is only calling 10 posts.
When I move to the end of the screen I want to call the next 10 more posts. And when it comes to the end of it, I want to call the 10 posts next.
There will be hundreds of posts in the meantime.
How can I do it?
getPost(){swipeRefreshLayout.setRefreshing(true);
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(100, TimeUnit.SECONDS)
.readTimeout(100,TimeUnit.SECONDS).build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Ayarlar.base_url_deneme)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
Connect connect = retrofit.create(Connect.class);
Call<List<Post>> call = connect.getPost(Ayarlar.get_post_url_deneme);
call.enqueue(new Callback<List<Post>>() {
@Override
public void onResponse(Call<List<Post>> call, Response<List<Post>> response) {
Log.e("response",""+response.code());
if (response.code()==200){
List<Post> postList = response.body();
PostAdapter postAdapter = new PostAdapter(TurkUser.this,postList);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(TurkUser.this,LinearLayoutManager.VERTICAL,false);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(postAdapter);
swipeRefreshLayout.setRefreshing(false);
postAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<List<Post>> call, Throwable t) {
Toast.makeText(TurkUser.this,"Hata veriler çekilemedi.",Toast.LENGTH_SHORT).show();
Log.e("onFailure", "hata veriler çekilemedi "+t+" "+call);
swipeRefreshLayout.setRefreshing(false);
}
});
}