Not loading latest videos firstly in NextPageToken Youtube API3 in Android

I wanted to load YouTube channel videos in Android app via YouTube API.So I added code with pagination.So code is working but the problem is not loading latest videos firstly.They have jumbled.some are showing more than one. Why is that ? please help me to resolve my problem.I used Retrofit.

Here is my

public class MainActivity extends AppCompatActivity {

        private static final String TAG = "MainActivity";
        private VideosAdapter adapter;
        //if you are using searchview to get search result then store searched query in lastSearched variable.
        //get latest token and store in lastToken variable.
        private String lastSearched = "", lastToken = "";

        protected void onCreate(Bundle savedInstanceState) {
            RecyclerView recyclerView = findViewById(;
            Button more = findViewById(;

            adapter = new VideosAdapter();
            recyclerView.setLayoutManager(new LinearLayoutManager(this));
            recyclerView.setItemAnimator(new DefaultItemAnimator());
            recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

            //load data from api.
            search("", false);

            more.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    //load more data
                    search("", true);

         * call this method to get response from youtube API.
         * @param query String value to search on google, Empty string means get all videos.
         * @param more  if you want to load next page then pass true, this means add new items at bottom of RecyclerView.
        private void search(String query, final boolean more) {

            final ProgressDialog progressDialog =, null, "Loading ...", true, false);
            String searchType = "video";
            if (query != null) {
                if (query.startsWith("#")) {
                    searchType = "video";
                    query = query.substring(1);
                } else if (query.startsWith("@")) {
                    searchType = "channel";
                    query = query.substring(1);
            if (!more) {
                lastSearched = query;
                lastToken = "";

            Call<YoutubeResponse> youtubeResponseCall = APIService.youtubeApi.searchVideo(query, searchType, Constants.YOUTUBE_API_KEY, "snippet,id", "5","UCItoVC3HUBA6s9qOEVPILrA", lastToken);
            youtubeResponseCall.enqueue(new Callback<YoutubeResponse>() {
                public void onResponse(@NonNull Call<YoutubeResponse> call, @NonNull Response<YoutubeResponse> response) {
                    if (progressDialog.isShowing()) {
                    YoutubeResponse body = response.body();
                    if (body != null) {
                        List<YoutubeResponse.Item> items = body.getItems();
                        lastToken = body.getNextPageToken();
                        if (more) {
                        } else {

                public void onFailure(@NonNull Call<YoutubeResponse> call, @NonNull Throwable t) {
                    if (progressDialog.isShowing()) {
                    Log.e(TAG, "onFailure: ", t);

Here is

public interface YoutubeApi {
    Call<YoutubeResponse> searchVideo(@Query("q") String query,
                                  @Query("type") String type,
                                  @Query("key") String key,
                                  @Query("part") String part,
                                  @Query("maxResults") String maxResults,
                                  @Query("channelId") String channelId,
                                  @Query("pageToken") String pageToken);

Thank you.