[Updates] Add toast for error while checking and for no updates.

This commit is contained in:
Kuba Szczodrzyński 2020-01-19 22:35:12 +01:00
parent 0eb8366027
commit eedbd954bd
2 changed files with 8 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.text.Html
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.work.*
import kotlinx.coroutines.CoroutineScope
@ -79,11 +80,15 @@ class UpdateWorker(val context: Context, val params: WorkerParameters) : Worker(
val update = if (overrideUpdate == null) {
val api = SzkolnyApi(app)
val response = api.getUpdate("beta")
if (response?.success != true)
if (response?.success != true) {
Toast.makeText(app, app.getString(R.string.notification_cant_check_update), Toast.LENGTH_SHORT).show()
return
}
val updates = response.data
if (updates?.isNotEmpty() != true)
if (updates?.isNotEmpty() != true) {
Toast.makeText(app, app.getString(R.string.notification_no_update), Toast.LENGTH_SHORT).show()
return
}
updates[0]
}
else overrideUpdate

View File

@ -1165,4 +1165,5 @@
<string name="notification_type_new_shared_homework">Udostępniono zadanie domowe</string>
<string name="notification_type_removed_shared_event">Usunięto wydarzenie</string>
<string name="notification_click_to_see_all">Kliknij, aby zobaczyć wszystkie powiadomienia</string>
<string name="notification_cant_check_update">Nie udało się sprawdzić aktualizacji</string>
</resources>