mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 19:04:38 -06:00
[Updates] Add toast for error while checking and for no updates.
This commit is contained in:
parent
0eb8366027
commit
eedbd954bd
@ -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
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user