mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 12:20:51 +01:00
Refresh events when CalDAV sync is complete
This commit is contained in:
parent
09f5597afb
commit
67600acee6
@ -3,9 +3,7 @@ package com.simplemobiletools.calendar.pro.activities
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.SearchManager
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.*
|
||||
import android.content.pm.ShortcutInfo
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Icon
|
||||
@ -206,11 +204,15 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
main_toolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
val intentFilter = IntentFilter(ACTION_REFRESH_EVENTS)
|
||||
localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
storeStateVariables()
|
||||
localBroadcastManager.unregisterReceiver(broadcastReceiver)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@ -1360,4 +1362,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
checkWhatsNew(this, BuildConfig.VERSION_CODE)
|
||||
}
|
||||
}
|
||||
|
||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
if (intent?.action == ACTION_REFRESH_EVENTS) {
|
||||
refreshViewPager()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,8 +328,10 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
syncCalDAVCalendars {
|
||||
calDAVHelper.refreshCalendars(true, true) {
|
||||
calDAVHelper.refreshCalendars(showToasts = true, scheduleNextSync = true) {
|
||||
if (settings_caldav_sync.isChecked) {
|
||||
val broadcastIntent = Intent(ACTION_REFRESH_EVENTS)
|
||||
localBroadcastManager.sendBroadcast(broadcastIntent)
|
||||
toast(R.string.synchronization_completed)
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import android.widget.Toast
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.app.AlarmManagerCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.print.PrintHelper
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.EventActivity
|
||||
@ -57,6 +58,8 @@ val Context.completedTasksDB: TasksDao get() = EventsDatabase.getInstance(applic
|
||||
val Context.eventsHelper: EventsHelper get() = EventsHelper(this)
|
||||
val Context.calDAVHelper: CalDAVHelper get() = CalDAVHelper(this)
|
||||
|
||||
val Context.localBroadcastManager: LocalBroadcastManager get() = LocalBroadcastManager.getInstance(this)
|
||||
|
||||
fun Context.updateWidgets() {
|
||||
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetMonthlyProvider::class.java))
|
||||
?: return
|
||||
|
@ -227,6 +227,7 @@ const val IS_NEW_EVENT = "IS_NEW_EVENT"
|
||||
|
||||
// actions
|
||||
const val ACTION_MARK_COMPLETED = "ACTION_MARK_COMPLETED"
|
||||
const val ACTION_REFRESH_EVENTS = "ACTION_REFRESH_EVENTS"
|
||||
|
||||
fun getNowSeconds() = System.currentTimeMillis() / 1000L
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user