Skip to content

Commit c4f159e

Browse files
ashishkumar468neslihanturan
authored andcommitted
BugFix invalid upload count string (commons-app#2989)
* Added non empty check in response.body() in OkHttpJsonApiClient$getUploadCount
1 parent cc0b059 commit c4f159e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/main/java/fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fr.free.nrw.commons.mwapi;
22

3+
import android.text.TextUtils;
34
import androidx.annotation.NonNull;
45
import androidx.annotation.Nullable;
56
import com.google.gson.Gson;
@@ -91,7 +92,9 @@ public Single<Integer> getUploadCount(String userName) {
9192
return Single.fromCallable(() -> {
9293
Response response = okHttpClient.newCall(request).execute();
9394
if (response != null && response.isSuccessful()) {
94-
return Integer.parseInt(response.body().string().trim());
95+
if(!TextUtils.isEmpty(response.body().string().trim())){
96+
return Integer.parseInt(response.body().string().trim());
97+
}
9598
}
9699
return 0;
97100
});

0 commit comments

Comments
 (0)