use of POGOProtos.Networking.Requests.Messages.DownloadItemTemplatesMessageOuterClass.DownloadItemTemplatesMessage in project PokeGOAPI-Java by Grover-c13.
the class ItemTemplates method updatePage.
/**
* Updates {@link ItemTemplate} pages recursively
*
* @param api the current api
* @param page the current page index
* @param timestamp the timestamp of this page
* @param loadTime the time at which the templates started loading
* @throws RequestFailedException if the page update is not successfully sent
*/
private void updatePage(PokemonGo api, int page, long timestamp, long loadTime) throws RequestFailedException {
DownloadItemTemplatesMessage message = DownloadItemTemplatesMessage.newBuilder().setPaginate(true).setPageOffset(page).setPageTimestamp(timestamp).build();
ServerRequest request = new ServerRequest(RequestType.DOWNLOAD_ITEM_TEMPLATES, message);
api.requestHandler.sendServerRequests(request, true);
try {
DownloadItemTemplatesResponse response = DownloadItemTemplatesResponse.parseFrom(request.getData());
provider.updateTemplates(response, loadTime);
if (response.getResult() == Result.PAGE) {
updatePage(api, response.getPageOffset(), response.getTimestampMs(), loadTime);
}
} catch (IOException e) {
throw new RequestFailedException(e);
}
}
Aggregations