add a helper function for checking if google sync is active

This commit is contained in:
tibbi 2017-07-23 23:05:20 +02:00
parent c6f716206f
commit d95152d53c
4 changed files with 15 additions and 2 deletions

View File

@ -470,6 +470,13 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
} else {
toast(R.string.event_added)
}
if (isGoogleSyncActive()) {
if (isOnline()) {
createRemoteGoogleEvent()
}
}
finish()
}
} else {
@ -493,6 +500,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
}
}
private fun createRemoteGoogleEvent() {
}
private fun updateStartTexts() {
updateStartDateText()
updateStartTimeText()

View File

@ -90,7 +90,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
config.googleSync = false
}
if (config.googleSync && config.syncAccountName.isNotEmpty()) {
if (isGoogleSyncActive()) {
FetchGoogleEventsTask(this, googleSyncListener).execute()
}
}

View File

@ -109,7 +109,7 @@ class SettingsActivity : SimpleActivity() {
}
private fun setupGoogleSync() {
settings_google_sync.isChecked = config.googleSync
settings_google_sync.isChecked = isGoogleSyncActive()
settings_google_sync_holder.setOnClickListener {
if (config.googleSync) {
ConfirmationDialog(this, getString(R.string.google_sync_disabling), positive = R.string.ok, negative = R.string.cancel) {

View File

@ -249,6 +249,8 @@ fun Context.getNewEventTimestampFromCode(dayCode: String) = Formatter.getLocalDa
fun Context.getCurrentOffset() = SimpleDateFormat("Z", Locale.getDefault()).format(Date())
fun Context.isGoogleSyncActive() = config.googleSync && config.syncAccountName.isNotEmpty()
val Context.config: Config get() = Config.newInstance(this)
val Context.dbHelper: DBHelper get() = DBHelper.newInstance(this)