79341089

Date: 2025-01-09 00:43:46
Score: 3.5
Natty:
Report link

The error you got is that FrameLayout LayoutParams can't be cast to LinearLayout LayoutParams. This means that the error is caused by the LayoutParams of your LinearLayout being seen as that of a FrameLayout. Here is the fix you need.

linearLayout.updateLayoutParams<FrameLayout.LayoutParams> {
  setMargins(marginStart, marginTop, marginEnd, marginBottom)
}

However, I strongly suggest you update your when statement range to the code below as you are currently not covering all 24 hours (0 to 23)

when (currentHour) {
  in 0..11 -> { // Morning (0 AM - 11 AM)

  }
  in 12..17 -> { // Afternoon (12 PM - 5 PM)

  }
  in 18..23 -> { // Evening/Night (6 PM - 5 AM)

  }
  else -> { // Would not happen now!, but a default case

  }
}

Lastly! Like CommonsWare said, you're supposed to add the error log in your question so you can help others help you.

Cheers and Happy Coding.

Reasons:
  • Blacklisted phrase (1): Cheers
  • RegEx Blacklisted phrase (3): you can help
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Christophy Barth