mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 04:10:45 +01:00
make widget variables non static
This commit is contained in:
parent
fbaf5b6f1e
commit
4884a4ce39
@ -36,12 +36,8 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPrevMonth() {
|
fun getMonth(targetDate: DateTime) {
|
||||||
updateMonthlyCalendar(mTargetDate.minusMonths(1))
|
updateMonthlyCalendar(targetDate)
|
||||||
}
|
|
||||||
|
|
||||||
fun getNextMonth() {
|
|
||||||
updateMonthlyCalendar(mTargetDate.plusMonths(1))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDays() {
|
fun getDays() {
|
||||||
|
@ -22,15 +22,13 @@ class MyWidgetListProvider : AppWidgetProvider() {
|
|||||||
private val NEW_EVENT = "new_event"
|
private val NEW_EVENT = "new_event"
|
||||||
private val LAUNCH_TODAY = "launch_today"
|
private val LAUNCH_TODAY = "launch_today"
|
||||||
|
|
||||||
companion object {
|
private var mTextColor = 0
|
||||||
private var mTextColor = 0
|
|
||||||
|
|
||||||
lateinit var mRemoteViews: RemoteViews
|
lateinit var mRemoteViews: RemoteViews
|
||||||
lateinit var mRes: Resources
|
lateinit var mRes: Resources
|
||||||
lateinit var mWidgetManager: AppWidgetManager
|
lateinit var mWidgetManager: AppWidgetManager
|
||||||
lateinit var mIntent: Intent
|
lateinit var mIntent: Intent
|
||||||
lateinit var mContext: Context
|
lateinit var mContext: Context
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||||
initVariables(context)
|
initVariables(context)
|
||||||
|
@ -23,20 +23,22 @@ import com.simplemobiletools.commons.extensions.adjustAlpha
|
|||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
||||||
|
private val PREV = "prev"
|
||||||
|
private val NEXT = "next"
|
||||||
|
private val NEW_EVENT = "new_event"
|
||||||
|
|
||||||
|
private var mTextColor = 0
|
||||||
|
private var mWeakTextColor = 0
|
||||||
|
private var mCalendar: MonthlyCalendarImpl? = null
|
||||||
|
private var mRemoteViews: RemoteViews? = null
|
||||||
|
|
||||||
|
lateinit var mRes: Resources
|
||||||
|
lateinit var mContext: Context
|
||||||
|
lateinit var mWidgetManager: AppWidgetManager
|
||||||
|
lateinit var mIntent: Intent
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val PREV = "prev"
|
private var mTargetDate = DateTime()
|
||||||
private val NEXT = "next"
|
|
||||||
private val NEW_EVENT = "new_event"
|
|
||||||
|
|
||||||
private var mTextColor = 0
|
|
||||||
private var mWeakTextColor = 0
|
|
||||||
private var mCalendar: MonthlyCalendarImpl? = null
|
|
||||||
private var mRemoteViews: RemoteViews? = null
|
|
||||||
|
|
||||||
lateinit var mRes: Resources
|
|
||||||
lateinit var mContext: Context
|
|
||||||
lateinit var mWidgetManager: AppWidgetManager
|
|
||||||
lateinit var mIntent: Intent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||||
@ -63,8 +65,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
|||||||
updateTopViews()
|
updateTopViews()
|
||||||
|
|
||||||
mRemoteViews?.setInt(R.id.calendar_holder, "setBackgroundColor", config.widgetBgColor)
|
mRemoteViews?.setInt(R.id.calendar_holder, "setBackgroundColor", config.widgetBgColor)
|
||||||
|
mCalendar?.updateMonthlyCalendar(mTargetDate, false)
|
||||||
mCalendar?.updateMonthlyCalendar(DateTime(), false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateWidget() {
|
private fun updateWidget() {
|
||||||
@ -107,13 +108,23 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
|||||||
|
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
when (action) {
|
when (action) {
|
||||||
PREV -> mCalendar?.getPrevMonth()
|
PREV -> getPrevMonth()
|
||||||
NEXT -> mCalendar?.getNextMonth()
|
NEXT -> getNextMonth()
|
||||||
NEW_EVENT -> mContext.launchNewEventIntent(true)
|
NEW_EVENT -> mContext.launchNewEventIntent(true)
|
||||||
else -> super.onReceive(context, intent)
|
else -> super.onReceive(context, intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getPrevMonth() {
|
||||||
|
mTargetDate = mTargetDate.minusMonths(1)
|
||||||
|
mCalendar?.getMonth(mTargetDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getNextMonth() {
|
||||||
|
mTargetDate = mTargetDate.plusMonths(1)
|
||||||
|
mCalendar?.getMonth(mTargetDate)
|
||||||
|
}
|
||||||
|
|
||||||
fun updateDays(days: List<Day>) {
|
fun updateDays(days: List<Day>) {
|
||||||
val displayWeekNumbers = mContext.config.displayWeekNumbers
|
val displayWeekNumbers = mContext.config.displayWeekNumbers
|
||||||
val len = days.size
|
val len = days.size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user