Skip to content

Commit 1dc0a7c

Browse files
Vivek Maskaramisaochan
authored andcommitted
Fix resource not found exception with null checks (commons-app#1628)
1 parent 2e9af3c commit 1dc0a7c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,25 @@ private void setUploadCount() {
275275
.getUploadCount(sessionManager.getCurrentAccount().name)
276276
.subscribeOn(Schedulers.io())
277277
.observeOn(AndroidSchedulers.mainThread())
278-
.subscribe(
279-
uploadCount -> getSupportActionBar().setSubtitle(getResources()
280-
.getQuantityString(R.plurals.contributions_subtitle,
281-
uploadCount, uploadCount)),
278+
.subscribe(this::displayUploadCount,
282279
t -> Timber.e(t, "Fetching upload count failed")
283280
));
284281
}
285282

286-
public void betaSetUploadCount(int betaUploadCount){
283+
private void displayUploadCount(Integer uploadCount) {
284+
if (isFinishing()
285+
|| getSupportActionBar() == null
286+
|| getResources() == null) {
287+
return;
288+
}
289+
287290
getSupportActionBar().setSubtitle(getResources()
288-
.getQuantityString(R.plurals.contributions_subtitle, betaUploadCount, betaUploadCount));
291+
.getQuantityString(R.plurals.contributions_subtitle,
292+
uploadCount, uploadCount));
293+
}
294+
295+
public void betaSetUploadCount(int betaUploadCount) {
296+
displayUploadCount(betaUploadCount);
289297
}
290298

291299

0 commit comments

Comments
 (0)