Skip to content

Commit

Permalink
Merge pull request #22 from womentech-hackathon/feature/#9/goal_todo
Browse files Browse the repository at this point in the history
[FIX] #6 - Null Pointer Error
  • Loading branch information
jung0115 authored Aug 6, 2023
2 parents e14c766 + af67789 commit 233a8f5
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ class EducationFragment : Fragment() {
override fun onResume() {
super.onResume()

// 서울시 어르신 취업지원센터 교육정보 개수 조회
apiGetEducationCount(
addEducationCount = {
addEducationCount(it)
}
)
if(_binding != null) {
// 서울시 어르신 취업지원센터 교육정보 개수 조회
apiGetEducationCount(
addEducationCount = {
addEducationCount(it)
}
)
}
}

override fun onCreateView(
Expand All @@ -59,7 +61,7 @@ class EducationFragment : Fragment() {
)
}

var eduCount: Int? = null
var eduCount: Int = 0
fun addEducationCount(count: Int) {
eduCount = count
// 북마크 조회
Expand All @@ -69,8 +71,9 @@ class EducationFragment : Fragment() {
}
)
}
private fun getBookmarkCnt(bookmarks: MutableList<GetBookmarks>) {
initViewPager(eduCount!!, bookmarks.size)
private fun getBookmarkCnt(bookmarks: MutableList<GetBookmarks>?) {
if(bookmarks == null) initViewPager(eduCount, 0)
else initViewPager(eduCount, bookmarks.size)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ class EduAllFragment : Fragment(), EduOrderBottomFragment.EduOrderListener {
filter = "all"
orderType = "new"
page = 1

// 서울시 어르신 취업지원센터 교육정보 조회
apiGetEducationCount(
addEducationCount = {
getEducation(it)
}
)
}

override fun onCreateView(
Expand All @@ -71,80 +64,89 @@ class EduAllFragment : Fragment(), EduOrderBottomFragment.EduOrderListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// recyclerview 세팅
initRecycler()
if(_binding != null && binding != null) {

// 서울시 어르신 취업지원센터 교육정보 조회
/*apiGetEducationCount(
addEducationCount = {
getEducation(it)
}
)*/

// 모두보기 필터 선택
binding.linearEduFilterAll.setOnClickListener(View.OnClickListener {
filterAll()
})

// 접수중 필터 선택
binding.linearEduFilterIng.setOnClickListener(View.OnClickListener {
filterIng()
})

// 마감 필터 선택
binding.linearEduFilterEnd.setOnClickListener(View.OnClickListener {
filterEnd()
})

// 정렬 버튼
binding.linearSortingBtn.setOnClickListener(View.OnClickListener {
val bundle = Bundle()
bundle.putString("orderType", orderType)
val bottomSheet = EduOrderBottomFragment().apply { setListener(this@EduAllFragment) }
bottomSheet.arguments = bundle
bottomSheet.show(requireActivity().supportFragmentManager, bottomSheet.tag)
})

// recyclerview 스크롤 감지 => 무한 스크롤
binding.recyclerviewEduAll.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)

// 스크롤이 끝에 도달했는지 확인
if (!binding.recyclerviewEduAll.canScrollVertically(1)) {
// 모두 보기 filter 중이라면 모두보기 list의 데이터를 추가
if(filter == "all" && allEducationItems!!.size >= 10) {
educationAdapter.items.removeAt(10 * page)
page++
educationAdapter.items = allEducationItems!!.subList(0, 10 * page)
if(allEducationItems!!.size > 10 * page) {
educationAdapter.items.add(LoadingItem())
filter = "all"
orderType = "new"
page = 1

// recyclerview 세팅
initRecycler()

// 서울시 어르신 취업지원센터 교육정보 조회
apiGetEducationCount(
addEducationCount = {
getEducation(it)
}
)

// 모두보기 필터 선택
binding.linearEduFilterAll.setOnClickListener(View.OnClickListener {
filterAll()
})

// 접수중 필터 선택
binding.linearEduFilterIng.setOnClickListener(View.OnClickListener {
filterIng()
})

// 마감 필터 선택
binding.linearEduFilterEnd.setOnClickListener(View.OnClickListener {
filterEnd()
})

// 정렬 버튼
binding.linearSortingBtn.setOnClickListener(View.OnClickListener {
val bundle = Bundle()
bundle.putString("orderType", orderType)
val bottomSheet =
EduOrderBottomFragment().apply { setListener(this@EduAllFragment) }
bottomSheet.arguments = bundle
bottomSheet.show(requireActivity().supportFragmentManager, bottomSheet.tag)
})

// recyclerview 스크롤 감지 => 무한 스크롤
binding.recyclerviewEduAll.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)

// 스크롤이 끝에 도달했는지 확인
if (!binding.recyclerviewEduAll.canScrollVertically(1)) {
// 모두 보기 filter 중이라면 모두보기 list의 데이터를 추가
if (filter == "all" && allEducationItems!!.size >= 10) {
educationAdapter.items.removeAt(10 * page)
page++
educationAdapter.items = allEducationItems!!.subList(0, 10 * page)
if (allEducationItems!!.size > 10 * page) {
educationAdapter.items.add(LoadingItem())
}
educationAdapter.notifyDataSetChanged()
}
educationAdapter.notifyDataSetChanged()
}
// 접수중 filter 중이라면 접수중 list의 데이터를 추가
else if(filter == "ing" && ingEducationItems!!.size >= 10) {
educationAdapter.items.removeAt(10 * page)
page++
educationAdapter.items = ingEducationItems!!.subList(0, 10 * page)
if(ingEducationItems!!.size > 10 * page) {
educationAdapter.items.add(LoadingItem())
// 접수중 filter 중이라면 접수중 list의 데이터를 추가
else if (filter == "ing" && ingEducationItems!!.size >= 10) {
educationAdapter.items.removeAt(10 * page)
page++
educationAdapter.items = ingEducationItems!!.subList(0, 10 * page)
if (ingEducationItems!!.size > 10 * page) {
educationAdapter.items.add(LoadingItem())
}
educationAdapter.notifyDataSetChanged()
}
educationAdapter.notifyDataSetChanged()
}
// 마감 filter 중이라면 마감 list의 데이터를 추가
else if(filter == "end" && endEducationItems!!.size >= 10) {
educationAdapter.items.removeAt(10 * page)
page++
educationAdapter.items = endEducationItems!!.subList(0, 10 * page)
if(endEducationItems!!.size > 10 * page) {
educationAdapter.items.add(LoadingItem())
// 마감 filter 중이라면 마감 list의 데이터를 추가
else if (filter == "end" && endEducationItems!!.size >= 10) {
educationAdapter.items.removeAt(10 * page)
page++
educationAdapter.items = endEducationItems!!.subList(0, 10 * page)
if (endEducationItems!!.size > 10 * page) {
educationAdapter.items.add(LoadingItem())
}
educationAdapter.notifyDataSetChanged()
}
educationAdapter.notifyDataSetChanged()
}
}
}
})
})
}
}

