Chciałbym złożyć wniosek za pomocą Biblioteki Salwatorian w różnych wątkach.Utwórz zamówienie na siatkę w innym wątku
To znaczy, że istnieje połączenie, które jest w Bieżniku i proces danych w UIThread. Chcę to zrobić, ponieważ mam dużo połączenia, więc wiele danych do przetworzenia i dziś mam interfejs użytkownika, który jest blokiem.
Więc, jak mogę zrobić, aby umieścić i uruchomić połączenie w inny wątek, i zrobić OnResponse()/OnErrorResponse() w UIThread
JsonArrayRequest getReq = new JsonArrayRequest(url,new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d("onRESPONSE Synchro -> Produit",response.toString());
PgrBarProducts.setMax(response.length());
percentDisplayProduct.setText("0/"+ PgrBarProducts.getMax());
nbMaxCallNetwork = PgrBarProducts.getMax();
try {
for (int i = 0; i < response.length(); i++) {
JSONObject explrObject = response.getJSONObject(i);
String id = Integer.toString((Integer) explrObject.get("id"));
callOneObject(id, PgrBarProducts, percentDisplayProduct , 1); // appel du product
}
} catch (JSONException e) {
e.printStackTrace(new PrintWriter(stackTrace));
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
changeStatutToError();
VolleyLog.d("", "Error: " + error.getMessage());
percentDisplayProduct.setTextColor(Color.RED);
percentDisplayProduct.setTypeface(null, Typeface.BOLD);
percentDisplayProduct.setText("erreur");
waitBarProgressProduct.setVisibility(View.INVISIBLE);
synchroProducts.setVisibility(View.VISIBLE);
}
});
getReq.setRetryPolicy(new DefaultRetryPolicy(60 * 1000, 1,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue and start the request
AppController.getInstance().addToAndStartRequestQueue(getReq);
}
});
Nikt nie może odpowiedzieć ?? :/ –