CardView does not display information from a JSON [closed]

15

I am trying to set some information in a CardView, where these are obtained from a JSON, however, it does not display, the information search is ok, it returns the values normally but does not display in the app ..

 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mList = savedInstanceState.getParcelableArrayList("mList");
    } else {
        mList = getCarsByCategory(0);
    }
}

method getSetCarList ()

public List<Car> getSetCarList(final int qtd, final int category) {

    final String[] models = new String[qtd];
    final String[] brands = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",};
    final int[] categories = new int[]{2, 1, 2, 1, 1, 4, 3, 2, 4, 1};
    final int[] photos = new int[]{R.drawable.gallardo, R.drawable.vyron, R.drawable.corvette, R.drawable.paganni_zonda, R.drawable.porsche_911, R.drawable.bmw_720, R.drawable.db77, R.drawable.mustang, R.drawable.camaro, R.drawable.ct6};
    final String description = "Lorem Ipsum é simplesmente uma simulação de texto da indústria tipográfica e de impressos, e vem sendo utilizado desde o século XVI, quando um impressor desconhecido pegou uma bandeja de tipos e os embaralhou para fazer um livro de modelos de tipos. Lorem Ipsum sobreviveu não só a cinco séculos, como também ao salto para a editoração eletrônica, permanecendo essencialmente inalterado. Se popularizou na década de 60, quando a Letraset lançou decalques contendo passagens de Lorem Ipsum, e mais recentemente quando passou a ser integrado a softwares de editoração eletrônica como Aldus PageMaker.";
    mList = new ArrayList<>();
    //carAdapter = new CarAdapter(this, listCars);
    //carAdapter.onAttachedToRecyclerView(new CarFragment().recycler());

    RequestQueue mRequestQueue = Volley.newRequestQueue(getActivity());

    Log.e("START GET", "STARTED GET");
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            URL_FEED, null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject jsonObject) {
            try {

                JSONArray feedArray = jsonObject.getJSONArray("data");

                for (int i = 0; i < models.length; i++) {
                    JSONObject feedObj = (JSONObject) feedArray.get(i);
                    models[i] = feedObj.getString("message");
                    Log.i("MESSAGE", "------ POSITION: " + i + ", MESSAGE:" + models[i]);
                }

                for (int i = 0; i < qtd; i++) {
                    Car c = new Car(models[i % models.length], brands[i % brands.length], photos[i % models.length]);
                    Log.e("MODELS", "MESSAGE: " + models[i]);
                    c.setDescription(description);
                    c.setCategory(categories[i % brands.length]);
                    c.setTel("33221155");

                    if (category != 0 && c.getCategory() != category) {
                        continue;
                    }

                    mList.add(c);
                }

                Log.e("FINISH INSERT", "FINISH INSERT");

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            Log.e("ERRO JSONREQUEST", "ERRO: " + volleyError.toString());
        }
    });

    mRequestQueue.add(jsonObjReq);
    Log.i("FINISH REQUEST", "FINISH REQUEST");
    /*for (int i = 0; i < qtd; i++) {
        Car c = new Car(models[i % models.length], brands[i % brands.length], photos[i % models.length]);
        Log.e("MODELS", "MESSAGE: " + models[i]);
        c.setDescription(description);
        c.setCategory(categories[i % brands.length]);
        c.setTel("33221155");

        if (category != 0 && c.getCategory() != category) {
            continue;
        }

        listAux.add(c);
    }*/

    return (mList);
}

method getCarsByCategory ()

 public List<Car> getCarsByCategory(int category) {
    List<Car> listAux = new ArrayList<>();
    for (int i = 0; i < mList.size(); i++) {
        if (category != 0 && mList.get(i).getCategory() != category) {
            continue;
        }

        listAux.add(mList.get(i));
    }
    return (listAux);
}

    
asked by anonymous 12.06.2015 / 20:28

0 answers