Skip to content

Commit

Permalink
[chore/#55] 수정사항 및 통계 세부사항 화면 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
blueme0 committed Jun 11, 2024
1 parent 6fb4b77 commit 743b7ec
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class AddAssignmentActivity
binding.tvFab.text = "과제 수정하기"
}
with(binding) {
llBack.setOnSingleClickListener {
finish()
}

fab.setOnSingleClickListener {
if (addAssignmentViewModel.assignmentValid.value) {
if (isEditable) addAssignmentViewModel.editAssignment(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AddProblemPhotoActivity

subjects = Subject.values()
subject = subjects!![0]
if (tsubject != "") initForResultReview()
if (tsubject != null) initForResultReview()
chapters = subject!!.chapters
chapter = chapters!![0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class AddProblemViewModel @Inject constructor(
}

companion object {
private const val DATE_REGEX = "^(\\d{4})-(\\d{2})-(\\d{2})\$"
private const val DATE_REGEX = "^(\\d{4}).(\\d{2}).(\\d{2})\$"
const val IMAGE_TYPE_HOMEWORK_THUMBNAIL = "HOMEWORK_THUMBNAIL"
const val IMAGE_TYPE_REVIEW_NOTE_PROBLEM = "REVIEW_NOTE_PROBLEM"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.chaeda.chaeda.presentation.signup

import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
Expand All @@ -25,6 +26,13 @@ class SignUpActivity
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

this.window?.apply {
// this.statusBarColor = Color.TRANSPARENT
this.statusBarColor = Color.parseColor("#FFFFFF")
// decorView.systemUiVisibility =
// View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
}

binding.vm = signUpViewModel
binding.lifecycleOwner = this
initListener()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.util.Log
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.appcompat.widget.AppCompatTextView
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
Expand Down Expand Up @@ -195,7 +194,7 @@ class StatisticsChapterFragment
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
// 선택된 아이템의 텍스트 가져오기
chapter = parent.getItemAtPosition(position) as Chapter
Toast.makeText(requireActivity(), "${chapter.koreanName}", Toast.LENGTH_SHORT).show()
// Toast.makeText(requireActivity(), "${chapter.koreanName}", Toast.LENGTH_SHORT).show()
// if (selectedItem != "학년 선택하기") signUpViewModel.updateGrade(selectedItem)
// else signUpViewModel.updateGrade("")
// setGraph(selectedItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class StatisticsCountFragment
val endOfWeek = date.plusDays(6)
binding.tvStandardText.text = when (mode) {
MODE_DATE -> "${date.year}${date.monthValue}${date.dayOfMonth}일 (${DAY_OF_WEEK[date.dayOfWeek.value - 1]})"
MODE_WEEK -> "${date.year}${date.monthValue}${date.dayOfMonth} ~ ${endOfWeek.year}${endOfWeek.monthValue}${endOfWeek.dayOfMonth}"
MODE_WEEK -> "${date.year}${date.monthValue}${date.dayOfMonth}\n~ ${endOfWeek.year}${endOfWeek.monthValue}${endOfWeek.dayOfMonth}"
MODE_MONTH -> "${date.year}${date.monthValue}"
else -> ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.chaeda.domain.enumSet.Concept
import com.chaeda.domain.enumSet.Subject
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import timber.log.Timber

@AndroidEntryPoint
class StatisticsTypeDetailActivity
Expand Down Expand Up @@ -45,14 +46,13 @@ class StatisticsTypeDetailActivity
val subjectEnum = Subject.valueOf(chapterEnum.subject)
tvConcept.text = conceptEnum.koreanName
tvChapter.text = chapterEnum.koreanName
tvChapter.text = subjectEnum.koreanName
tvSubject.text = subjectEnum.koreanName
}
requestStatistics()
}

private fun updateView(concept: ConceptDetail) {
with(binding) {
// tv
tvSolved.text = "${concept.problemCount}문제"
tvWrong.text = "${concept.wrongCount}문제"
tvEasy.text = "${concept.easyNum}문제"
Expand All @@ -62,7 +62,7 @@ class StatisticsTypeDetailActivity
}

private fun requestStatistics() {
when (mode) {
when (cur_mode) {
MODE_ALL -> {
viewModel.getAccumulatedStatisticsByType(type!!)
}
Expand All @@ -78,6 +78,10 @@ class StatisticsTypeDetailActivity

private fun initListener() {
with(binding) {
llBack.setOnSingleClickListener {
finish()
}

llCheckAll.setOnSingleClickListener {
ivCheckAll.setImageResource(R.drawable.ic_radio_checked)
ivCheckMonth.setImageResource(R.drawable.ic_radio_unchecked)
Expand Down Expand Up @@ -109,14 +113,20 @@ class StatisticsTypeDetailActivity
viewModel.statisticsState.collect { state ->
when (state) {
is StatisticsState.GetWeeklyStatisticsDetail -> {
Timber.tag("chaeda-detail").d("weekly success - ${state.concept}")
updateView(state.concept)
}
is StatisticsState.GetMontlyStatisticsDetail -> {
Timber.tag("chaeda-detail").d("monthly success - ${state.concept}")
updateView(state.concept)
}
is StatisticsState.GetAccumulatedStatisticsDetail -> {
Timber.tag("chaeda-detail").d("accumulated success - ${state.concept}")
updateView(state.concept)
}
is StatisticsState.Failure -> {
Timber.tag("chaeda-detail").d("failure - ${state.msg}")
}
else -> {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class StatisticsWrongFragment
navigateTo<StatisticsFragment>()
}
val endOfWeek = date.plusDays(6)
tvStandardText.text = "${date.year}${date.monthValue}${date.dayOfMonth} ~ ${endOfWeek.year}${endOfWeek.monthValue}${endOfWeek.dayOfMonth}"
tvStandardText.text = "${date.year}${date.monthValue}${date.dayOfMonth}\n~ ${endOfWeek.year}${endOfWeek.monthValue}${endOfWeek.dayOfMonth}"
}
requestWrongCount()
}
Expand Down Expand Up @@ -198,7 +198,7 @@ class StatisticsWrongFragment
private fun setStandardText() {
val endOfWeek = date.plusDays(6)
binding.tvStandardText.text = when (mode) {
MODE_WEEK -> "${date.year}${date.monthValue}${date.dayOfMonth} ~ ${endOfWeek.year}${endOfWeek.monthValue}${endOfWeek.dayOfMonth}"
MODE_WEEK -> "${date.year}${date.monthValue}${date.dayOfMonth}\n~ ${endOfWeek.year}${endOfWeek.monthValue}${endOfWeek.dayOfMonth}"
MODE_MONTH -> "${date.year}${date.monthValue}"
else -> ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class TextbookActivity
tvAdd.setOnSingleClickListener {
startActivity(AddTextbookActivity.getIntent(this@TextbookActivity))
}
llBack.setOnSingleClickListener {
finish()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class AddTextbookActivity

private fun initListener() {
with(binding) {
llBack.setOnSingleClickListener {
finish()
}

tvAddFile.setOnSingleClickListener {
openFilePicker()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.chaeda.base.BindingActivity
import com.chaeda.base.util.extension.setOnSingleClickListener
import com.chaeda.chaeda.R
import com.chaeda.chaeda.databinding.ActivityTextbookListBinding
import com.chaeda.chaeda.presentation.textbook.TextbookState
Expand Down Expand Up @@ -55,15 +56,9 @@ class TextbookListActivity

private fun initListener() {
with(binding) {
// fab.setOnSingleClickListener {
// // 결과를 전달하기 위해 Intent를 생성합니다.
// val resultIntent = Intent().apply {
// putExtra("textbookId", textbookViewModel.textbookId.value)
// putExtra("textbookName", textbookViewModel.textbookName.value)
// }
// setResult(RESULT_OK, resultIntent)
// finish()
// }
llBack.setOnSingleClickListener {
finish()
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/fragment_statistics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
android:layout_height="wrap_content"
android:text="@string/statistics_count_subtitle"
android:fontFamily="@font/nanumsquare_regular"
android:textSize="13sp"
android:textSize="11sp"
android:textColor="#717171"
app:layout_constraintTop_toBottomOf="@id/tv_count_title"
app:layout_constraintStart_toStartOf="@id/tv_count_title"
Expand Down Expand Up @@ -135,7 +135,7 @@
android:layout_height="wrap_content"
android:text="@string/statistics_wrong_subtitle"
android:fontFamily="@font/nanumsquare_regular"
android:textSize="13sp"
android:textSize="11sp"
android:textColor="#717171"
app:layout_constraintTop_toBottomOf="@id/tv_wrong_title"
app:layout_constraintStart_toStartOf="@id/tv_wrong_title"
Expand Down Expand Up @@ -182,7 +182,7 @@
android:layout_height="wrap_content"
android:text="@string/statistics_chapter_subtitle"
android:fontFamily="@font/nanumsquare_regular"
android:textSize="13sp"
android:textSize="11sp"
android:textColor="#717171"
app:layout_constraintTop_toBottomOf="@id/tv_chapter_title"
app:layout_constraintStart_toStartOf="@id/tv_chapter_title"
Expand All @@ -205,7 +205,7 @@
android:layout_height="wrap_content"
android:text="@string/statistics_detail_comment"
android:fontFamily="@font/nanumsquare_regular"
android:textSize="13sp"
android:textSize="11sp"
android:textColor="#717171"
app:layout_constraintTop_toBottomOf="@id/divider4"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.chaeda.data.datasoure.remote

import com.chaeda.data.model.response.statistics.toConceptDetail
import com.chaeda.data.service.StatisticsService
import com.chaeda.domain.entity.ChapterDetail
import com.chaeda.domain.entity.ConceptDetail
Expand Down Expand Up @@ -42,19 +43,19 @@ class RemoteStatisticsDataSource @Inject constructor(
suspend fun getAccumulatedStatisticsByType(
subConcept: String
): ConceptDetail {
return statisticsService.getAccumulatedStatisticsByType(subConcept)
return statisticsService.getAccumulatedStatisticsByType(subConcept).toConceptDetail()
}

suspend fun getMonthlyStatisticsByType(
subConcept: String
): ConceptDetail {
return statisticsService.getMonthlyStatisticsByType(subConcept)
return statisticsService.getMonthlyStatisticsByType(subConcept).toConceptDetail()
}

suspend fun getWeeklyStatisticsByType(
subConcept: String
): ConceptDetail {
return statisticsService.getWeeklyStatisticsByType(subConcept)
return statisticsService.getWeeklyStatisticsByType(subConcept).toConceptDetail()
}

suspend fun getChapterListBySubject(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.chaeda.data.model.response.statistics

import com.chaeda.domain.entity.ConceptDetail
import kotlinx.serialization.Serializable

@Serializable
data class ConceptStatisticsDTO (
val subConcept: String,
val problemCount: Int,
val wrongCount: Int,
val easyNum: Int,
val middleNum: Int,
val hardNum: Int
)

fun ConceptStatisticsDTO.toConceptDetail(): ConceptDetail {
return ConceptDetail(null, null, subConcept, problemCount, wrongCount, easyNum, middleNum, hardNum)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.chaeda.data.service

import com.chaeda.data.model.response.statistics.ConceptStatisticsDTO
import com.chaeda.domain.entity.ChapterDetail
import com.chaeda.domain.entity.ConceptDetail
import com.chaeda.domain.entity.WrongCountWithConcept
Expand Down Expand Up @@ -36,17 +37,17 @@ interface StatisticsService {
@GET("/statistics/statistics/accumulated/{subConcept}")
suspend fun getAccumulatedStatisticsByType(
@Path("subConcept") subConcept: String
): ConceptDetail
): ConceptStatisticsDTO

@GET("/statistics/statistics/monthly/{subConcept}")
suspend fun getMonthlyStatisticsByType(
@Path("subConcept") subConcept: String
): ConceptDetail
): ConceptStatisticsDTO

@GET("/statistics/statistics/weekly/{subConcept}")
suspend fun getWeeklyStatisticsByType(
@Path("subConcept") subConcept: String
): ConceptDetail
): ConceptStatisticsDTO

// not in use
@GET("/statistics/chapter/list")
Expand Down

0 comments on commit 743b7ec

Please sign in to comment.