From 3f41da709d7ab1ffdaa838160660edd0672c6c67 Mon Sep 17 00:00:00 2001 From: xynngh Date: Tue, 9 Jun 2020 14:41:41 +0400 Subject: [PATCH] Display error if online reviews can't be loaded --- .../yetanothercallblocker/ReviewsActivity.java | 5 +++++ .../sia/model/CommunityReviewsLoader.java | 10 ++++++---- app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/dummydomain/yetanothercallblocker/ReviewsActivity.java b/app/src/main/java/dummydomain/yetanothercallblocker/ReviewsActivity.java index 5a56cb3..5048cc8 100644 --- a/app/src/main/java/dummydomain/yetanothercallblocker/ReviewsActivity.java +++ b/app/src/main/java/dummydomain/yetanothercallblocker/ReviewsActivity.java @@ -93,6 +93,11 @@ public class ReviewsActivity extends AppCompatActivity { } private void handleReviews(List reviews) { + if (reviews == null) { + setText(getString(R.string.reviews_loading_error)); + return; + } + listViewAdapter.setItems(reviews); listViewAdapter.notifyDataSetChanged(); displaySummary(reviews); diff --git a/app/src/main/java/dummydomain/yetanothercallblocker/sia/model/CommunityReviewsLoader.java b/app/src/main/java/dummydomain/yetanothercallblocker/sia/model/CommunityReviewsLoader.java index 6f646fa..0499c0a 100644 --- a/app/src/main/java/dummydomain/yetanothercallblocker/sia/model/CommunityReviewsLoader.java +++ b/app/src/main/java/dummydomain/yetanothercallblocker/sia/model/CommunityReviewsLoader.java @@ -38,14 +38,14 @@ public class CommunityReviewsLoader { WebService.WSResponse response = webService.callForJson(webService.getGetReviewsUrlPart(), params); - List reviews = new ArrayList<>(); - if (response == null || !response.getSuccessful()) { LOG.warn("loadReviews() response is not successful"); - return reviews; + return null; } try { + List reviews = new ArrayList<>(); + // response.getJsonObject(): // "success": boolean // "nn": String number starting with "+" @@ -68,10 +68,12 @@ public class CommunityReviewsLoader { } LOG.trace("loadReviews() loaded {} reviews", reviews.size()); + + return reviews; } catch (JSONException e) { LOG.error("loadReviews()", e); } - return reviews; + return null; } } diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 23d7e5c..d945c40 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -35,6 +35,7 @@ Отображает уведомление с краткой информацией о номере (рейтинги, кол-во отзывов, категория) при входящих вызовах Отзывы Загружаем отзывы… + Ошибка загрузки отзывов Факс Злонамеренный Нежелательный diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d31f613..acbd95a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -50,6 +50,7 @@ Reviews Loading reviews… + Reviews loading error Due to denied permissions following features may not work: notifications