Skip to content

Commit b528fb0

Browse files
committed
✨ 운동기록 페이지에서 선택한 운동기록 safe args로 가져와서 인증글 작성페이지에서 띄워주기
1 parent 749e5a0 commit b528fb0

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

presentation/src/main/java/com/whyranoid/presentation/base/BaseActivity.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ internal abstract class BaseActivity<VDB : ViewDataBinding>(
1010
@LayoutRes val layoutRes: Int
1111
) : AppCompatActivity() {
1212

13-
protected lateinit var binding: VDB
13+
private var _binding: VDB? = null
14+
protected val binding get() = requireNotNull(_binding)
1415

1516
override fun onCreate(savedInstanceState: Bundle?) {
1617
super.onCreate(savedInstanceState)
1718

18-
binding = DataBindingUtil.setContentView(this, layoutRes)
19+
_binding = DataBindingUtil.setContentView(this, layoutRes)
1920
binding.lifecycleOwner = this
2021
}
22+
23+
override fun onDestroy() {
24+
_binding = null
25+
super.onDestroy()
26+
}
2127
}

presentation/src/main/java/com/whyranoid/presentation/base/BaseFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal abstract class BaseFragment<VDB : ViewDataBinding>(
2828
}
2929

3030
override fun onDestroyView() {
31-
super.onDestroyView()
3231
_binding = null
32+
super.onDestroyView()
3333
}
3434
}
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
package com.whyranoid.presentation.community.runningpost
22

3+
import android.os.Bundle
4+
import android.view.View
5+
import androidx.navigation.fragment.navArgs
36
import com.whyranoid.presentation.R
47
import com.whyranoid.presentation.base.BaseFragment
58
import com.whyranoid.presentation.databinding.FragmentCreateRunningPostBinding
69

710
internal class CreateRunningPostFragment :
8-
BaseFragment<FragmentCreateRunningPostBinding>(R.layout.fragment_create_running_post)
11+
BaseFragment<FragmentCreateRunningPostBinding>(R.layout.fragment_create_running_post) {
12+
13+
private val args: CreateRunningPostFragmentArgs by navArgs()
14+
15+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
16+
super.onViewCreated(view, savedInstanceState)
17+
18+
initViews()
19+
}
20+
21+
private fun initViews() {
22+
binding.selectedRunningHistory = args.selectedRunningHistory
23+
}
24+
}

presentation/src/main/res/layout/fragment_create_running_post.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<layout
3-
android:id="@+id/layout_root"
2+
<layout android:id="@+id/layout_root"
43
xmlns:android="http://schemas.android.com/apk/res/android"
5-
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:binds="http://schemas.android.com/tools">
66

77
<data>
8-
8+
<variable
9+
name="selectedRunningHistory"
10+
type="com.whyranoid.presentation.model.RunningHistoryUiModel" />
911
</data>
1012

1113
<androidx.constraintlayout.widget.ConstraintLayout
@@ -45,6 +47,7 @@
4547
android:layout_width="0dp"
4648
android:layout_height="wrap_content"
4749
android:layout_marginTop="12dp"
50+
binds:runningHistory="@{selectedRunningHistory}"
4851
app:layout_constraintStart_toStartOf="parent"
4952
app:layout_constraintEnd_toEndOf="parent"
5053
app:layout_constraintTop_toBottomOf="@id/tv_label_running_history"/>

0 commit comments

Comments
 (0)