Skip to content

Commit 6d9fd1b

Browse files
authored
Merge pull request #313 from SPOTeam/SPOT-231-FEAT-신청승인UI수정
마이 페이지 세부 페이지 수정
2 parents 8fc5864 + 5784328 commit 6d9fd1b

38 files changed

+1573
-2381
lines changed

SPOTeam_android/app/src/main/java/com/example/spoteam_android/ui/community/EditContentFragment.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,14 @@ import android.widget.Toast
1717
import androidx.activity.result.ActivityResultLauncher
1818
import androidx.activity.result.contract.ActivityResultContracts
1919
import androidx.core.content.ContextCompat
20-
import androidx.core.os.bundleOf
21-
import androidx.fragment.app.setFragmentResult
2220
import androidx.lifecycle.lifecycleScope
2321
import androidx.recyclerview.widget.LinearLayoutManager
2422
import com.example.spoteam_android.R
25-
import com.example.spoteam_android.ReportCompleteListener
2623
import com.example.spoteam_android.RetrofitInstance
2724
import com.example.spoteam_android.databinding.FragmentMystudyWriteContentBinding
28-
import com.example.spoteam_android.ui.study.MyStudyPostContentActivity
2925
import com.example.spoteam_android.ui.study.WriteContentImageRVadapter
3026
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
31-
import kotlinx.coroutines.Dispatchers
3227
import kotlinx.coroutines.launch
33-
import kotlinx.coroutines.withContext
3428
import okhttp3.MediaType.Companion.toMediaTypeOrNull
3529
import okhttp3.MultipartBody
3630
import okhttp3.RequestBody

SPOTeam_android/app/src/main/java/com/example/spoteam_android/ui/mypage/BoardAdapter.kt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.example.spoteam_android.ui.mypage
22

3-
import android.app.AlertDialog
4-
import android.os.Bundle
3+
import StudyFormMode
54
import android.content.Context
5+
import android.os.Bundle
66
import android.util.Log
77
import android.view.Gravity
88
import android.view.LayoutInflater
@@ -11,9 +11,7 @@ import android.view.ViewGroup
1111
import android.widget.ImageView
1212
import android.widget.PopupWindow
1313
import android.widget.TextView
14-
import android.widget.Toast
1514
import androidx.appcompat.app.AppCompatActivity
16-
import androidx.core.view.isVisible
1715
import androidx.fragment.app.FragmentActivity
1816
import androidx.recyclerview.widget.RecyclerView
1917
import com.bumptech.glide.Glide
@@ -24,19 +22,17 @@ import com.example.spoteam_android.R
2422
import com.example.spoteam_android.ReportStudyMemberFragment
2523
import com.example.spoteam_android.RetrofitInstance
2624
import com.example.spoteam_android.databinding.ItemRecyclerViewPlusToggleBinding
27-
import com.example.spoteam_android.ui.community.CommunityAPIService
28-
import com.example.spoteam_android.ui.community.GetHostResponse
29-
import com.example.spoteam_android.ui.study.RegisterStudyFragment
30-
import com.example.spoteam_android.ui.community.MyRecruitingStudyDetail
3125
import com.example.spoteam_android.ui.interestarea.GetHostInterface
26+
import com.example.spoteam_android.ui.study.RegisterStudyFragment
3227
import retrofit2.Call
3328
import retrofit2.Callback
3429
import retrofit2.Response
3530

3631
class BoardAdapter(
3732
private val itemList: ArrayList<BoardItem>,
3833
private val onItemClick: (BoardItem) -> Unit,
39-
private val onLikeClick: (BoardItem, ImageView) -> Unit // onLikeClick 추가
34+
private val onLikeClick: (BoardItem, ImageView) -> Unit, // onLikeClick 추가
35+
private val listener: fetchProgressStudy? = null // 🔹추가
4036
) : RecyclerView.Adapter<BoardAdapter.BoardViewHolder>() {
4137

4238
private lateinit var context : Context
@@ -131,7 +127,7 @@ class BoardAdapter(
131127
view1.visibility = View.GONE
132128
endStudy.visibility = View.GONE
133129
view2.visibility = View.GONE
134-
reportMember.visibility = View.GONE
130+
reportMember.visibility = View.VISIBLE
135131
view3.visibility = View.VISIBLE
136132
leaveStudy.visibility = View.VISIBLE
137133
}
@@ -155,10 +151,11 @@ class BoardAdapter(
155151
}
156152

157153
endStudy.setOnClickListener {
158-
// 스터디 종료 다이얼로그 띄우기
159-
val exitDialog =
160-
ExitStudyPopupFragment(view.context, this@BoardAdapter, adapterPosition)
161-
exitDialog.start()
154+
// 스터디 끝내기 다이얼로그 띄우기
155+
val endStudyDialog = EndStudyDialog(view.context, studyId, onComplete = {
156+
listener?.fetchProgress() // ✅ 여기서 호출
157+
})
158+
endStudyDialog.start()
162159
popupWindow.dismiss()
163160
}
164161

@@ -205,7 +202,7 @@ class BoardAdapter(
205202
view.getLocationOnScreen(location) // 화면 전체 기준 좌표 가져오기
206203
val x = location[0]
207204
val y = location[1]
208-
popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, x, y + 100)
205+
popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, x-100, y + 100)
209206
}
210207
}
211208
}
Lines changed: 119 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,67 @@
11
package com.example.spoteam_android.ui.mypage
22