// 교육 아이템 recyclerview 세팅
Expand All @@ -166,7 +168,7 @@ class EduAllFragment : Fragment(), EduOrderBottomFragment.EduOrderListener {
// 처음 보여줄 교육 데이터 10개 가져와서 나열
apiGetEducationInfo(
1,
count,
count-1,
addEducationList = {
addEducationItems(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ class EduBookmarkFragment : Fragment() {

page = 1
bookmarkList = null

apiGetBookmark(
getBookmark = {
getBookmark(it)
}
)
}

override fun onCreateView(
Expand All @@ -63,6 +57,12 @@ class EduBookmarkFragment : Fragment() {
// recyclerview 세팅
initRecycler()

apiGetBookmark(
getBookmark = {
getBookmark(it)
}
)

binding.textBookmarkNoticeCount.text = "총 0건이 있습니다."
}

Expand All @@ -78,16 +78,21 @@ class EduBookmarkFragment : Fragment() {
educationAdapter.items = bookmarkEducationItems!!
}

private fun getBookmark(bookmarks: MutableList<GetBookmarks>) {
bookmarkList = bookmarks
private fun getBookmark(bookmarks: MutableList<GetBookmarks>?) {
if(bookmarks == null) {
binding.textBookmarkNoticeCount.text = "총 0건이 있습니다."
}
else {
bookmarkList = bookmarks

binding.textBookmarkNoticeCount.text = ""+ bookmarks.size + "건이 있습니다."
binding.textBookmarkNoticeCount.text = "" + bookmarks!!.size + "건이 있습니다."

apiGetEducationCount(
addEducationCount = {
getCountEdu(it)
}
)
apiGetEducationCount(
addEducationCount = {
getCountEdu(it)
}
)
}
}

private fun getCountEdu(count: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private val retrofit: Retrofit = ApiClient.getInstance()

// 북마크 조회
fun apiGetBookmark(
getBookmark: (bookmarks: MutableList<GetBookmarks>) -> Unit
getBookmark: (bookmarks: MutableList<GetBookmarks>?) -> Unit
) {
retrofit.create(GetBookmarkService::class.java)
.getBookmark()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ fun apiGetEducationInfo(
Log.d(ContentValues.TAG, "서울시 어르신 취업지원센터 교육정보 조회 결과 -------------------------------------------")
Log.d(ContentValues.TAG, "onResponse: ${response.body().toString()}")

val body: EducationData? = response.body()!!
if(body != null) {
val educationList: MutableList<EducationRow> = body.tbViewProgram.row
//val body: EducationData? = response.body()!!
if(response.body() != null) {
val educationList: MutableList<EducationRow> = response.body()!!.tbViewProgram.row
addEducationList(educationList)
}
}
Expand All @@ -52,9 +52,9 @@ fun apiGetEducationCount(
Log.d(ContentValues.TAG, "서울시 어르신 취업지원센터 교육정보 조회 결과 -------------------------------------------")
Log.d(ContentValues.TAG, "onResponse: ${response.body().toString()}")

val body: EducationData? = response.body()!!
if(body != null) {
val count: Int = body.tbViewProgram.list_total_count
//val body: EducationData? = response.body()!!
if(response.body() != null) {
val count: Int = response.body()!!.tbViewProgram.list_total_count
addEducationCount(count)
}
}
Expand Down
19 changes: 14 additions & 5 deletions app/src/main/java/com/ssjm/sw_hackathon/goal/GoalFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.time.LocalDate
import java.time.format.TextStyle
import java.util.Locale

public var checkAdd = false

// 목표 탭
class GoalFragment : Fragment() {
Expand All @@ -38,12 +39,12 @@ class GoalFragment : Fragment() {

private lateinit var today: LocalDate
private lateinit var startDay: LocalDate
var progressValues = mutableListOf<String>("done", "fail", "some", "fail", "done", "some", "done")
var progressValues = mutableListOf<String>("none", "none", "none", "none", "none", "none", "none")

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

return binding.root
Expand Down Expand Up @@ -88,8 +89,8 @@ class GoalFragment : Fragment() {
view.findNavController().navigate(R.id.action_menu_goal_to_view)
})

addTodoContent(TodoOfDayItem(today, "바리스타 필기 공부", false))
addTodoContent(TodoOfDayItem(today, "오전 10:00 실기 학원", true))
addTodoContent(TodoOfDayItem(today, "라떼 아트", false))
if(checkAdd) addTodoContent(TodoOfDayItem(today, "오전 10:00 실기 학원", false))
}
private fun initRecycler() {
dayOfWeekItems = mutableListOf<DayOfWeekItem>()
Expand All @@ -108,7 +109,10 @@ class GoalFragment : Fragment() {

// 실천 내용 recyclerview 세팅
todoOfDayAdapter = TodoOfDayAdapter(
requireContext()
requireContext(),
onClickLatte = {
checkLatte()
}
)
binding.recyclerviewTodoContent.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
Expand Down Expand Up @@ -163,6 +167,11 @@ class GoalFragment : Fragment() {
}
}

private fun checkLatte() {
dayOfWeekItems!![6].progress = "some"
dayOfWeekAdapter.notifyDataSetChanged()
}

// 주차 계산
@RequiresApi(Build.VERSION_CODES.O)
private fun getWeekOfMonth(startDay: LocalDate): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.ssjm.sw_hackathon.R
import com.ssjm.sw_hackathon.databinding.ItemTodoContentsBinding

class TodoOfDayAdapter (private val context: Context,
private val onClickLatte: () -> Unit
) : RecyclerView.Adapter<TodoOfDayAdapter.TodoOfDayViewHolder>() {

var items = mutableListOf<TodoOfDayItem>()
Expand Down Expand Up @@ -40,6 +41,7 @@ class TodoOfDayAdapter (private val context: Context,

if(item.checked) {
binding.imgTodoCompleteBtnRound.setImageResource(R.drawable.ic_check_round_selected)
onClickLatte()
}
else {
binding.imgTodoCompleteBtnRound.setImageResource(R.drawable.ic_check_round_unselected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ViewTodoDoneFragment : Fragment() {

initRecycler()

addTodoDone(ViewTodoDoneItem("인강 듣기", mutableListOf("", "", ""), "2023년 7월 3일", "2023년 7월 18일"))
//addTodoDone(ViewTodoDoneItem("인강 듣기", mutableListOf("월", "수", "금"), "2023년 7월 3일", "2023년 7월 18일"))
}

private fun initRecycler() {
Expand Down
Loading

0 comments on commit 233a8f5

Please sign in to comment.