Skip to content

Commit

Permalink
Merge pull request #271 from Runnect/feature/chore-mypage-history-tit…
Browse files Browse the repository at this point in the history
…le-edit

[CHORE] 마이페이지 러닝기록 / 제목 수정 시, 키보드 완료 버튼 누르면 바로 수정되도록 변경
  • Loading branch information
leeeha authored Nov 5, 2023
2 parents 51aef0d + 79dca9b commit c8a8fdb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ interface UserService {
suspend fun getUserUploadCourse(
): ResponseUserUploadCourse

@PUT("api/record")
suspend fun putDeleteHistory(
@Body requestDeleteHistoryDto: RequestDeleteHistoryDto
): BaseResponse<ResponseDeleteHistoryDto>

@PUT("api/public-course")
suspend fun putDeleteUploadCourse(
@Body requestDeleteUploadCourse: RequestDeleteUploadCourse
): ResponseDeleteUploadCourse

@PUT("api/record")
suspend fun putDeleteHistory(
@Body requestDeleteHistoryDto: RequestDeleteHistoryDto
): BaseResponse<ResponseDeleteHistoryDto>

@PATCH("api/record/{recordId}")
suspend fun patchHistoryTitle(
@Path("recordId") historyId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import android.content.Intent
import android.os.Bundle
import android.text.InputType
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import androidx.constraintlayout.widget.ConstraintSet
Expand All @@ -19,6 +22,7 @@ import com.runnect.runnect.util.custom.CommonDialogFragment
import com.runnect.runnect.util.custom.PopupItem
import com.runnect.runnect.util.custom.RunnectPopupMenu
import com.runnect.runnect.util.extension.getCompatibleSerializableExtra
import com.runnect.runnect.util.extension.hideKeyboard
import com.runnect.runnect.util.extension.setFocusAndShowKeyboard
import com.runnect.runnect.util.extension.showToast
import com.runnect.runnect.util.extension.snackBar
Expand Down Expand Up @@ -82,19 +86,43 @@ class MyHistoryDetailActivity :
}

private fun addListener() {
initBackButtonClickListener()
initShowMoreButtonClickListener()
initEditFinishButtonClickListener()
initTitleEditorActionDoneListener()
}

private fun initBackButtonClickListener() {
binding.ivBackBtn.setOnClickListener {
handleBackButtonByCurrentScreenMode()
}
}

private fun initShowMoreButtonClickListener() {
binding.ivShowMore.setOnClickListener { view ->
showPopupMenu(view)
}
}

private fun initEditFinishButtonClickListener() {
binding.btnMyHistoryDetailEditFinish.setOnClickListener {
viewModel.patchHistoryTitle()
}
}

private fun initTitleEditorActionDoneListener() {
binding.etCourseTitle.setOnEditorActionListener(object : TextView.OnEditorActionListener {
override fun onEditorAction(view: TextView?, actionId: Int, event: KeyEvent?): Boolean {
if (actionId == EditorInfo.IME_ACTION_DONE) {
viewModel.patchHistoryTitle()
hideKeyboard(currentFocus ?: View(this@MyHistoryDetailActivity))
return true
}
return false
}
})
}

private fun registerBackPressedCallback() {
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/layout/activity_my_history_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@
app:layout_constraintEnd_toEndOf="@id/view_1"
app:layout_constraintTop_toTopOf="@id/tv_total_distance" />


<!--이동시간-->

<View
Expand All @@ -271,7 +270,6 @@
app:layout_constraintStart_toEndOf="@id/view_1"
app:layout_constraintTop_toTopOf="@id/view_1" />


<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -318,7 +316,6 @@
app:layout_constraintStart_toEndOf="@id/view_2"
app:layout_constraintTop_toTopOf="@id/view_2" />


<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_pace"
android:layout_width="wrap_content"
Expand Down

0 comments on commit c8a8fdb

Please sign in to comment.