make mCalendar of the widget nullable

This commit is contained in:
tibbi 2016-11-21 00:07:21 +01:00
parent 2f59421909
commit f1044a82c1

View File

@ -30,8 +30,8 @@ class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar {
private var mTodayTextSize = 0f private var mTodayTextSize = 0f
private var mTextColor = 0 private var mTextColor = 0
private var mWeakTextColor = 0 private var mWeakTextColor = 0
private var mCalendar: MonthlyCalendarImpl? = null
lateinit var mCalendar: MonthlyCalendarImpl
lateinit var mRemoteViews: RemoteViews lateinit var mRemoteViews: RemoteViews
lateinit var mRes: Resources lateinit var mRes: Resources
lateinit var mContext: Context lateinit var mContext: Context
@ -68,7 +68,7 @@ class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar {
val bgColor = prefs.getInt(WIDGET_BG_COLOR, Color.BLACK) val bgColor = prefs.getInt(WIDGET_BG_COLOR, Color.BLACK)
mRemoteViews.setInt(R.id.calendar_holder, "setBackgroundColor", bgColor) mRemoteViews.setInt(R.id.calendar_holder, "setBackgroundColor", bgColor)
mCalendar.updateMonthlyCalendar(DateTime()) mCalendar?.updateMonthlyCalendar(DateTime())
} }
private fun updateWidget() { private fun updateWidget() {
@ -108,8 +108,8 @@ class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
val action = intent.action val action = intent.action
when (action) { when (action) {
PREV -> mCalendar.getPrevMonth() PREV -> mCalendar?.getPrevMonth()
NEXT -> mCalendar.getNextMonth() NEXT -> mCalendar?.getNextMonth()
else -> super.onReceive(context, intent) else -> super.onReceive(context, intent)
} }
} }