mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
fixing a crash at creating the monthly widget
This commit is contained in:
@ -19,6 +19,7 @@ import android.view.Gravity
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.RelativeLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@ -42,6 +43,7 @@ import com.simplemobiletools.calendar.pro.services.SnoozeService
|
|||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import kotlinx.android.synthetic.main.day_monthly_event_view.view.*
|
import kotlinx.android.synthetic.main.day_monthly_event_view.view.*
|
||||||
|
import kotlinx.android.synthetic.main.day_monthly_number_view.view.*
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import org.joda.time.DateTimeZone
|
import org.joda.time.DateTimeZone
|
||||||
import org.joda.time.LocalDate
|
import org.joda.time.LocalDate
|
||||||
@ -437,26 +439,29 @@ fun Context.addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: Linea
|
|||||||
if (!day.isThisMonth)
|
if (!day.isThisMonth)
|
||||||
textColor = textColor.adjustAlpha(LOWER_ALPHA)
|
textColor = textColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
(View.inflate(applicationContext, R.layout.day_monthly_number_view, null) as TextView).apply {
|
(View.inflate(applicationContext, R.layout.day_monthly_number_view, null) as RelativeLayout).apply {
|
||||||
setTextColor(textColor)
|
|
||||||
text = day.value.toString()
|
|
||||||
gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
|
||||||
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
linearLayout.addView(this)
|
linearLayout.addView(this)
|
||||||
|
|
||||||
if (day.isToday) {
|
day_monthly_number_id.apply {
|
||||||
val primaryColor = getAdjustedPrimaryColor()
|
setTextColor(textColor)
|
||||||
setTextColor(primaryColor.getContrastColor())
|
text = day.value.toString()
|
||||||
if (dayLabelHeight == 0) {
|
gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
||||||
onGlobalLayout {
|
|
||||||
val height = this@apply.height
|
if (day.isToday) {
|
||||||
if (height > 0) {
|
val primaryColor = getAdjustedPrimaryColor()
|
||||||
callback(height)
|
setTextColor(primaryColor.getContrastColor())
|
||||||
addTodaysBackground(this, resources, height, primaryColor)
|
if (dayLabelHeight == 0) {
|
||||||
|
onGlobalLayout {
|
||||||
|
val height = this@apply.height
|
||||||
|
if (height > 0) {
|
||||||
|
callback(height)
|
||||||
|
addTodaysBackground(this, resources, height, primaryColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
addTodaysBackground(this, resources, dayLabelHeight, primaryColor)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
addTodaysBackground(this, resources, dayLabelHeight, primaryColor)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user