Skip to content

Commit

Permalink
Fix: 향후 계획 시간표 학기/과목 선택 기능 #50
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyuuum committed Feb 15, 2024
1 parent 894cbff commit 9e006fa
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 438 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import java.time.LocalDate


data class SaveInfo(
val name: String,
val date: String
val name: String,
val date: String
)




data class SavelicenseRequest(
val info : List<SaveInfo>,

)
val info: List<SaveInfo>
)



Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package umc.com.mobile.project.data.model.plan

data class SemesterTimeResponse(
val isSuccess: Boolean,
val code: String,
val message: String,
val result: List<semesterResult>,
)
val isSuccess: Boolean,
val code: String,
val message: String,
val result: List<semesterResult>,
) {


}

data class semesterResult(
val hakkiNum: String,
val hakkiText: String,
val hakkiNum: String,
val hakkiText: String,
)

Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@ import umc.com.mobile.project.data.model.plan.semesterResult
import umc.com.mobile.project.databinding.ItemChooseSemesterBinding

class PlanSemesterAdapter( semesterList: List<semesterResult?>): RecyclerView.Adapter<PlanSemesterAdapter.NonSubjectViewHolder>(){
var semesterList: List<semesterResult?> = semesterList
set(value) {
field = value
notifyDataSetChanged()
//데이터가 바뀌었다 알려줌.
}
var semesterList: List<semesterResult?> = semesterList
set(value) {
field = value
notifyDataSetChanged()
//데이터가 바뀌었다 알려줌.
}


override fun getItemCount(): Int {
return semesterList?.size ?: 0
}
override fun getItemCount(): Int {
return semesterList?.size ?: 0
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlanSemesterAdapter.NonSubjectViewHolder {
val itemBinding = ItemChooseSemesterBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return PlanSemesterAdapter.NonSubjectViewHolder(itemBinding)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlanSemesterAdapter.NonSubjectViewHolder {
val itemBinding = ItemChooseSemesterBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return PlanSemesterAdapter.NonSubjectViewHolder(itemBinding)
}

override fun onBindViewHolder(holder: PlanSemesterAdapter.NonSubjectViewHolder, position: Int) {
override fun onBindViewHolder(holder: PlanSemesterAdapter.NonSubjectViewHolder, position: Int) {

holder.itemBinding.planTimeSemesterItem.text =semesterList[position]?.hakkiText.toString()
val semesterInfo = semesterList[position]
if (semesterInfo != null) {
holder.itemBinding.planTimeSemesterItem.text = semesterInfo.hakkiText
}

}
}

class NonSubjectViewHolder(val itemBinding: ItemChooseSemesterBinding) : RecyclerView.ViewHolder(itemBinding.root)
class NonSubjectViewHolder(val itemBinding: ItemChooseSemesterBinding) : RecyclerView.ViewHolder(itemBinding.root)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,59 @@ import umc.com.mobile.project.databinding.FragmentPlanlicenseBinding
import android.widget.EditText
import androidx.core.view.setMargins
import androidx.lifecycle.Observer
import umc.com.mobile.project.data.model.plan.SaveInfo
import androidx.recyclerview.widget.LinearLayoutManager

import umc.com.mobile.project.data.model.plan.SavelicenseRequest
import umc.com.mobile.project.data.model.plan.semesterResult
import umc.com.mobile.project.databinding.SemesterChooseBinding
import java.time.LocalDate

class PlanSemesterFragment : Fragment() {
private var _binding: SemesterChooseBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!
private var _binding: SemesterChooseBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = SemesterChooseBinding.inflate(inflater, container, false)





return binding.root
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = SemesterChooseBinding.inflate(inflater, container, false)


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)


val adapter = PlanSemesterAdapter(listOf()) // 초기 데이터로 빈 리스트 사용

return binding.root
}
// RecyclerView에 어댑터와 레이아웃 매니저 설정
binding.recyclerViewPlanSemester.adapter = adapter
binding.recyclerViewPlanSemester.layoutManager = LinearLayoutManager(context)


viewModel.planSemesterInfo.observe(viewLifecycleOwner) { semesterInfo ->
// 데이터가 업데이트되면 어댑터의 리스트 업데이트
adapter.semesterList = semesterInfo?.result ?: emptyList()
adapter.notifyDataSetChanged()

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}

}
viewModel.getSemesterInfo() // 데이터 로드
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,57 @@ import umc.com.mobile.project.ui.gradInfo.adapter.GradInfoVPAdapter
import umc.com.mobile.project.ui.gradInfo.viewmodel.GradInfoViewModel

class PlanSettingFragment : Fragment() {
private var _binding:PlanTimeTabMainBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!
private var _binding:PlanTimeTabMainBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!

private lateinit var viewPager : ViewPager2
private lateinit var tabLayout : TabLayout
private lateinit var viewPager : ViewPager2
private lateinit var tabLayout : TabLayout

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = PlanTimeTabMainBinding.inflate(inflater, container, false)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = PlanTimeTabMainBinding.inflate(inflater, container, false)

initTabLayout()
initViewPager()
initTabLayout()
initViewPager()


return binding.root
}
return binding.root
}

