If you think the Android project AndroidPlaces listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2014 Brian Lee//www.java2s.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.tigerpenguin.places.response;
import android.content.Context;
import com.tigerpenguin.places.model.Place;
import com.tigerpenguin.places.request.PlaceSearchRequest;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import com.tigerpenguin.places.request.InvalidRequestException;
import com.tigerpenguin.places.responsehandler.PlacesResponseHandler;
publicabstractclass PlaceSearchResponse<SearchResponse extends PlaceSearchResponse> extends PlacesResponse {
@JsonProperty(NEXT_PAGE_TOKEN)
private String nextPageToken;
@JsonProperty(RESULTS)
private List<Place> results;
protectedabstract PlaceSearchRequest getNextPageRequest(Context context, String nextPageToken,
PlacesResponseHandler<SearchResponse>
placesResponseHandler);
publicfinalvoid getMoreResults(Context context, PlacesResponseHandler<SearchResponse> placesResponseHandler)
throws InvalidRequestException {
if (hasMoreResults()) {
PlaceSearchRequest placeSearchRequest = getNextPageRequest(context, nextPageToken, placesResponseHandler);
placeSearchRequest.execute();
} else {
thrownew InvalidRequestException("There are no more results");
}
}
publicfinalboolean hasMoreResults() {
return (nextPageToken != null && !nextPageToken.trim().isEmpty());
}
publicfinal String getNextPageToken() {
return nextPageToken;
}
publicfinal List<Place> getResults() {
return results;
}
}