mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-03-06 12:27:49 +01:00
show an error if fetching google events fails
This commit is contained in:
parent
617c56cefd
commit
dc5846f268
@ -37,7 +37,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.22.8'
|
||||
compile 'com.simplemobiletools:commons:2.23.0'
|
||||
compile 'joda-time:joda-time:2.9.1'
|
||||
compile 'com.facebook.stetho:stetho:1.4.1'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
|
@ -4,13 +4,18 @@ import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.AsyncTask
|
||||
import android.util.SparseIntArray
|
||||
import android.widget.Toast
|
||||
import com.google.api.client.googleapis.json.GoogleJsonResponseException
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.extensions.*
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.calendar.interfaces.GoogleSyncListener
|
||||
import com.simplemobiletools.calendar.models.*
|
||||
import com.simplemobiletools.commons.extensions.isOnMainThread
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
|
||||
@ -24,6 +29,7 @@ class FetchGoogleEventsTask(val context: Context, val googleSyncListener: Google
|
||||
private var eventTypes = ArrayList<EventType>()
|
||||
private var eventColors = SparseIntArray()
|
||||
private var service = context.getGoogleSyncService()
|
||||
private var parseError: Exception? = null
|
||||
|
||||
override fun doInBackground(vararg params: Void): String {
|
||||
if (!context.isGoogleSyncActive() || !context.isOnline())
|
||||
@ -56,12 +62,20 @@ class FetchGoogleEventsTask(val context: Context, val googleSyncListener: Google
|
||||
getColors()
|
||||
getDataFromApi()
|
||||
} catch (e: Exception) {
|
||||
cancel(true)
|
||||
parseError = e
|
||||
}
|
||||
googleSyncListener?.syncCompleted()
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun onPostExecute(result: String?) {
|
||||
super.onPostExecute(result)
|
||||
if (context.isOnMainThread() && parseError != null && parseError is GoogleJsonResponseException) {
|
||||
val msg = String.format(context.getString(R.string.google_sync_error_fetch), parseError!!.getGoogleMessageError())
|
||||
context.toast(msg, Toast.LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getColors() {
|
||||
val colors = service.colors().get().execute()
|
||||
for ((id, color) in colors.event.entries) {
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minuto</item>
|
||||
|
@ -211,6 +211,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d минута</item>
|
||||
|
@ -204,6 +204,7 @@
|
||||
<string name="google_sync_disabling">Vypnutie Google synchonizácie odstráni všetky synchronizované udalosti zo zariadenia, no v oblakoch ostanú nedotknuté.</string>
|
||||
<string name="google_sync_error_insert">Chyba pri nahrávaní udalosti na Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Chyba pri úprave udalosti na Googli: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Chyba pri čítaní Google udalostí: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minútu</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minut</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
@ -197,6 +197,7 @@
|
||||
<string name="google_sync_disabling">Disabling Google sync will delete all synced events from your device, while leaving them intact in the cloud.</string>
|
||||
<string name="google_sync_error_insert">Error uploading event to Google: %1$s</string>
|
||||
<string name="google_sync_error_update">Error updating event at Google: %1$s</string>
|
||||
<string name="google_sync_error_fetch">Error fetching Google events: %1$s</string>
|
||||
|
||||
<plurals name="minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user