private fun initTabLayout() {
private fun initTabLayout() {

val tabTitle = arrayOf("시간표", "자격증", "자유")
val tabTitle = arrayOf("시간표", "자격증", "자유")


viewPager = binding.viewPagerTimeTabMain
tabLayout = binding.tabLayoutPlanTime
viewPager = binding.viewPagerTimeTabMain
tabLayout = binding.tabLayoutPlanTime


val adapter = PlanVPAdapter(this)
val adapter = PlanVPAdapter(this)

adapter.addFragment(PlanTimeFragment())
adapter.addFragment(PlanlicenseFragment())
adapter.addFragment(PlanFreeFragment())

adapter.addFragment(PlanlicenseFragment())
adapter.addFragment(PlanTimeFragment())
adapter.addFragment(PlanFreeFragment())
viewPager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
viewPager.adapter = adapter

viewPager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
viewPager.adapter = adapter
TabLayoutMediator(tabLayout, viewPager
) { tab, position -> tab.text = tabTitle[position] }.attach()
}

TabLayoutMediator(tabLayout, viewPager
) { tab, position -> tab.text = tabTitle[position] }.attach()
}
private fun initViewPager() {

private fun initViewPager() {
binding.viewPagerTimeTabMain.isUserInputEnabled = false
}

binding.viewPagerTimeTabMain.isUserInputEnabled = false
}


override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,64 @@ import umc.com.mobile.project.ui.common.NavigationUtil.navigate
import umc.com.mobile.project.ui.plan.PlanViewModel

class PlanTimeFragment : Fragment() {
private var _binding: PlanSubjectListBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!
private var _binding: PlanSubjectListBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
_binding = PlanSubjectListBinding.inflate(inflater, container, false)
binding.planSubjectListSemester.setOnClickListener{
navigate(R.id.action_planTimeFragment_to_planSemesterFragment)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
_binding = PlanSubjectListBinding.inflate(inflater, container, false)

viewModel.getListTimeInfo()
val adapter = viewModel.listTimeInfo.value?.let { PlanRecyclerAdapter(it.result) }

binding.recyclerView.adapter = adapter
binding.recyclerView.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)

viewModel.getListTimeInfo()
val adapter = viewModel.listTimeInfo.value?.let { PlanRecyclerAdapter(it.result) }

binding.recyclerView.adapter = adapter
binding.recyclerView.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)

viewModel.listTimeInfo.observe(viewLifecycleOwner) { timenewList ->
if (timenewList != null) {
if (adapter != null) {
adapter.timeList=timenewList.result
adapter.notifyDataSetChanged()
}
}


viewModel.listTimeInfo.observe(viewLifecycleOwner) { timenewList ->
if (timenewList != null) {
if (adapter != null) {
adapter.timeList=timenewList.result
adapter.notifyDataSetChanged()
}
}


}


}

return binding.root

}

return binding.root

}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)


binding.planSubjectListSemester.setOnClickListener {

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
findNavController().navigate(R.id.action_planTimeFragment_to_planSemesterFragment)
}
}







override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

}
Loading

0 comments on commit 9e006fa

Please sign in to comment.