-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MOD] 상세페이지 / 보관함으로 뒤로가기 및 코스 삭제 시 애니메이션 통일 #277
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package com.runnect.runnect.presentation.mydrawdetail | |
import android.content.ContentValues | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.activity.OnBackPressedCallback | ||
import androidx.activity.viewModels | ||
import androidx.core.net.toUri | ||
import com.bumptech.glide.Glide | ||
|
@@ -42,6 +43,11 @@ class MyDrawDetailActivity : | |
deleteButton() | ||
} | ||
|
||
private fun finishViewAnimLeftRight() { | ||
finish() | ||
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) | ||
} | ||
|
||
private fun deletingDialog() { | ||
val (dialog, dialogLayout) = setActivityDialog( | ||
layoutInflater = layoutInflater, | ||
|
@@ -57,6 +63,7 @@ class MyDrawDetailActivity : | |
putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, "fromDeleteMyDrawDetail") | ||
} | ||
startActivity(intent) | ||
finishViewAnimLeftRight() | ||
} | ||
this.btn_delete_no.setOnClickListener { | ||
dialog.dismiss() | ||
|
@@ -73,17 +80,17 @@ class MyDrawDetailActivity : | |
|
||
private fun backButton() { //png가 imgBtn으로 하면 잘리길래 어차피 임시로 해놓는 거니까 imgView로 component를 추가해줬음 | ||
binding.imgBtnBack.setOnClickListener { | ||
finish() | ||
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) | ||
finishViewAnimLeftRight() | ||
} | ||
} | ||
|
||
override fun onBackPressed() { | ||
finish() | ||
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) | ||
private val backPressedCallback = object : OnBackPressedCallback(true) { | ||
override fun handleOnBackPressed() { | ||
finishViewAnimLeftRight() | ||
} | ||
} | ||
|
||
fun getMyDrawDetail() { | ||
private fun getMyDrawDetail() { | ||
val courseId = intent.getIntExtra(EXTRA_COURSE_ID, 0) | ||
Timber.tag(ContentValues.TAG).d("courseId from Storage : $courseId") | ||
|
||
|
@@ -101,6 +108,8 @@ class MyDrawDetailActivity : | |
|
||
fun addObserver() { | ||
observeGetResult() | ||
|
||
onBackPressedDispatcher.addCallback(this, backPressedCallback) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드 스타일의 차이일 수 있지만, 아래처럼 관련있는 코드를 함수로 묶어두면 나중에 볼 때 편하더라구요! private fun registerBackPressedCallback() { // 이 함수를 addObserver에서 호출
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
naviagteToPreviousScreen()
}
}
onBackPressedDispatcher.addCallback(this, callback)
}
private fun naviagteToPreviousScreen() {
finish()
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right)
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 다른 코드에서 navigateToPreviousScreen 이라는 함수명을 사용하긴 했습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addObserver 함수에서 onBackPressedDispatcher에 콜백 등록하는 코드도 backPressedCallback 이라는 변수를 굳이 전역 변수로 만들 필요가 없을 거 같아서요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다! |
||
} | ||
|
||
private fun setImage(src: ResponseGetMyDrawDetailDTO) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반복되는 코드를 함수화 하는 게 어떨까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 의견입니다! 우선 여기 파일 내에서만 함수화해보고 프로젝트 전체적으로도 많이 쓰는 것 같다 싶으면 확장함수로 빼는 것도 괜찮을 것 같네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 부분에서도 저 코드가 반복되는 경우가 많더라구요!! 확장함수로 만드는 거 좋은 거 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확장함수로 만들었고 반영했습니다!