Gson не заполняет список gson.getJson - PullRequest
0 голосов
/ 05 июля 2018

Я преобразовал данные в JSON и получил их тоже. Но чего-то не хватает. Я не знаю что. У меня 2 ссылки, 1 из них работает. Он получает ответ и преобразует данные в JSON.

Я пытался: Я заменяю старую базу данных новой, но она не работает. Старая база данных снова работает. Я проверяю таблицу и столбец, но оба одинаковы. Что еще я должен попробовать. Пожалуйста, помогите!

 private void requestData(String uri) {
    JsonObjectRequest request = new JsonObjectRequest(uri,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Utils.psLog("Response > " + response);
                    try {
                        String status = response.getString("status");
                        if (status.equals(jsonStatusSuccessString)) {
                            progressWheel.setVisibility(View.GONE);
                            Gson gson = new Gson();
                            Type listType = new TypeToken<List<PShopData>>() {
                            }.getType();

                            pShopDataList = gson.fromJson(response.getString("data"), listType);
                            if(pShopDataList != null ) {
                                Utils.psLog("Shop Count : "  + pShopDataList.size());
                                if (pShopDataList.size() > 1) {
                                    singleLayout.setVisibility(View.GONE);
                                    mRecyclerView.setVisibility(View.VISIBLE);
                                    updateDisplay();
                                } else {
                                    mRecyclerView.setVisibility(View.GONE);
                                    singleLayout.setVisibility(View.VISIBLE);
                                    stopLoading();
                                    updateSingleDisplay();
                                }
                                updateGlobalCityList();
                            }
                        } else {
                            stopLoading();
                            Utils.psLog("Error in loading ShopList.");
                        }
                    } catch (JSONException e) {
                        Utils.psErrorLogE("Error in loading ShopList.", e);
                        stopLoading();
                        e.printStackTrace();
                    } catch (Exception e){
                        Utils.psErrorLog("Error in loading", e.getMessage());
                    }
                }
            },

            new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError ex) {
                    progressWheel.setVisibility(View.GONE);
                    stopLoading();
                    try {
                        display_message.setVisibility(View.VISIBLE);
                        display_message.setText(connectionError);
                    }catch (Exception e){
                        Utils.psErrorLogE("Error in Connection Url.", e);
                    }
                }
            });

    request.setRetryPolicy(new DefaultRetryPolicy(
            5000,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

    request.setShouldCache(false);
    VolleySingleton.getInstance(getActivity()).addToRequestQueue(request);
}

Я попытался отладить код. Вот скриншот. введите описание изображения здесь

Вот Logcat:

07-05 21: 20: 38.130 20632-20644 / com.logictex.usamapharmacy I / zygote: Фоновое одновременное копирование освободило GC 444 (367 КБ) объектов AllocSpace, 0 (0B) объектов LOS, 49% свободных, 1872 КБ / 3 МБ, приостановлено 7,903 мс 450.981ms 07-05 21: 20: 38.294 20632-20638 / com.logictex.usamapharmacy I / zygote: сбор полного кэша кода, код = 91 КБ, данные = 56 КБ 07-05 21: 20: 38.296 20632-20638 / com.logictex.usamapharmacy I / zygote: After сбор кеша кода, код = 91KB, данные = 45KB 07-05 21: 20: 38.557 20632-20632 / com.logictex.usamapharmacy I / Хореограф: пропущено 99 кадры! Приложение может делать слишком много работы на своем основном нить. 07-05 21: 20: 38.621 20632-20673 / com.logictex.usamapharmacy D / EGL_emulation: eglMakeCurrent: 0xa5b3ffa0: ver 2 0 (tinfo 0xa5becec0) 07-05 21: 20: 38.627 20632-20812 / com.logictex.usamapharmacy E / StudioProfiler: ошибка JVMTI: 15 (JVMTI_ERROR_THREAD_NOT_ALIVE) 07-05 21: 20: 38.631 20632-20812 / com.logictex.usamapharmacy I / chatty: uid = 10088 (u0_a88) hwuiTask1 идентичный 3 строки 07-05 21: 20: 38.631 20632-20812 / com.logictex.usamapharmacy E / StudioProfiler: ошибка JVMTI: 15 (JVMTI_ERROR_THREAD_NOT_ALIVE) 07-05 21: 20: 39.161 20632-20815 / com.logictex.usamapharmacy I / FirebaseCrash: отправка аварии 07-05 21: 20: 39.264 20632-20771 / com.logictex.usamapharmacy W / zygote: проверка пустоты com.android.tools.profiler.support.network.HttpTracker $ InputStreamTracker. (java.io.InputStream, com.android.tools.profiler.support.network.HttpTracker $ Connection) потребовалось 135,766мс 07-05 21:20:40,671 20632-20791 / com.logictex.usamapharmacy D / FirebaseInstanceId: тема синхронизация завершена 07-05 21:20:40 20632-20638 / com.logictex.usamapharmacy I / zygote: делать частичный кэш кода сбор, код = 122 КБ, данные = 85 КБ 07-05 21: 20: 40,738 20632-20638 / com.logictex.usamapharmacy I / zygote: после кэширования кода коллекция, код = 122 КБ, данные = 85 КБ Увеличение емкости кэша кода до 512 КБ 07-05 21: 20: 41.301 20632-20632 / com.logictex.usamapharmacy D / TEAMPS: Ответ> { "Статус": "Успех", "данные": [{ "ID": "1", "имя": "Лекарство", "Описание": "Все лекарство вашего нужно "" телефон. ":" " "электронная почта": "", "адрес": "", "координата": "", "ш": "0.000000", "LNG": "0.000000"," paypal_email ":"», "paypal_environment": "", "paypal_appid_live": "", "paypal_merchantname": "", "paypal_customerid": "", "paypal_ipnurl": "", "paypal_memo": "", "BANK_ACCOUNT" : "", "BANK_NAME": "", "bank_code": "", "branch_code": "", "swift_code": "", "cod_email": "", "stripe_publishable_key": "", "stripe_secret_key": "", "currency_symbol": "", "currency_short_form": "", "SENDER_EMAIL": "", "добавил": "2018-03-24 9:06:38" , "Статус": "1", "paypal_enabled": "0", "stripe_enabled": "0", "cod_enabled": "0", "banktransfer_enabled": "0", "ITEM_COUNT" : 132, "category_count": 3, "sub_category_count": 15, "follow_count": 0, "cover_image_file": "unnamed.jpg", "cover_image_width": "512", "cover_image_height": "341", "cover_image_description" : "", "категории": [{ "ID": "1", "shop_id": "", "название 1": "Компании", "is_published": "1", "заказные": "0", "добавил": "2018-04-04 8:47:51" , "обновленный": нулевой, "cover_image_file": "", "cover_image_width": "", "cover_image_height": "", "sub_categories": [{ "ID": "1", "cat_id ":" 1" , "shop_id": "1", "имя": "Abbott", "is_published": "1", "упорядоченность": "0", "добавил": "2018-04-04 8:53:09" , "обновленный": нулевой, "cover_image_file": "Abbott.jpg", "cover_image_width": "1910", "cover_image_height": "1000"}, { "ID": "2",» cat_id ":" 1" , "shop_id": "1", "имя": "АдамJee " "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:53:39" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "3", "cat_id": "1 " "shop_id": "1", "имя": "AGP", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:53:59" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "4", "cat_id": "1 " "shop_id": "1", "имя": "Amson", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:54:12" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "5", "cat_id": "1 " "shop_id": "1", "имя":" Азиатский Continental " "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:54:26" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "6", "cat_id": "1 " "shop_id": "1", "имя": "Atco", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:54:44" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "7", "cat_id": "1 " "shop_id": "1", "имя": "Barrett", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:55:07" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "8", "cat_id": "1 " "shop_id": "1", "имя": "Байер", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:55:14" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "9", "cat_id": "1 " "shop_id": "1", "имя": "Bosch", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:55:21" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "10", "cat_id": "1 " "shop_id": "1", "имя": "Брукс", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:55:29" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "11", "cat_id": "1 " "shop_id": "1", "имя": "Chiesi", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:55:54" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "12", "cat_id": "1 " "shop_id": "1", "имя":" Дон Долина " "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:56:02" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "13", "cat_id": "1 " "shop_id": "1", "имя": "Этические", "is_published": "1", "упорядоченность": "0", "добавил":" 2018-04-04 8:56:11" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "14", "cat_id": "1 "," shop_id ":" 1 "," name ":" Excel Health Care "," is_published ":" 1 "," ordering ":" 0 "," добавлено ":" 2018-04-04 8:56:31" , "обновление": NULL, "cover_image_file": "", "cover_image_width": "", "cover_image_height": ""}, { "идентификатор": "15", "cat_id": "1 "," shop_id ":" 1 "," name ":" Ferosons "," is_published ":" 1 "," ordering "07-05 21: 20: 42.369 20632-20632 / com.logictex.usamapharmacy D / TEAMPS: Ошибка при загрузке 07-05 21: 20: 42.392 20632-20632 / com.logictex.usamapharmacy D / TEAMPS: Линия: 323 07-05 21: 20: 42.398 20632-20632 / com.logictex.usamapharmacy D / TEAMPS: Класс: класс java.lang.String 07-05 21: 20: 42.402 20632-20632 / com.logictex.usamapharmacy I / Хореограф: пропущено 70 кадры! Приложение может делать слишком много работы на своем основном нить. 07-05 21: 20: 42.812 20632-20666 / com.logictex.usamapharmacy V / FA: бездействие, отключение от услуги

...