mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
search paging improvement
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package org.diylc.plugins.cloud.presenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||
|
||||
public class PagingProvider {
|
||||
|
||||
private CloudPresenter cloudPresenter;
|
||||
|
||||
private String searchFor;
|
||||
private String category;
|
||||
private String sort;
|
||||
private int itemsPerPage = 10;
|
||||
|
||||
private int currentPage;
|
||||
private List<ProjectEntity> currentResults;
|
||||
|
||||
public PagingProvider(CloudPresenter cloudPresenter) {
|
||||
this.cloudPresenter = cloudPresenter;
|
||||
}
|
||||
|
||||
public List<ProjectEntity> startSession(String searchFor, String category, String sort) throws CloudException {
|
||||
this.searchFor = searchFor;
|
||||
this.category = category;
|
||||
this.sort = sort;
|
||||
this.currentPage = 1;
|
||||
|
||||
return currentResults = cloudPresenter.search(searchFor, category, sort, currentPage, itemsPerPage);
|
||||
}
|
||||
|
||||
public boolean hasMoreData() {
|
||||
return this.currentResults != null && this.currentResults.size() == itemsPerPage;
|
||||
}
|
||||
|
||||
public List<ProjectEntity> requestMoreData() throws CloudException {
|
||||
currentPage++;
|
||||
return currentResults = cloudPresenter.search(searchFor, category, sort, currentPage, itemsPerPage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user