Skip to content

Commit

Permalink
Merge pull request #358 from Runnect/feature/refactor-remove-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sxunea authored Jul 4, 2024
2 parents 9751701 + 44087f9 commit 7fa655c
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 111 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'

id 'kotlin-android-extensions'
//id 'kotlin-parcelize'
id 'kotlin-parcelize'

id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.20'
id 'dagger.hilt.android.plugin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.runnect.runnect.data.dto

import android.os.Parcelable
import com.naver.maps.geometry.LatLng
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class CourseData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.runnect.runnect.data.dto


import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class RunToEndRunData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.runnect.runnect.data.dto

import android.os.Parcelable
import com.naver.maps.geometry.LatLng
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class SearchResultEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.runnect.runnect.data.dto


import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class TimerData(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.runnect.runnect.domain.entity

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class DiscoverUploadCourse(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.runnect.runnect.domain.entity

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class MyDrawCourse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.runnect.runnect.domain.entity


import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class MyScrapCourse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.runnect.runnect.data.dto.SearchResultEntity
import com.runnect.runnect.data.dto.UploadLatLng
import com.runnect.runnect.databinding.ActivityDrawBinding
import com.runnect.runnect.databinding.BottomsheetRequireCourseNameBinding
import com.runnect.runnect.databinding.CustomDialogMakeCourseBinding
import com.runnect.runnect.presentation.MainActivity
import com.runnect.runnect.presentation.countdown.CountDownActivity
import com.runnect.runnect.presentation.state.UiState
Expand All @@ -54,8 +55,6 @@ import com.runnect.runnect.util.extension.setActivityDialog
import com.runnect.runnect.util.extension.showToast
import com.runnect.runnect.util.multipart.ContentUriRequestBody
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.custom_dialog_make_course.view.btn_run
import kotlinx.android.synthetic.main.custom_dialog_make_course.view.btn_storage
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import timber.log.Timber
Expand Down Expand Up @@ -502,15 +501,14 @@ class DrawActivity : BindingActivity<ActivityDrawBinding>(R.layout.activity_draw
* 코스 완성 시 뜨는 팝업 (보관함 가기 / 바로 달리기)
*/
private fun notifyCreateFinish() { //todo dialogFragment로 리팩토링
val binding = CustomDialogMakeCourseBinding.inflate(layoutInflater)
val (dialog, dialogLayout) = setActivityDialog(
layoutInflater = layoutInflater,
view = binding.root,
resId = R.layout.custom_dialog_make_course,
binding = binding,
cancel = false
)

with(dialogLayout) {
this.btn_run.setOnClickListener {
with(binding) {
btnRun.setOnClickListener {
Analytics.logClickedItemEvent(EventName.EVENT_CLICK_RUN_AFTER_COURSE_COMPLETE)
if (isCustomLocationMode) departureLatLng = customDepartureLatLng

Expand Down Expand Up @@ -539,7 +537,7 @@ class DrawActivity : BindingActivity<ActivityDrawBinding>(R.layout.activity_draw
dialog.dismiss()
}

this.btn_storage.setOnClickListener {
btnStorage.setOnClickListener {
Analytics.logClickedItemEvent(EventName.EVENT_CLICK_STORED_AFTER_COURSE_COMPLETE)
val intent = Intent(this@DrawActivity, MainActivity::class.java).apply {
putExtra(EXTRA_FRAGMENT_REPLACEMENT_DIRECTION, "fromDrawCourse")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.AlertDialog
import android.content.ContentValues
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
Expand All @@ -13,6 +14,7 @@ import com.runnect.runnect.R
import com.runnect.runnect.binding.BindingActivity
import com.runnect.runnect.data.dto.HistoryInfoDTO
import com.runnect.runnect.databinding.ActivityMyHistoryBinding
import com.runnect.runnect.databinding.CustomDialogDeleteBinding
import com.runnect.runnect.presentation.mypage.history.adapter.MyHistoryAdapter
import com.runnect.runnect.presentation.mypage.history.detail.MyHistoryDetailActivity
import com.runnect.runnect.presentation.search.SearchActivity
Expand All @@ -25,13 +27,13 @@ import com.runnect.runnect.util.extension.navigateToPreviousScreenWithAnimation
import com.runnect.runnect.util.extension.setCustomDialog
import com.runnect.runnect.util.extension.setDialogButtonClickListener
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.custom_dialog_delete.btn_delete_yes
import timber.log.Timber

@AndroidEntryPoint
class MyHistoryActivity : BindingActivity<ActivityMyHistoryBinding>(R.layout.activity_my_history),
OnMyHistoryItemClick {
private val viewModel: MyHistoryViewModel by viewModels()
private lateinit var deleteDialogDeleteBinding: CustomDialogDeleteBinding
private lateinit var adapter: MyHistoryAdapter
private lateinit var dialog: AlertDialog

Expand Down Expand Up @@ -65,18 +67,18 @@ class MyHistoryActivity : BindingActivity<ActivityMyHistoryBinding>(R.layout.act
}

private fun initDialog() {
deleteDialogDeleteBinding = CustomDialogDeleteBinding.inflate(layoutInflater)
dialog = setCustomDialog(
layoutInflater = layoutInflater,
view = binding.root,
binding = deleteDialogDeleteBinding,
description = DIALOG_DESC,
yesBtnText = DELETE_BTN
)
}

private fun setDialogClickEvent() {
dialog.setDialogButtonClickListener { which ->
dialog.setDialogButtonClickListener(deleteDialogDeleteBinding) { which ->
when (which) {
dialog.btn_delete_yes -> viewModel.deleteHistory()
deleteDialogDeleteBinding.btnDeleteYes -> viewModel.deleteHistory()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.fragment.app.replace
import androidx.fragment.app.viewModels
import com.runnect.runnect.R
import com.runnect.runnect.binding.BindingFragment
import com.runnect.runnect.databinding.CustomDialogDeleteBinding
import com.runnect.runnect.databinding.FragmentMySettingAccountInfoBinding
import com.runnect.runnect.presentation.login.LoginActivity
import com.runnect.runnect.presentation.mypage.setting.MySettingFragment
Expand All @@ -28,7 +29,6 @@ import com.runnect.runnect.util.extension.showToast
import com.runnect.runnect.util.preference.AuthUtil.saveToken
import com.runnect.runnect.util.preference.StatusType.LoginStatus
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.custom_dialog_delete.btn_delete_yes
import timber.log.Timber

@AndroidEntryPoint
Expand All @@ -49,9 +49,7 @@ class MySettingAccountInfoFragment :
addListener()
addObserver()
initLogoutDialog()
setLogoutDialogClickEvent()
initWithdrawalDialog()
setWithdrawalDialogClickEvent()
}

private fun initLayout() {
Expand Down Expand Up @@ -105,10 +103,14 @@ class MySettingAccountInfoFragment :
}

private fun initLogoutDialog() {
val binding = CustomDialogDeleteBinding.inflate(layoutInflater)
logoutDialog = requireActivity().setCustomDialog(
layoutInflater, binding.root, DESCRIPTION_LOGOUT,
DESCRIPTION_LOGOUT_YES, DESCRIPTION_LOGOUT_NO
binding = binding,
description = DESCRIPTION_LOGOUT,
yesBtnText = DESCRIPTION_LOGOUT_YES,
noBtnText = DESCRIPTION_LOGOUT_NO
)
setLogoutDialogClickEvent(binding)
}

private fun moveToLogin() {
Expand All @@ -123,10 +125,10 @@ class MySettingAccountInfoFragment :
requireActivity().finish()
}

private fun setLogoutDialogClickEvent() {
logoutDialog.setDialogButtonClickListener { which ->
private fun setLogoutDialogClickEvent(binding: CustomDialogDeleteBinding) {
logoutDialog.setDialogButtonClickListener(binding) { which ->
when (which) {
logoutDialog.btn_delete_yes -> {
binding.btnDeleteYes -> {
Analytics.logClickedItemEvent(EVENT_VIEW_SUCCESS_LOGOUT)
moveToLogin()
}
Expand All @@ -135,16 +137,20 @@ class MySettingAccountInfoFragment :
}

private fun initWithdrawalDialog() {
val binding = CustomDialogDeleteBinding.inflate(layoutInflater)
withdrawalDialog = requireActivity().setCustomDialog(
layoutInflater, binding.root, DESCRIPTION_WITHDRAWAL,
DESCRIPTION_WITHDRAWAL_YES, DESCRIPTION_WITHDRAWAL_NO
binding = binding,
description = DESCRIPTION_WITHDRAWAL,
yesBtnText = DESCRIPTION_WITHDRAWAL_YES,
noBtnText = DESCRIPTION_WITHDRAWAL_NO
)
setWithdrawalDialogClickEvent(binding)
}

private fun setWithdrawalDialogClickEvent() {
withdrawalDialog.setDialogButtonClickListener { which ->
private fun setWithdrawalDialogClickEvent(binding: CustomDialogDeleteBinding) {
withdrawalDialog.setDialogButtonClickListener(binding) { which ->
when (which) {
withdrawalDialog.btn_delete_yes -> {
binding.btnDeleteYes -> {
viewModel.deleteUser()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.runnect.runnect.R
import com.runnect.runnect.binding.BindingActivity
import com.runnect.runnect.databinding.ActivityMyUploadBinding
import com.runnect.runnect.databinding.CustomDialogDeleteBinding
import com.runnect.runnect.presentation.detail.CourseDetailActivity
import com.runnect.runnect.presentation.detail.CourseDetailRootScreen
import com.runnect.runnect.presentation.discover.DiscoverFragment
Expand All @@ -31,8 +32,6 @@ import com.runnect.runnect.util.extension.setCustomDialog
import com.runnect.runnect.util.extension.setDialogButtonClickListener
import com.runnect.runnect.util.extension.showSnackbar
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.custom_dialog_delete.btn_delete_no
import kotlinx.android.synthetic.main.custom_dialog_delete.btn_delete_yes
import timber.log.Timber

@AndroidEntryPoint
Expand All @@ -41,6 +40,7 @@ class MyUploadActivity : BindingActivity<ActivityMyUploadBinding>(R.layout.activ
private val viewModel: MyUploadViewModel by viewModels()
private lateinit var uploadAdapter: MyUploadAdapter
private lateinit var dialog: AlertDialog
private lateinit var dialogBinding: CustomDialogDeleteBinding

private val resultLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
Expand Down Expand Up @@ -135,23 +135,25 @@ class MyUploadActivity : BindingActivity<ActivityMyUploadBinding>(R.layout.activ
}
}


private fun initDialog() {
dialogBinding = CustomDialogDeleteBinding.inflate(layoutInflater)
dialog = setCustomDialog(
layoutInflater, binding.root,
DESCRIPTION_DIALOG,
DELETE_BTN
binding = dialogBinding,
description = DESCRIPTION_DIALOG,
yesBtnText = DELETE_BTN
)
}

private fun setDialogClickEvent() {
dialog.setDialogButtonClickListener { which ->
dialog.setDialogButtonClickListener(dialogBinding) { which ->
when (which) {
dialog.btn_delete_yes -> {
dialogBinding.btnDeleteYes -> {
viewModel.deleteUploadCourse()
dialog.dismiss()
}

dialog.btn_delete_no -> {
dialogBinding.btnDeleteNo -> {
dialog.dismiss()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Bundle
import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.Button
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.widget.AppCompatButton
import androidx.core.content.ContextCompat
Expand All @@ -31,8 +32,6 @@ import com.runnect.runnect.util.custom.deco.GridSpacingItemDecoration
import com.runnect.runnect.util.extension.applyScreenEnterAnimation
import com.runnect.runnect.util.extension.setFragmentDialog
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.custom_dialog_delete.view.*
import kotlinx.android.synthetic.main.fragment_storage_my_draw.*
import timber.log.Timber

@AndroidEntryPoint
Expand Down Expand Up @@ -199,26 +198,27 @@ class StorageMyDrawFragment :

private fun showCourseDeleteConfirmDialog() {
val (dialog, dialogLayout) = setFragmentDialog(
layoutInflater = layoutInflater,
resId = R.layout.custom_dialog_delete,
cancel = true
)
with(dialogLayout) {
this.btn_delete_yes.setOnClickListener {
deleteCourse()
dialog.dismiss()
availableEdit = false
isSelectAvailable = false
hideDeleteCourseBtn()
showBottomNav()
}
this.btn_delete_no.setOnClickListener {
dialog.dismiss()
}

dialogLayout.findViewById<Button>(R.id.btn_delete_yes)?.setOnClickListener {
deleteCourse()
dialog.dismiss()
availableEdit = false
isSelectAvailable = false
hideDeleteCourseBtn()
showBottomNav()
}

dialogLayout.findViewById<Button>(R.id.btn_delete_no)?.setOnClickListener {
dialog.dismiss()
}

dialog.show()
}


private fun deleteCourse() {
viewModel.deleteMyDrawCourse()
binding.btnEditCourse.text = EDIT_MODE
Expand Down
Loading

0 comments on commit 7fa655c

Please sign in to comment.