This commit is contained in:
Tommaso Berlose
2020-05-16 12:47:29 +02:00
parent b04b103634
commit b81461f725
18 changed files with 59 additions and 33 deletions

View File

@ -102,6 +102,7 @@ object CalendarHelper {
if (eventList.isEmpty()) {
eventRepository.resetNextEventData()
eventRepository.clearEvents()
} else {
eventList.sortWith(Comparator { event: Event, event1: Event ->
if (event.allDay && event1.allDay) {
@ -134,6 +135,7 @@ object CalendarHelper {
MainWidget.updateWidget(context)
EventBus.getDefault().post(MainFragment.UpdateUiMessageEvent())
eventRepository.close()
}
fun getCalendarList(context: Context): List<me.everything.providers.android.calendar.Calendar> {

View File

@ -79,12 +79,15 @@ object GlanceProviderHelper {
}
fun showGlanceProviders(context: Context): Boolean {
return Preferences.showGlance && EventRepository(context).getEventsCount() == 0 && (
val eventRepository = EventRepository(context)
val showGlance = Preferences.showGlance && eventRepository.getEventsCount() == 0 && (
(Preferences.showNextAlarm && AlarmHelper.getNextAlarm(context) != "") ||
(MediaPlayerHelper.isSomeonePlaying(context)) ||
(Preferences.isBatteryLevelLow) ||
(Preferences.customNotes.isNotEmpty()) ||
(Preferences.showDailySteps && Preferences.googleFitSteps > 0)
)
eventRepository.close()
return showGlance
}
}

View File

@ -5,7 +5,6 @@ import android.content.Context
import android.os.Build
import com.google.android.gms.location.LocationServices
import com.tommasoberlose.anotherwidget.R
import com.tommasoberlose.anotherwidget.db.EventRepository
import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.network.WeatherNetworkApi