Display error if online reviews can't be loaded

This commit is contained in:
xynngh 2020-06-09 14:41:41 +04:00
parent c9f5f58245
commit 3f41da709d
4 changed files with 13 additions and 4 deletions

View File

@ -93,6 +93,11 @@ public class ReviewsActivity extends AppCompatActivity {
} }
private void handleReviews(List<CommunityReview> reviews) { private void handleReviews(List<CommunityReview> reviews) {
if (reviews == null) {
setText(getString(R.string.reviews_loading_error));
return;
}
listViewAdapter.setItems(reviews); listViewAdapter.setItems(reviews);
listViewAdapter.notifyDataSetChanged(); listViewAdapter.notifyDataSetChanged();
displaySummary(reviews); displaySummary(reviews);

View File

@ -38,14 +38,14 @@ public class CommunityReviewsLoader {
WebService.WSResponse response = webService.callForJson(webService.getGetReviewsUrlPart(), params); WebService.WSResponse response = webService.callForJson(webService.getGetReviewsUrlPart(), params);
List<CommunityReview> reviews = new ArrayList<>();
if (response == null || !response.getSuccessful()) { if (response == null || !response.getSuccessful()) {
LOG.warn("loadReviews() response is not successful"); LOG.warn("loadReviews() response is not successful");
return reviews; return null;
} }
try { try {
List<CommunityReview> reviews = new ArrayList<>();
// response.getJsonObject(): // response.getJsonObject():
// "success": boolean // "success": boolean
// "nn": String number starting with "+" // "nn": String number starting with "+"
@ -68,10 +68,12 @@ public class CommunityReviewsLoader {
} }
LOG.trace("loadReviews() loaded {} reviews", reviews.size()); LOG.trace("loadReviews() loaded {} reviews", reviews.size());
return reviews;
} catch (JSONException e) { } catch (JSONException e) {
LOG.error("loadReviews()", e); LOG.error("loadReviews()", e);
} }
return reviews; return null;
} }
} }

View File

@ -35,6 +35,7 @@
<string name="incoming_call_notifications_summary">Отображает уведомление с краткой информацией о номере (рейтинги, кол-во отзывов, категория) при входящих вызовах</string> <string name="incoming_call_notifications_summary">Отображает уведомление с краткой информацией о номере (рейтинги, кол-во отзывов, категория) при входящих вызовах</string>
<string name="title_activity_reviews">Отзывы</string> <string name="title_activity_reviews">Отзывы</string>
<string name="reviews_loading">Загружаем отзывы…</string> <string name="reviews_loading">Загружаем отзывы…</string>
<string name="reviews_loading_error">Ошибка загрузки отзывов</string>
<string name="sia_category_fax">Факс</string> <string name="sia_category_fax">Факс</string>
<string name="sia_category_nuisance">Злонамеренный</string> <string name="sia_category_nuisance">Злонамеренный</string>
<string name="sia_category_unsolicited">Нежелательный</string> <string name="sia_category_unsolicited">Нежелательный</string>

View File

@ -50,6 +50,7 @@
<string name="title_activity_reviews">Reviews</string> <string name="title_activity_reviews">Reviews</string>
<string name="reviews_loading">Loading reviews…</string> <string name="reviews_loading">Loading reviews…</string>
<string name="reviews_loading_error">Reviews loading error</string>
<string name="denied_permissions_message">Due to denied permissions following features may not work:</string> <string name="denied_permissions_message">Due to denied permissions following features may not work:</string>
<string name="feature_info">notifications</string> <string name="feature_info">notifications</string>