public static ArrayList<Item> getItems( String auth_token, Integer offset, Integer batch_size, Date last_sync, HashMap<String, Object> options) { if (options == null) { options = new HashMap<String, Object>(); } if (auth_token != null) options.put("token", auth_token); if (offset != null) options.put("offset", offset); if (batch_size != null) options.put("batch_size", batch_size); if (last_sync != null) options.put("last_sync", (last_sync.getTime() / 1000)); ArrayList<Item> items = new ArrayList<Item>(); Gson gson = new Gson(); try { JsonArray array = (JsonArray) apiGet("/v1/items", queryParams(options)); for (int i = 0; i < array.size(); i++) { Item item = Item.fromJSON((JsonObject) array.get(i)); items.add(item); } return items; } catch (ApiException ae) { handleApiException(ae); return null; } }
/* =============================== STUBS =================================*/ public static ArrayList<Item> itemsStub() { Log.v("TIME:", "\n\n\n" + (new Date().getTime())); ArrayList<Item> items = new ArrayList<Item>(); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"Lorem Ipsum\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"dolor sit amet\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"consectetur adipisicing elit\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"sed do eiusmod tempor\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"incididunt ut labore\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"dolore magna aliqua\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"Ut enim ad minim veniam\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"quis nostrud exercitation\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"ullamco laboris\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); items.add( Item.fromJSON( (JsonObject) new JsonParser() .parse( "{\"content\":\"nisi ut aliquip ex ea\", \"created_at\":\"2011-11-01T11:51:36-07:00\"}"))); return items; }