From a3d858241bf09c1046ec44cf38989f792992de1a Mon Sep 17 00:00:00 2001 From: unam Date: Thu, 9 Nov 2023 10:57:09 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[MOD]=20#253=20=EC=83=81=EC=84=B8=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20=EB=92=A4=EB=A1=9C?= =?UTF-8?q?=EA=B0=80=EA=B8=B0=20=EB=B0=8F=20=EC=BD=94=EC=8A=A4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=8B=9C=20=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mydrawdetail/MyDrawDetailActivity.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt index 68fe614d7..34eb4f649 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt @@ -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 @@ -57,6 +58,8 @@ class MyDrawDetailActivity : putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, "fromDeleteMyDrawDetail") } startActivity(intent) + finish() + overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) } this.btn_delete_no.setOnClickListener { dialog.dismiss() @@ -78,12 +81,14 @@ class MyDrawDetailActivity : } } - override fun onBackPressed() { - finish() - overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) + private val backPressedCallback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + finish() + overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) + } } - fun getMyDrawDetail() { + private fun getMyDrawDetail() { val courseId = intent.getIntExtra(EXTRA_COURSE_ID, 0) Timber.tag(ContentValues.TAG).d("courseId from Storage : $courseId") @@ -101,6 +106,8 @@ class MyDrawDetailActivity : fun addObserver() { observeGetResult() + + onBackPressedDispatcher.addCallback(this, backPressedCallback) } private fun setImage(src: ResponseGetMyDrawDetailDTO) { From 7534adf6089bd8d30b382fd2ce4303f5652706fe Mon Sep 17 00:00:00 2001 From: unam Date: Fri, 10 Nov 2023 14:53:58 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[MOD]=20#253=20=EB=92=A4=EB=A1=9C=EA=B0=80?= =?UTF-8?q?=EA=B8=B0=20logic=20=ED=95=A8=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 반복 사용되는 logic을 함수화함 --- .../mydrawdetail/MyDrawDetailActivity.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt index 34eb4f649..fc0addb08 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt @@ -43,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, @@ -58,8 +63,7 @@ class MyDrawDetailActivity : putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, "fromDeleteMyDrawDetail") } startActivity(intent) - finish() - overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) + finishViewAnimLeftRight() } this.btn_delete_no.setOnClickListener { dialog.dismiss() @@ -76,15 +80,13 @@ 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() } } private val backPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { - finish() - overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) + finishViewAnimLeftRight() } } From 70ce33767f84e2d673cb0d54cfd0efc5ad4f648d Mon Sep 17 00:00:00 2001 From: unam Date: Tue, 14 Nov 2023 11:00:36 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[MOD]=20#253=20OnBackPressedCallback=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=EC=B2=B4=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mydrawdetail/MyDrawDetailActivity.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt index fc0addb08..e12175962 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt @@ -43,11 +43,6 @@ 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, @@ -63,7 +58,7 @@ class MyDrawDetailActivity : putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, "fromDeleteMyDrawDetail") } startActivity(intent) - finishViewAnimLeftRight() + navigateToPreviousScreen() } this.btn_delete_no.setOnClickListener { dialog.dismiss() @@ -80,13 +75,7 @@ class MyDrawDetailActivity : private fun backButton() { //png가 imgBtn으로 하면 잘리길래 어차피 임시로 해놓는 거니까 imgView로 component를 추가해줬음 binding.imgBtnBack.setOnClickListener { - finishViewAnimLeftRight() - } - } - - private val backPressedCallback = object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - finishViewAnimLeftRight() + navigateToPreviousScreen() } } @@ -108,8 +97,21 @@ class MyDrawDetailActivity : fun addObserver() { observeGetResult() + registerBackPressedCallback() + } - onBackPressedDispatcher.addCallback(this, backPressedCallback) + private fun registerBackPressedCallback() { // 이 함수를 addObserver에서 호출 + val callback = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + navigateToPreviousScreen() + } + } + onBackPressedDispatcher.addCallback(this, callback) + } + + private fun navigateToPreviousScreen() { + finish() + overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) } private fun setImage(src: ResponseGetMyDrawDetailDTO) { From 6e0735ccfe133cbdacd134420789e5950ba564b3 Mon Sep 17 00:00:00 2001 From: unam Date: Tue, 14 Nov 2023 11:05:31 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[ADD]=20#253=20=EB=92=A4=EB=A1=9C=EA=B0=80?= =?UTF-8?q?=EA=B8=B0=20=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=ED=99=95=EC=9E=A5=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mydrawdetail/MyDrawDetailActivity.kt | 12 ++++-------- .../runnect/runnect/util/extension/ActivityExt.kt | 9 +++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/com/runnect/runnect/util/extension/ActivityExt.kt diff --git a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt index e12175962..7ce2242d3 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mydrawdetail/MyDrawDetailActivity.kt @@ -14,6 +14,7 @@ import com.runnect.runnect.data.dto.response.ResponseGetMyDrawDetailDTO import com.runnect.runnect.databinding.ActivityMyDrawDetailBinding import com.runnect.runnect.presentation.MainActivity import com.runnect.runnect.presentation.countdown.CountDownActivity +import com.runnect.runnect.util.extension.navigateToPreviousScreenWithAnimation import com.runnect.runnect.util.extension.setActivityDialog import dagger.hilt.android.AndroidEntryPoint import kotlinx.android.synthetic.main.custom_dialog_delete.view.btn_delete_no @@ -58,7 +59,7 @@ class MyDrawDetailActivity : putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, "fromDeleteMyDrawDetail") } startActivity(intent) - navigateToPreviousScreen() + navigateToPreviousScreenWithAnimation() } this.btn_delete_no.setOnClickListener { dialog.dismiss() @@ -75,7 +76,7 @@ class MyDrawDetailActivity : private fun backButton() { //png가 imgBtn으로 하면 잘리길래 어차피 임시로 해놓는 거니까 imgView로 component를 추가해줬음 binding.imgBtnBack.setOnClickListener { - navigateToPreviousScreen() + navigateToPreviousScreenWithAnimation() } } @@ -103,17 +104,12 @@ class MyDrawDetailActivity : private fun registerBackPressedCallback() { // 이 함수를 addObserver에서 호출 val callback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { - navigateToPreviousScreen() + navigateToPreviousScreenWithAnimation() } } onBackPressedDispatcher.addCallback(this, callback) } - private fun navigateToPreviousScreen() { - finish() - overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) - } - private fun setImage(src: ResponseGetMyDrawDetailDTO) { with(binding) { Glide diff --git a/app/src/main/java/com/runnect/runnect/util/extension/ActivityExt.kt b/app/src/main/java/com/runnect/runnect/util/extension/ActivityExt.kt new file mode 100644 index 000000000..48d5687f0 --- /dev/null +++ b/app/src/main/java/com/runnect/runnect/util/extension/ActivityExt.kt @@ -0,0 +1,9 @@ +package com.runnect.runnect.util.extension + +import android.app.Activity +import com.runnect.runnect.R + +fun Activity.navigateToPreviousScreenWithAnimation() { + finish() + overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right) +} \ No newline at end of file