Skip to content

Commit 36a4b7d

Browse files
A generalised message for exceptions in Nearby Activity [issue commons-app#1504]
1 parent 20d3c37 commit 36a4b7d

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyActivity.java

+4-13
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,8 @@ private void refreshView(LocationServiceManager.LocationChangeType locationChang
435435
.observeOn(AndroidSchedulers.mainThread())
436436
.subscribe(this::populatePlaces,
437437
throwable -> {
438-
if (throwable instanceof UnknownHostException || throwable instanceof ConnectException) {
439-
showErrorMessage(getString(R.string.slow_internet));
440-
} else {
441-
showErrorMessage(throwable.getMessage());
442-
}
438+
Timber.d(throwable);
439+
showErrorMessage(getString(R.string.error_fetching_nearby_places));
443440
progressBar.setVisibility(View.GONE);
444441
});
445442
} else if (locationChangeType
@@ -597,11 +594,8 @@ private void updateMapFragment(boolean isSlightUpdate) {
597594
.observeOn(AndroidSchedulers.mainThread())
598595
.subscribe(this::populatePlaces,
599596
throwable -> {
600-
if (throwable instanceof UnknownHostException || throwable instanceof ConnectException) {
601-
showErrorMessage(getString(R.string.slow_internet));
602-
} else {
603-
showErrorMessage(throwable.getMessage());
604-
}
597+
Timber.d(throwable);
598+
showErrorMessage(getString(R.string.error_fetching_nearby_places));
605599
progressBar.setVisibility(View.GONE);
606600
});
607601
nearbyMapFragment.setBundleForUpdtes(bundle);
@@ -671,9 +665,6 @@ public void prepareViewsForSheetPosition(int bottomSheetState) {
671665
}
672666

673667
private void showErrorMessage(String message) {
674-
if (TextUtils.isEmpty(message)) {
675-
message = getString(R.string.something_went_wrong);
676-
}
677668
ViewUtil.showLongToast(NearbyActivity.this, message);
678669
}
679670
}

app/src/main/res/values/strings.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@
282282

283283
<string name="share_app_title">Share App</string>
284284
<string name="share_coordinates_not_present">Coordinates were not specified during image selection</string>
285-
<string name="something_went_wrong">Something went wrong</string>
286-
<string name="slow_internet">You seem to have slow internet connection</string>
285+
<string name="error_fetching_nearby_places">Error fetching nearby places.</string>
287286

288287
</resources>

0 commit comments

Comments
 (0)