Skip to content
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

[feature/calendar2] 커스텀뷰 캘린더 #7

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CustomCalendarAdapter(fragmentActivity: FragmentActivity) :

override fun createFragment(position: Int): Fragment {
val millsId = getItemId(position)
return CustomCalendarFragment(millsId)
return CustomCalendarFragment.newInstance(millsId)
}

override fun getItemId(position: Int): Long {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,24 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.teamcatchme.catchmesample.databinding.FragmentCustomCalendarBinding
import java.util.*
import kotlin.properties.Delegates

class CustomCalendarFragment : Fragment() {

companion object {
private var MILLS_ID: String = "MILLS_ID"
private var millsId: Long = 0L

fun newInstance(millsId: Long): CustomCalendarFragment {
val fragment = CustomCalendarFragment()
val args = Bundle()
args.putLong(MILLS_ID, millsId)
fragment.arguments = args
Comment on lines +20 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val args = Bundle()
args.putLong(MILLS_ID, millsId)
fragment.arguments = args
fragment.arguments = Bundle().also { putLong(MILLS_ID, millsId) }

3줄을 1줄로


return fragment
}
}

class CustomCalendarFragment(private val millsId: Long) : Fragment() {
private var _binding: FragmentCustomCalendarBinding? = null
private val binding: FragmentCustomCalendarBinding
get() = requireNotNull(_binding)
Expand All @@ -19,6 +35,9 @@ class CustomCalendarFragment(private val millsId: Long) : Fragment() {
savedInstanceState: Bundle?
): View {
_binding = FragmentCustomCalendarBinding.inflate(inflater, container, false)
arguments?.let {
millsId = it.getLong(MILLS_ID)
}
Comment on lines +38 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

initView()
return binding.root
}
Expand Down