From 023d5b057f29a6cc45667999336c07c8c3f921fa Mon Sep 17 00:00:00 2001 From: Nikita Vorobev Date: Fri, 22 Sep 2023 20:29:17 +0100 Subject: [PATCH] fix #5150, simplify the margins' calculation This is just a proposal, will brush it up if the proposal is approved --- .../home/topiclist/TopicSummaryViewModel.kt | 64 +------------------ 1 file changed, 2 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt b/app/src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt index 36807c9d4cf..3e6edea086a 100755 --- a/app/src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt @@ -41,72 +41,12 @@ class TopicSummaryViewModel( topicSummaryClickListener.onTopicSummaryClicked(topicSummary) } - /** - * Determines the start margin for an individual TopicSummary relative to the grid columns laid out on the - * HomeActivity. GridLayout columns are evenly spread out across the entire activity screen but the - * Topic Summaries are positioned towards the center, so start margins are calculated to stagger inside each - * fixed column but centered on the activity's layout, as shown below. - * - * | _____| _____ | _____ |_____ | - * | | | | | | | | | | | - * | | | | | | | | | | | - * | |_____| |_____| | |_____| |_____| | - * | | | | | - * | _____ _____ _____ _____ | - * | | | | | | | | | | - * | | | | | | | | | | - * | |_____| |_____| |_____| |_____| | - * | | - */ fun computeStartMargin(): Int { - return when (spanCount) { - 2 -> when (position % spanCount) { - 0 -> outerMargin - else -> innerMargin - } - 3 -> when (position % spanCount) { - 0 -> outerMargin - 1 -> innerMargin - 2 -> 0 - else -> 0 - } - 4 -> when (position % spanCount) { - 0 -> outerMargin - 1 -> innerMargin - 2 -> innerMargin / 2 - 3 -> 0 - else -> 0 - } - else -> 0 - } + return outerMargin } - /** - * Determines the end margin for an individual TopicSummary relative to the grid columns laid out on the - * HomeActivity. The end margins are calculated to stagger inside each fixed column but centered on the - * activity's layout (see [computeStartMargin]). - */ fun computeEndMargin(): Int { - return when (spanCount) { - 2 -> when (position % spanCount) { - 0 -> innerMargin - else -> outerMargin - } - 3 -> when (position % spanCount) { - 0 -> 0 - 1 -> innerMargin - 2 -> outerMargin - else -> 0 - } - 4 -> when (position % spanCount) { - 0 -> 0 - 1 -> innerMargin / 2 - 2 -> innerMargin - 3 -> outerMargin - else -> 0 - } - else -> 0 - } + return innerMargin } fun computeLessonCountText(): String {