Skip to content

Commit

Permalink
Hygiene a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
cooltey committed Jan 24, 2025
1 parent 1166d07 commit 76a5024
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ import java.time.Duration
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.temporal.WeekFields
import java.util.Locale

class OnThisDayGameFinalFragment : Fragment(), WeeklyActivityView.Callback {
class OnThisDayGameFinalFragment : Fragment() {
private var _binding: FragmentOnThisDayGameFinalBinding? = null
val binding get() = _binding!!

Expand Down Expand Up @@ -82,12 +81,6 @@ class OnThisDayGameFinalFragment : Fragment(), WeeklyActivityView.Callback {
super.onDestroyView()
}

override fun onDayClick(date: LocalDate) {
viewModel.resetCurrentDayState()
requireActivity().finish()
startActivity(OnThisDayGameActivity.newIntent(requireContext(), viewModel.invokeSource, date))
}

private fun updateOnLoading() {
binding.errorView.isVisible = false
binding.scrollContainer.isVisible = false
Expand All @@ -105,32 +98,12 @@ class OnThisDayGameFinalFragment : Fragment(), WeeklyActivityView.Callback {
binding.progressBar.isVisible = false
binding.errorView.isVisible = false
binding.scrollContainer.isVisible = true
val totalCorrect = gameState.answerState.count { it }
// binding.resultText.text = getString(R.string.on_this_day_game_result,
// totalCorrect,
// gameState.totalQuestions,
// getString(when (totalCorrect) {
// 0 -> R.string.on_this_day_game_encourage0
// 1 -> R.string.on_this_day_game_encourage1
// 2 -> R.string.on_this_day_game_encourage2
// else -> R.string.on_this_day_game_encourage3
// }))

val streak = calculateStreak(gameState.answerStateHistory)
// binding.streakText.text = StringUtil.fromHtml(resources.getQuantityString(R.plurals.on_this_day_game_streak, streak, streak))

// TODO: add stats

binding.resultArticlesList.layoutManager = LinearLayoutManager(requireContext())
binding.resultArticlesList.isNestedScrollingEnabled = false
binding.resultArticlesList.adapter = RecyclerViewAdapter(gameState.articles)

var displayStartDate = getStartOfWeekDate(OnThisDayGameViewModel.gameStartDate)
while (displayStartDate.isBefore(OnThisDayGameViewModel.gameEndDate)) {
val weekView = WeeklyActivityView(requireContext())
weekView.callback = this
binding.weeksContainer.addView(weekView)
weekView.setWeekStats(displayStartDate, gameState)
displayStartDate = displayStartDate.plusDays(7)
}
}

private inner class RecyclerViewAdapter(val pages: List<PageSummary>) : RecyclerView.Adapter<RecyclerViewItemHolder>() {
Expand Down Expand Up @@ -215,12 +188,6 @@ class OnThisDayGameFinalFragment : Fragment(), WeeklyActivityView.Callback {
}
}

fun getStartOfWeekDate(date: LocalDate, locale: Locale = Locale.getDefault()): LocalDate {
val firstDayOfWeek = WeekFields.of(locale).firstDayOfWeek
val daysToSubtract = ((7 + (date.dayOfWeek.value - firstDayOfWeek.value)) % 7).toLong()
return date.minusDays(daysToSubtract)
}

fun calculateStreak(answerStateHistory: Map<Int, Map<Int, Map<Int, List<Boolean>>>?>): Int {
var streak = 0
var date = LocalDate.now()
Expand Down

This file was deleted.

13 changes: 7 additions & 6 deletions app/src/main/res/layout/fragment_on_this_day_game_final.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
android:id="@+id/yourStatsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/H2.AppBar"
style="@style/H4"
android:textColor="?attr/primary_color"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/resultTextContainer"
Expand Down Expand Up @@ -213,7 +213,7 @@
android:id="@+id/resultSubtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="@style/H2.AppBar"
style="@style/H4"
android:textColor="?attr/primary_color"
android:layout_marginTop="32dp"
android:text="@string/on_this_day_game_result_subtitle"
Expand All @@ -234,16 +234,17 @@

</ScrollView>

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/shareButton"
style="@style/App.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/on_this_day_game_share"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:contentDescription="@null"/>
android:contentDescription="@string/on_this_day_game_share"
app:tint="?attr/background_color"
app:srcCompat="@drawable/ic_share"
app:backgroundTint="?attr/progressive_color"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
83 changes: 0 additions & 83 deletions app/src/main/res/layout/view_game_weekly_activity.xml

This file was deleted.

0 comments on commit 76a5024

Please sign in to comment.