removing some redundant variables from the monthly widget config activity

This commit is contained in:
tibbi 2020-05-04 22:03:41 +02:00
parent 1fa0d25fc6
commit 85930394dd

View File

@ -4,7 +4,6 @@ import android.app.Activity
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.res.Resources
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.widget.LinearLayout import android.widget.LinearLayout
@ -30,9 +29,7 @@ import kotlinx.android.synthetic.main.widget_config_monthly.*
import org.joda.time.DateTime import org.joda.time.DateTime
class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
lateinit var mRes: Resources
private var mDays: List<DayMonthly>? = null private var mDays: List<DayMonthly>? = null
private var mPackageName = ""
private var dayLabelHeight = 0 private var dayLabelHeight = 0
private var mBgAlpha = 0f private var mBgAlpha = 0f
@ -70,9 +67,6 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
} }
private fun initVariables() { private fun initVariables() {
mPackageName = packageName
mRes = resources
mTextColorWithoutTransparency = config.widgetTextColor mTextColorWithoutTransparency = config.widgetTextColor
updateColors() updateColors()
@ -159,7 +153,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
week_num.beVisible() week_num.beVisible()
for (i in 0..5) { for (i in 0..5) {
findViewById<TextView>(mRes.getIdentifier("week_num_$i", "id", mPackageName)).apply { findViewById<TextView>(resources.getIdentifier("week_num_$i", "id", packageName)).apply {
text = "${mDays!![i * 7 + 3].weekOfYear}:" text = "${mDays!![i * 7 + 3].weekOfYear}:"
setTextColor(mTextColor) setTextColor(mTextColor)
beVisible() beVisible()
@ -167,14 +161,14 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
} }
} }
val dividerMargin = mRes.displayMetrics.density.toInt() val dividerMargin = resources.displayMetrics.density.toInt()
for (i in 0 until len) { for (i in 0 until len) {
findViewById<LinearLayout>(mRes.getIdentifier("day_$i", "id", mPackageName)).apply { findViewById<LinearLayout>(resources.getIdentifier("day_$i", "id", packageName)).apply {
val day = mDays!![i] val day = mDays!![i]
removeAllViews() removeAllViews()
context.addDayNumber(mTextColor, day, this, dayLabelHeight) { dayLabelHeight = it } context.addDayNumber(mTextColor, day, this, dayLabelHeight) { dayLabelHeight = it }
context.addDayEvents(day, this, mRes, dividerMargin) context.addDayEvents(day, this, resources, dividerMargin)
} }
} }
} }
@ -185,13 +179,9 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
updateBgColor() updateBgColor()
} }
override fun onStartTrackingTouch(seekBar: SeekBar) { override fun onStartTrackingTouch(seekBar: SeekBar) {}
} override fun onStopTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {
}
} }
override fun updateMonthlyCalendar(context: Context, month: String, days: ArrayList<DayMonthly>, checkedEvents: Boolean, currTargetDate: DateTime) { override fun updateMonthlyCalendar(context: Context, month: String, days: ArrayList<DayMonthly>, checkedEvents: Boolean, currTargetDate: DateTime) {
@ -204,7 +194,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private fun updateLabels() { private fun updateLabels() {
for (i in 0..6) { for (i in 0..6) {
findViewById<TextView>(mRes.getIdentifier("label_$i", "id", mPackageName)).apply { findViewById<TextView>(resources.getIdentifier("label_$i", "id", packageName)).apply {
setTextColor(mTextColor) setTextColor(mTextColor)
} }
} }