Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ApiMethod(name = "getAllUnclaimedLeftovers")
- public Collection<Leftover> getAllUnclaimedLeftovers() {
- Collection<Leftover> unclaimedLeftoverOffers = new ArrayList<Leftover>();
- for(Leftover leftover : ofy().load().type(Leftover.class)) {
- if (!leftover.isClaimed() && leftover.isValid()) {
- unclaimedLeftoverOffers.add(leftover);
- }
- }
- return unclaimedLeftoverOffers;
- }
- public static Collection<Leftover> getAllUnclaimedLeftovers() throws IOException {
- try {
- return Proxy.getEndpoint().getAllUnclaimedLeftovers().execute().getItems();
- } catch (IOException e) {
- Log.d("DataStore_UnclaimedLeftovers_Error", e.getMessage());
- throw e;
- }
- }
- private class UnclaimedLeftoversTask extends AsyncTask<Void, Void, Void> {
- @Override
- protected Void doInBackground(Void... params) {
- try {
- setUnclaimedLeftovers(LeftoverProxy.getAllUnclaimedLeftovers());
- setIsUnclaimedLeftoversSucceeded(true);
- return null;
- } catch (IOException e) {
- setIsUnclaimedLeftoversSucceeded(false);
- return null;
- } catch (NullPointerException e) {
- setIsUnclaimedLeftoversSucceeded(false);
- return null;
- }
- }
- }
- public GetAllUnclaimedLeftovers getAllUnclaimedLeftovers() throws java.io.IOException {
- GetAllUnclaimedLeftovers result = new GetAllUnclaimedLeftovers();
- initialize(result);
- return result;
- }
- public class GetAllUnclaimedLeftovers extends EndpointRequest<com.frigoshare.endpoint.model.LeftoverCollection> {
- private static final String REST_PATH = "leftovercollection";
- protected GetAllUnclaimedLeftovers() {
- super(Endpoint.this, "GET", REST_PATH, null, com.frigoshare.endpoint.model.LeftoverCollection.class);
- }
- ...
- }
- public EndpointRequest(
- Endpoint client, String method, String uriTemplate, Object content, Class<T> responseClass) {
- super(
- client,
- method,
- uriTemplate,
- content,
- responseClass);
- }
- /**
- * Sends the metadata request to the server and returns the parsed metadata response.
- *
- * <p>
- * Subclasses may override by calling the super implementation.
- * </p>
- *
- * @return parsed HTTP response
- */
- public T execute() throws IOException {
- HttpResponse response = executeUnparsed();
- if (Void.class.equals(responseClass)) {
- response.ignore();
- return null;
- }
- return response.parseAs(responseClass);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement