Do nothing if ids are empty. More logging.

This commit is contained in:
Amine Bou 2018-03-30 19:54:21 +02:00
parent edb5eabee7
commit 18946464a2

View File

@ -1051,49 +1051,54 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
Crashlytics.logException(e) Crashlytics.logException(e)
} }
api.readAll(ids).enqueue(object : Callback<SuccessResponse> { if (ids.isNotEmpty()) {
override fun onResponse( api.readAll(ids).enqueue(object : Callback<SuccessResponse> {
call: Call<SuccessResponse>, override fun onResponse(
response: Response<SuccessResponse> call: Call<SuccessResponse>,
) { response: Response<SuccessResponse>
if (response.body() != null && response.body()!!.isSuccess) { ) {
Toast.makeText( if (response.body() != null && response.body()!!.isSuccess) {
this@HomeActivity, Toast.makeText(
R.string.all_posts_read, this@HomeActivity,
Toast.LENGTH_SHORT R.string.all_posts_read,
).show() Toast.LENGTH_SHORT
tabNewBadge.removeBadge() ).show()
} else { tabNewBadge.removeBadge()
} else {
Toast.makeText(
this@HomeActivity,
R.string.all_posts_not_read,
Toast.LENGTH_SHORT
).show()
if (debugReadingItems) {
readAllDebug(
Throwable(
"Got response, but : response.body() (${response.body()}) != null && response.body()!!.isSuccess (${response.body()?.isSuccess})." +
"Request url was (${call.request().url()}), ids were $ids"
)
)
}
}
swipeRefreshLayout.isRefreshing = false
}
override fun onFailure(call: Call<SuccessResponse>, t: Throwable) {
Toast.makeText( Toast.makeText(
this@HomeActivity, this@HomeActivity,
R.string.all_posts_not_read, R.string.all_posts_not_read,
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
swipeRefreshLayout.isRefreshing = false
if (debugReadingItems) { if (debugReadingItems) {
readAllDebug( readAllDebug(t)
Throwable("Got response, but : response.body() (${response.body()}) != null && response.body()!!.isSuccess (${response.body()?.isSuccess})")
)
} }
} }
})
swipeRefreshLayout.isRefreshing = false }
}
override fun onFailure(call: Call<SuccessResponse>, t: Throwable) {
Toast.makeText(
this@HomeActivity,
R.string.all_posts_not_read,
Toast.LENGTH_SHORT
).show()
swipeRefreshLayout.isRefreshing = false
if (debugReadingItems) {
readAllDebug(t)
}
}
})
items = ArrayList() items = ArrayList()
if (items.isEmpty()) { if (items.isEmpty()) {
Toast.makeText( Toast.makeText(