add a check at getting event types, if the activity is still alive

This commit is contained in:
tibbi 2017-11-14 09:19:08 +01:00
parent 343b7e00be
commit e49b349d6c
2 changed files with 7 additions and 4 deletions

View File

@ -47,7 +47,7 @@ ext {
} }
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.39.4' compile 'com.simplemobiletools:commons:2.39.5'
compile 'joda-time:joda-time:2.9.9' compile 'joda-time:joda-time:2.9.9'
compile 'com.facebook.stetho:stetho:1.5.0' compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'

View File

@ -16,6 +16,7 @@ import com.simplemobiletools.calendar.helpers.DAY_CODE
import com.simplemobiletools.calendar.helpers.Formatter import com.simplemobiletools.calendar.helpers.Formatter
import com.simplemobiletools.calendar.helpers.NEW_EVENT_START_TS import com.simplemobiletools.calendar.helpers.NEW_EVENT_START_TS
import com.simplemobiletools.calendar.interfaces.NavigationListener import com.simplemobiletools.calendar.interfaces.NavigationListener
import com.simplemobiletools.commons.extensions.isActivityDestroyed
import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.updateTextColors
import kotlinx.android.synthetic.main.activity_day.* import kotlinx.android.synthetic.main.activity_day.*
import org.joda.time.DateTime import org.joda.time.DateTime
@ -43,9 +44,11 @@ class DayActivity : SimpleActivity(), NavigationListener, ViewPager.OnPageChange
updateTextColors(day_coordinator) updateTextColors(day_coordinator)
dbHelper.getEventTypes { dbHelper.getEventTypes {
eventTypeColors.clear() if (!isActivityDestroyed()) {
it.map { eventTypeColors.put(it.id, it.color) } eventTypeColors.clear()
invalidateOptionsMenu() it.map { eventTypeColors.put(it.id, it.color) }
invalidateOptionsMenu()
}
} }
} }