forked from github/szkolny
[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.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.work.*
|
import androidx.work.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@ -79,11 +80,15 @@ class UpdateWorker(val context: Context, val params: WorkerParameters) : Worker(
|
|||||||
val update = if (overrideUpdate == null) {
|
val update = if (overrideUpdate == null) {
|
||||||
val api = SzkolnyApi(app)
|
val api = SzkolnyApi(app)
|
||||||
val response = api.getUpdate("beta")
|
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
|
return
|
||||||
|
}
|
||||||
val updates = response.data
|
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
|
return
|
||||||
|
}
|
||||||
updates[0]
|
updates[0]
|
||||||
}
|
}
|
||||||
else overrideUpdate
|
else overrideUpdate
|
||||||
|
@ -1165,4 +1165,5 @@
|
|||||||
<string name="notification_type_new_shared_homework">Udostępniono zadanie domowe</string>
|
<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_type_removed_shared_event">Usunięto wydarzenie</string>
|
||||||
<string name="notification_click_to_see_all">Kliknij, aby zobaczyć wszystkie powiadomienia</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>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user