Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Commit

Permalink
fix: paper analysis
Browse files Browse the repository at this point in the history
topic number and text answer layout
  • Loading branch information
JingBh committed Feb 12, 2022
1 parent a15347b commit 9c9bbd2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,6 @@ class PaperAnalysisActivity : AppCompatActivity() {
}
}

/*lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.uiState
.map { it.selectedIndex }
.filter { it >= 0 }
.distinctUntilChanged()
.collectLatest {
indexAdapter.notifyItemChanged(it)
binding.list.smoothScrollToPosition(it)
}
}
}*/

lifecycleScope.launch {
viewModel.analysis
.collectLatest { analysis ->
Expand Down Expand Up @@ -214,14 +201,21 @@ class PaperAnalysisActivity : AppCompatActivity() {
private val binding: ItemPaperAnalysisIndexBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(topic: ExamPaperTopic, selected: Boolean = false) {
binding.text.text = topic.id.toString()
binding.text.setTextColor(
when (topic.getCorrectness()) {
ExamPaperTopic.Correctness.CORRECT -> colorCorrectRoles.accent
ExamPaperTopic.Correctness.HALF_CORRECT -> colorHalfCorrectRoles.accent
ExamPaperTopic.Correctness.WRONG -> colorWrongRoles.accent
binding.text.apply {
text = topic.title.let { title ->
if (title.length > 2) {
title.substring(0, 2)
} else title
}
)

setTextColor(
when (topic.getCorrectness()) {
ExamPaperTopic.Correctness.CORRECT -> colorCorrectRoles.accent
ExamPaperTopic.Correctness.HALF_CORRECT -> colorHalfCorrectRoles.accent
ExamPaperTopic.Correctness.WRONG -> colorWrongRoles.accent
}
)
}

binding.root.isSelected = selected
if (!selected) binding.root.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PaperAnalysisTopicViewHolder private constructor(
private val context = binding.root.context

fun bind(topic: ExamPaperTopic) {
binding.title.text = context.getString(R.string.paper_topic_title, topic.id)
binding.title.text = context.getString(R.string.paper_topic_title, topic.title)

binding.userAnswerCard.apply {
val answerLayout = when (topic.type) {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/layout_topic_text_answer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/answerText"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="8dp"
android:textAppearance="?attr/textAppearanceHeadlineMedium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/answerTitle"
app:layout_constraintVertical_bias="0.0"
tools:text="A" />
Expand Down

0 comments on commit 9c9bbd2

Please sign in to comment.