-
Notifications
You must be signed in to change notification settings - Fork 159
дз custom view #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
дз custom view #119
Conversation
magendich
commented
Jun 2, 2025

makzimi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо за работу! Выглядит отлично, рисует всё как надо.
Одно, но важное замечание при отрисовки вьюшек - надо все создания объектов выносить из onDraw на пораньше. Для сдачи работы надо это поправить.
| val dailyExpenses = data.groupBy { it.time * 1000L } | ||
| .mapValues { it.value.sumOf { expense -> expense.amount } } | ||
| .toSortedMap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Каждый вызов groupBy, mapValues и toSortedMap создаёт новые коллекции. Лучше выносить эту логику из onDraw в setData
| for (i in 0..5) { | ||
| val time = dailyExpenses.firstKey() + dateStep * i | ||
| val x = paddingHorizontal + (time - dailyExpenses.firstKey()) * xScale | ||
| val date = Date(time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Каждая итерация создаёт объект Date. Это тоже плохо. В onDraw нельзя создавать новые объекты.
| if (gradientColors.isEmpty() && colors.isNotEmpty()) { | ||
| colors.forEach { | ||
| gradientColors += SweepGradient(width, height, it.first, it.second) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gradientColors += … создаёт новую коллекцию при каждом добавлении, а еще и создаем каждый раз SweepGradient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надо тоже это вынести из onDraw
| textPaint.textSize = 60f | ||
| textPaint.typeface = Typeface.DEFAULT_BOLD | ||
| val sumText = "$dataSum ₽" | ||
| val sumBounds = Rect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Даже Rect() не создаем
| textPaint.textSize = 40f | ||
| textPaint.typeface = Typeface.DEFAULT | ||
| val labelText = "Потрачено в Июне" | ||
| val labelBounds = Rect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И здесь тоже
| @@ -0,0 +1,21 @@ | |||
| FROM eclipse-temurin:17-jdk-jammy | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не будет ли контейнер больше, чем при openjdk?
| @@ -0,0 +1,21 @@ | |||
| FROM eclipse-temurin:17-jdk-jammy | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пробовали его использовать? Мне кажется что будет ругаться на недостачу пакетов
| @@ -0,0 +1,69 @@ | |||
| pipeline { | |||
| agent { | |||
| dockerfile true | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нужно указать название image и параметры