use of com.usp.icmc.taemcasa.Wishlist.WishlistResponse.WishlistRequest_GETALL in project TaEmCasa by Dionen.
the class WishlistActivity method downloadWishlist.
private void downloadWishlist() {
final Context context = getContext();
carregandoWishlist(getView());
vagas.clear();
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject jsonResponse = null;
layoutWishlist(getView());
try {
jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success) {
JSONArray wishlistResponse = jsonResponse.getJSONArray("data");
if (wishlistResponse.length() == 0)
vaziaWishlist(getView());
for (int i = 0; i < wishlistResponse.length(); i++) {
JSONObject atual = wishlistResponse.getJSONObject(i);
Vaga vaga = new Vaga();
Endereco end = new Endereco();
vaga.setPrice(atual.getString("vaga.preco"));
vaga.setTitle(atual.getString("republica.nome"));
vaga.setImagem(atual.getString("republica.imagem"));
end.setRua(atual.getString("republica.rua"));
end.setNumero(atual.getString("republica.numero"));
end.setComplemento(atual.getString("republica.complemento"));
end.setBairro(atual.getString("republica.bairro"));
end.setCidade(atual.getString("republica.cidade"));
end.setEstado(atual.getString("republica.estado"));
vaga.setAddress(end);
vagas.add(vaga);
}
adapter.notifyDataSetChanged();
} else {
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
/* ENTRA NA DATABASE ONLINE */
WishlistRequest_GETALL wishlistRequest = new WishlistRequest_GETALL(getActivity().getIntent().getExtras().getString("user_id"), responseListener);
RequestQueue queue = Volley.newRequestQueue(getContext());
// Executa as tarefas requisitadas
queue.add(wishlistRequest);
}
Aggregations