From 545e09643cd71cedfa0ddfb6e0da76fba9cbacdb Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Sun, 3 Nov 2024 21:54:53 +0530 Subject: [PATCH] Format code --- .../calendar/views/MonthViewWrapper.kt | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/views/MonthViewWrapper.kt b/app/src/main/kotlin/org/fossify/calendar/views/MonthViewWrapper.kt index 82f8b7060..415161552 100644 --- a/app/src/main/kotlin/org/fossify/calendar/views/MonthViewWrapper.kt +++ b/app/src/main/kotlin/org/fossify/calendar/views/MonthViewWrapper.kt @@ -10,7 +10,11 @@ import org.fossify.calendar.databinding.MonthViewBinding import org.fossify.calendar.extensions.config import org.fossify.calendar.extensions.launchNewEventIntent import org.fossify.calendar.extensions.launchNewTaskIntent -import org.fossify.calendar.helpers.* +import org.fossify.calendar.helpers.COLUMN_COUNT +import org.fossify.calendar.helpers.Formatter +import org.fossify.calendar.helpers.ROW_COUNT +import org.fossify.calendar.helpers.TYPE_EVENT +import org.fossify.calendar.helpers.TYPE_TASK import org.fossify.calendar.models.DayMonthly import org.fossify.commons.compose.extensions.getActivity import org.fossify.commons.dialogs.RadioGroupDialog @@ -18,7 +22,11 @@ import org.fossify.commons.extensions.onGlobalLayout import org.fossify.commons.models.RadioItem // used in the Monthly view fragment, 1 view per screen -class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : FrameLayout(context, attrs, defStyle) { +class MonthViewWrapper( + context: Context, + attrs: AttributeSet, + defStyle: Int +) : FrameLayout(context, attrs, defStyle) { private var dayWidth = 0f private var dayHeight = 0f private var weekDaysLetterHeight = 0 @@ -33,7 +41,8 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) init { - val normalTextSize = resources.getDimensionPixelSize(org.fossify.commons.R.dimen.normal_text_size).toFloat() + val normalTextSize = + resources.getDimensionPixelSize(org.fossify.commons.R.dimen.normal_text_size).toFloat() weekDaysLetterHeight = 2 * normalTextSize.toInt() inflater = LayoutInflater.from(context) @@ -76,7 +85,12 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F val childRight = childLeft + childWidth val childBottom = childTop + childHeight - child.layout(childLeft.toInt(), childTop.toInt(), childRight.toInt(), childBottom.toInt()) + child.layout( + childLeft.toInt(), + childTop.toInt(), + childRight.toInt(), + childBottom.toInt() + ) if (curLeft + childWidth <= end) { curLeft += childWidth @@ -89,7 +103,11 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F } } - fun updateDays(newDays: ArrayList, addEvents: Boolean, callback: ((DayMonthly) -> Unit)? = null) { + fun updateDays( + newDays: ArrayList, + addEvents: Boolean, + callback: ((DayMonthly) -> Unit)? = null + ) { setupHorizontalOffset() measureSizes() dayClickCallback = callback @@ -132,7 +150,12 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F background = null } //Accessible label composed by day and month - contentDescription = "${day.value} ${Formatter.getMonthName(context, Formatter.getDateTimeFromCode(day.code).monthOfYear)}" + contentDescription = "${day.value} ${ + Formatter.getMonthName( + context, + Formatter.getDateTimeFromCode(day.code).monthOfYear + ) + }" setOnClickListener { dayClickCallback?.invoke(day) @@ -142,7 +165,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F } } - setOnLongClickListener{ + setOnLongClickListener { if (context.config.allowCreatingTasks) { val items = arrayListOf( RadioItem(TYPE_EVENT, context.getString(R.string.event)), @@ -156,8 +179,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F context.launchNewTaskIntent(day.code) } } - } - else{ + } else { context.launchNewEventIntent(day.code) } true