clear Google sync queue if google sync is turned off

This commit is contained in:
tibbi 2017-07-27 20:58:40 +02:00
parent 20a5ef2a69
commit 8160443ac5
2 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import android.content.Context
import android.media.RingtoneManager import android.media.RingtoneManager
import android.text.format.DateFormat import android.text.format.DateFormat
import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.googleSyncQueue
import com.simplemobiletools.calendar.extensions.scheduleGoogleSync import com.simplemobiletools.calendar.extensions.scheduleGoogleSync
import com.simplemobiletools.commons.helpers.BaseConfig import com.simplemobiletools.commons.helpers.BaseConfig
import java.util.* import java.util.*
@ -75,6 +76,9 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(GOOGLE_SYNC, false) get() = prefs.getBoolean(GOOGLE_SYNC, false)
set(googleSync) { set(googleSync) {
context.scheduleGoogleSync(googleSync) context.scheduleGoogleSync(googleSync)
if (!googleSync)
context.googleSyncQueue.clearQueue()
prefs.edit().putBoolean(GOOGLE_SYNC, googleSync).apply() prefs.edit().putBoolean(GOOGLE_SYNC, googleSync).apply()
} }

View File

@ -71,4 +71,8 @@ class GoogleSyncQueueDB private constructor(val context: Context) : SQLiteOpenHe
val selection = "$COL_EVENT_ID = $eventId" val selection = "$COL_EVENT_ID = $eventId"
mDb.delete(OPERATIONS_TABLE_NAME, selection, null) mDb.delete(OPERATIONS_TABLE_NAME, selection, null)
} }
fun clearQueue() {
mDb.delete(OPERATIONS_TABLE_NAME, null, null)
}
} }