From ed9b1c8ba7d5b3074aa2269b0888a71b1d0f659f Mon Sep 17 00:00:00 2001 From: Amine Date: Wed, 1 Nov 2017 18:13:54 +0100 Subject: [PATCH] Only reporting the issue if there is an issue. --- .../amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt | 2 +- .../amine/bou/readerforselfoss/adapters/ItemListAdapter.kt | 2 +- .../java/apps/amine/bou/readerforselfoss/utils/ApiUtils.kt | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/apps/amine/bou/readerforselfoss/utils/ApiUtils.kt diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt index 126669a..e8a69b8 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemCardAdapter.kt @@ -125,7 +125,7 @@ class ItemCardAdapter(private val app: Activity, api.markItem(i.id).enqueue(object : Callback { override fun onResponse(call: Call, response: Response) { - if (debugReadingItems) { + if (!response.succeeded() && debugReadingItems) { val message = "message: ${response.message()} " + "response isSuccess: ${response.isSuccessful} " + diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt index 0821aff..cfe63d9 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt @@ -138,7 +138,7 @@ class ItemListAdapter(private val app: Activity, api.markItem(i.id).enqueue(object : Callback { override fun onResponse(call: Call, response: Response) { - if (debugReadingItems) { + if (!response.succeeded() && debugReadingItems) { val message = "message: ${response.message()} " + "response isSuccess: ${response.isSuccessful} " + diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/ApiUtils.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/ApiUtils.kt new file mode 100644 index 0000000..4f9c3cc --- /dev/null +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/ApiUtils.kt @@ -0,0 +1,7 @@ +package apps.amine.bou.readerforselfoss.utils + +import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse +import retrofit2.Response + +fun Response.succeeded(): Boolean = + this.code() === 200 && this.body() != null && this.body()!!.isSuccess \ No newline at end of file