3-
import android.util.Log
43
import android.view.LayoutInflater
54
import android.view.View
65
import android.view.ViewGroup
6+
import android.widget.ImageView
7+
import android.widget.TextView
8+
import androidx.core.content.ContextCompat
79
import androidx.recyclerview.widget.RecyclerView
810
import com.bumptech.glide.Glide
911
import com.example.spoteam_android.R
10-
import com.example.spoteam_android.databinding.ItemCommunityContentBinding
1112
import com.example.spoteam_android.databinding.ItemConsiderAttendanceBinding
12-
import com.example.spoteam_android.ui.community.CategoryPagesDetail
1313
import com.example.spoteam_android.ui.community.MyRecruitingStudyDetail
14-
import java.text.ParseException
15-
import java.text.SimpleDateFormat
16-
import java.util.Date
17-
import java.util.Locale
1814

19-
class ConsiderAttendanceContentRVAdapter(private var dataList: List<MyRecruitingStudyDetail>) : RecyclerView.Adapter<ConsiderAttendanceContentRVAdapter.ViewHolder>() {
15+
class ConsiderAttendanceContentRVAdapter(
16+
private var dataList: List<MyRecruitingStudyDetail>,
17+
private val onItemClick: (MyRecruitingStudyDetail) -> Unit,
18+
private val onPageClick: (Int) -> Unit,
19+
private val currentPageProvider: () -> Int,
20+
private val totalPagesProvider: () -> Int
21+
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
2022

21-
interface OnItemClickListener {
22-
fun onItemClick(data: MyRecruitingStudyDetail)
23-
// fun onLikeClick(data: CategoryPagesDetail)
24-
// fun onUnLikeClick(data: CategoryPagesDetail)
23+
companion object {
24+
private const val VIEW_TYPE_ITEM = 0
25+
private const val VIEW_TYPE_FOOTER = 1
2526
}
2627

27-
private lateinit var itemClickListener: OnItemClickListener
28+
override fun getItemCount(): Int = dataList.size + 1 // +1 for footer
2829

29-
fun setItemClickListener(onItemClickListener: OnItemClickListener) {
30-
this.itemClickListener = onItemClickListener
30+
override fun getItemViewType(position: Int): Int {
31+
return if (position == dataList.size) VIEW_TYPE_FOOTER else VIEW_TYPE_ITEM
3132
}
3233

33-
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
34-
val binding: ItemConsiderAttendanceBinding = ItemConsiderAttendanceBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
35-
return ViewHolder(binding)
36-
}
37-
38-
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
39-
if (position < dataList.size) {
40-
holder.bind(dataList[position])
34+
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
35+
return if (viewType == VIEW_TYPE_ITEM) {
36+
val binding = ItemConsiderAttendanceBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
37+
ItemViewHolder(binding)
38+
} else {
39+
val view = LayoutInflater.from(viewGroup.context)
40+
.inflate(R.layout.item_footer_paging, viewGroup, false)
41+
FooterViewHolder(view)
4142
}
43+
}
4244

43-
holder.binding.considerAttendanceBt.setOnClickListener {
44-
itemClickListener.onItemClick(dataList[position])
45+
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
46+
if (holder is ItemViewHolder && position < dataList.size) {
47+
val item = dataList[position]
48+
holder.bind(item)
49+
} else if (holder is FooterViewHolder) {
50+
holder.bind()
4551
}
4652
}
4753

48-
override fun getItemCount() = dataList.size
54+
inner class ItemViewHolder(val binding: ItemConsiderAttendanceBinding) :
55+
RecyclerView.ViewHolder(binding.root) {
4956

50-
inner class ViewHolder(val binding: ItemConsiderAttendanceBinding) : RecyclerView.ViewHolder(binding.root) {
5157
fun bind(data: MyRecruitingStudyDetail) {
5258
binding.tvTime.text = data.title
5359
binding.tvTitle.text = data.goal
5460
binding.tvName.text = data.maxPeople.toString()
5561
binding.tvName2.text = data.memberCount.toString()
5662
binding.tvName3.text = data.heartCount.toString()
5763
binding.tvName4.text = data.hitNum.toString()
64+
5865
if (data.liked) {
5966
binding.icHeartRed.visibility = View.VISIBLE
6067
binding.ImageView6.visibility = View.GONE
@@ -68,6 +75,91 @@ class ConsiderAttendanceContentRVAdapter(private var dataList: List<MyRecruiting
6875
.error(R.drawable.fragment_calendar_spot_logo)
6976
.fallback(R.drawable.fragment_calendar_spot_logo)
7077
.into(binding.ImageView4)
78+
79+
binding.considerAttendanceBt.setOnClickListener {
80+
onItemClick(data)
81+
}
82+
}
83+
}
84+
85+
inner class FooterViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
86+
fun bind() {
87+
val pageButtons = listOf<TextView>(
88+
itemView.findViewById(R.id.page_1),
89+
itemView.findViewById(R.id.page_2),
90+
itemView.findViewById(R.id.page_3),
91+
itemView.findViewById(R.id.page_4),
92+
itemView.findViewById(R.id.page_5),
93+
)
94+
val context = itemView.context
95+
96+
97+
val prev = itemView.findViewById<ImageView>(R.id.previous_page)
98+
val next = itemView.findViewById<ImageView>(R.id.next_page)
99+
100+
val currentPage = currentPageProvider()
101+
val totalPages = totalPagesProvider()
102+
103+
val startPage = when {
104+
totalPages <= 5 -> 0
105+
currentPage >= totalPages - 3 -> totalPages - 5
106+
currentPage >= 2 -> currentPage - 2
107+
else -> 0
108+
}
109+
110+
pageButtons.forEachIndexed { index, button ->
111+
val pageNum = startPage + index
112+
if (pageNum < totalPages) {
113+
button.text = (pageNum + 1).toString()
114+
button.visibility = View.VISIBLE
115+
button.setTextColor(
116+
if (pageNum == currentPage)
117+
itemView.context.getColor(R.color.b500)
118+
else
119+
itemView.context.getColor(R.color.g400)
120+
)
121+
button.setOnClickListener { onPageClick(pageNum) }
122+
} else {
123+
button.visibility = View.GONE
124+
}
125+
}
126+
127+
val grayColor = ContextCompat.getColor(context, R.color.g300)
128+
val blueColor = ContextCompat.getColor(context, R.color.b500)
129+
130+
// 좌우 버튼 처리
131+
if (totalPages <= 1) {
132+
prev.isEnabled = false
133+
next.isEnabled = false
134+
prev.setColorFilter(grayColor, android.graphics.PorterDuff.Mode.SRC_IN)
135+
next.setColorFilter(grayColor, android.graphics.PorterDuff.Mode.SRC_IN)
136+
} else {
137+
prev.isEnabled = true
138+
next.isEnabled = true
139+
prev.setColorFilter(blueColor, android.graphics.PorterDuff.Mode.SRC_IN)
140+
next.setColorFilter(blueColor, android.graphics.PorterDuff.Mode.SRC_IN)
141+
142+
prev.setOnClickListener {
143+
if (currentPage == 0) {
144+
onPageClick(totalPages - 1) // 첫 페이지에서 ← 클릭 → 마지막 페이지로
145+
} else {
146+
onPageClick(currentPage - 1)
147+
}
148+
}
149+
150+
next.setOnClickListener {
151+
if (currentPage == totalPages - 1) {
152+
onPageClick(0) // 마지막 페이지에서 → 클릭 → 첫 페이지로
153+
} else {
154+
onPageClick(currentPage + 1)
155+
}
156+
}
157+
}
71158
}
72159
}
160+
161+
fun updateList(newList: List<MyRecruitingStudyDetail>) {
162+
dataList = newList
163+
notifyDataSetChanged()
164+
}
73165
}

0 commit comments

Comments
 (0)