Skip to content

Commit

Permalink
Feat: 향후 계획 시간표 학기/과목 선택 #50
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyuuum committed Feb 15, 2024
1 parent 5cfebbf commit 894cbff
Show file tree
Hide file tree
Showing 13 changed files with 541 additions and 513 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ 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,17 +1,14 @@
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,31 +7,28 @@ 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) {

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

}
}

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,59 +16,42 @@ import umc.com.mobile.project.databinding.FragmentPlanlicenseBinding
import android.widget.EditText
import androidx.core.view.setMargins
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager

import umc.com.mobile.project.data.model.plan.SaveInfo
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!!

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





return binding.root
}
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)


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


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

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


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,57 +17,58 @@ 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())

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

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

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

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

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,64 +17,54 @@ 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)
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)
}

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 {

findNavController().navigate(R.id.action_planTimeFragment_to_planSemesterFragment)
}
}







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

}
Loading

0 comments on commit 894cbff

Please sign in to comment.