Skip to content

Commit 7ed7137

Browse files
authored
Merge branch 'dev' into feat(#610)-mockbean-최적화
2 parents 71ada03 + 2a2607e commit 7ed7137

40 files changed

+854
-477
lines changed

android/gitudy/presentation/src/main/java/com/takseha/presentation/adapter/DetailCommentListRVAdapter.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class DetailCommentListRVAdapter(val context: Context, val commentList: List<Com
3434
var date = binding.dateText
3535
var content = binding.contentText
3636
var moreBtn = binding.moreBtn
37-
var likeBtn = binding.likeBtn
38-
var heartBtn = binding.heartBtn
37+
// var likeBtn = binding.likeBtn
38+
// var heartBtn = binding.heartBtn
3939
}
4040

4141
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
@@ -66,12 +66,12 @@ class DetailCommentListRVAdapter(val context: Context, val commentList: List<Com
6666
// more 버튼 클릭 이벤트 처리
6767
showPopupMenu(v, position)
6868
}
69-
holder.likeBtn.setOnClickListener { v ->
70-
this.onClickListener?.onLikeClick(v, position)
71-
}
72-
holder.heartBtn.setOnClickListener { v ->
73-
this.onClickListener?.onHeartClick(v, position)
74-
}
69+
// holder.likeBtn.setOnClickListener { v ->
70+
// this.onClickListener?.onLikeClick(v, position)
71+
// }
72+
// holder.heartBtn.setOnClickListener { v ->
73+
// this.onClickListener?.onHeartClick(v, position)
74+
// }
7575

7676
}
7777

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/feed/FeedHomeFragment.kt

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.os.Bundle
55
import android.view.LayoutInflater
66
import android.view.View
77
import android.view.View.GONE
8+
import android.view.View.INVISIBLE
89
import android.view.View.VISIBLE
910
import android.view.ViewGroup
1011
import androidx.core.content.ContextCompat
@@ -16,6 +17,7 @@ import com.takseha.data.dto.feed.StudyStatus
1617
import com.takseha.presentation.R
1718
import com.takseha.presentation.adapter.FeedRVAdapter
1819
import com.takseha.presentation.databinding.FragmentFeedHomeBinding
20+
import com.takseha.presentation.ui.home.MainHomeAlertActivity
1921
import com.takseha.presentation.viewmodel.feed.FeedHomeViewModel
2022
import com.takseha.presentation.viewmodel.feed.StudyInfoWithBookmarkStatus
2123
import com.takseha.presentation.viewmodel.home.MyStudyWithTodo
@@ -37,6 +39,7 @@ class FeedHomeFragment : Fragment() {
3739
lifecycleScope.launch {
3840
launch { viewModel.getFeedList(null, 50, sortStatus) }
3941
launch { viewModel.getStudyCount() }
42+
launch { viewModel.getAlertCount(null, 1) }
4043
}
4144
}
4245

@@ -54,6 +57,7 @@ class FeedHomeFragment : Fragment() {
5457
viewLifecycleOwner.lifecycleScope.launch {
5558
viewModel.uiState.collectLatest {
5659
with(binding) {
60+
alarmActiveDot.visibility = if (it.isAlert) VISIBLE else INVISIBLE
5761
feedCnt.text = if (it.studyCnt == null) "" else it.studyCnt.toString()
5862

5963
if (it.isFeedEmpty == null) {
@@ -78,6 +82,10 @@ class FeedHomeFragment : Fragment() {
7882
}
7983
}
8084
with(binding) {
85+
alarmBtn.setOnClickListener {
86+
val intent = Intent(requireContext(), MainHomeAlertActivity::class.java)
87+
startActivity(intent)
88+
}
8189
sortBtn.setOnClickListener {
8290
var standard: String
8391
if (sortStatus == "createdDateTime") {
@@ -91,6 +99,7 @@ class FeedHomeFragment : Fragment() {
9199
viewLifecycleOwner.lifecycleScope.launch {
92100
launch { viewModel.getFeedList(null, 50, sortStatus) }
93101
launch { viewModel.getStudyCount() }
102+
launch { viewModel.getAlertCount(null, 1) }
94103
}
95104
}
96105
feedSwipeRefreshLayout.setOnRefreshListener {

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/feed/StudyApplyInfoFragment.kt

+5-15
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package com.takseha.presentation.ui.feed
33
import android.content.ClipData
44
import android.content.ClipboardManager
55
import android.content.Context
6-
import android.graphics.Color
7-
import android.graphics.drawable.ColorDrawable
86
import android.os.Bundle
97
import android.util.Log
108
import android.view.LayoutInflater
@@ -13,25 +11,19 @@ import android.view.View.GONE
1311
import android.view.View.VISIBLE
1412
import android.view.ViewGroup
1513
import androidx.core.content.ContextCompat
16-
import androidx.core.content.ContextCompat.getSystemService
1714
import androidx.fragment.app.Fragment
1815
import androidx.fragment.app.activityViewModels
1916
import androidx.lifecycle.lifecycleScope
2017
import androidx.navigation.findNavController
2118
import androidx.recyclerview.widget.LinearLayoutManager
22-
import com.google.android.material.snackbar.Snackbar
2319
import com.takseha.data.dto.feed.StudyPeriodStatus
2420
import com.takseha.data.dto.feed.StudyStatus
2521
import com.takseha.presentation.R
2622
import com.takseha.presentation.adapter.CategoryInStudyRVAdapter
2723
import com.takseha.presentation.databinding.FragmentStudyApplyInfoBinding
28-
import com.takseha.presentation.databinding.LayoutSnackbarDescBinding
29-
import com.takseha.presentation.databinding.LayoutSnackbarGreyBinding
30-
import com.takseha.presentation.databinding.LayoutSnackbarRedBinding
3124
import com.takseha.presentation.ui.common.CustomSetDialog
3225
import com.takseha.presentation.viewmodel.feed.StudyApplyViewModel
3326
import com.takseha.presentation.viewmodel.feed.StudyMainInfoState
34-
import kotlinx.coroutines.async
3527
import kotlinx.coroutines.flow.collectLatest
3628
import kotlinx.coroutines.launch
3729

@@ -107,16 +99,11 @@ class StudyApplyInfoFragment : Fragment() {
10799
backBtn.setOnClickListener {
108100
requireActivity().finish()
109101
}
110-
studyGithubLink.setOnClickListener {
102+
copyBtn.setOnClickListener {
111103
val textToCopy = studyGithubLinkText.text
112104
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
113105
val clip = ClipData.newPlainText("label", textToCopy)
114106
clipboard.setPrimaryClip(clip)
115-
116-
copyOkImg.visibility = VISIBLE
117-
copyOkImg.postDelayed({
118-
copyOkImg.visibility = GONE
119-
}, 2000)
120107
}
121108
studyEnterBtn.setOnClickListener {
122109
it.findNavController()
@@ -156,7 +143,10 @@ class StudyApplyInfoFragment : Fragment() {
156143
val studyImgSrc = setStudyImg(studyImgColor.toIntOrNull() ?: 0)
157144
studyImg.setImageResource(studyImgSrc)
158145
studyEndTag.visibility = GONE
159-
if (studyInfo.currentMember == studyInfo.maximumMember) {
146+
if (studyInfo.isLeader) {
147+
studyEnterBtn.isEnabled = false
148+
studyEnterBtn.text = "이미 가입한 스터디입니다"
149+
} else if(studyInfo.currentMember == studyInfo.maximumMember) {
160150
studyEnterBtn.isEnabled = false
161151
studyEnterBtn.text = "모집 완료"
162152
} else {

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/home/MainHomeAlertFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class MainHomeAlertFragment : Fragment() {
154154
putExtra("studyStatus", StudyStatus.STUDY_PUBLIC)
155155
}
156156
startActivity(intent)
157-
} else if (notice.title.contains("커밋 승인") || notice.title.contains("커밋 반려")) {
157+
} else if (notice.title.contains("커밋")) {
158158
val intent = Intent(requireContext(), MyStudyMainActivity::class.java).apply {
159159
putExtra("studyInfoId", notice.studyInfoId)
160160
putExtra("targetFragment", "toDoFragment")

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/home/MainHomeFragment.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import android.content.Intent
44
import android.graphics.Color
55
import android.os.Build
66
import android.os.Bundle
7-
import android.util.Log
87
import android.view.LayoutInflater
98
import android.view.View
109
import android.view.View.GONE
10+
import android.view.View.INVISIBLE
1111
import android.view.View.VISIBLE
1212
import android.view.ViewGroup
1313
import android.view.animation.AnimationUtils
@@ -19,7 +19,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
1919
import com.takseha.data.dto.mystudy.TodoStatus
2020
import com.takseha.presentation.R
2121
import com.takseha.presentation.adapter.MainStudyRVAdapter
22-
import com.takseha.presentation.adapter.MyStudyRVAdapter
2322
import com.takseha.presentation.databinding.FragmentMainHomeBinding
2423
import com.takseha.presentation.ui.mystudy.MyStudyMainActivity
2524
import com.takseha.presentation.viewmodel.home.MainHomeUserInfoUiState
@@ -41,6 +40,7 @@ class MainHomeFragment : Fragment() {
4140
lifecycleScope.launch {
4241
launch { viewModel.getUserInfo() }
4342
launch { viewModel.getMyStudyList(null, 50, "score") }
43+
launch { viewModel.getAlertCount(null, 1) }
4444
}
4545
}
4646

@@ -89,6 +89,7 @@ class MainHomeFragment : Fragment() {
8989
viewLifecycleOwner.lifecycleScope.launch {
9090
launch { viewModel.getUserInfo() }
9191
launch { viewModel.getMyStudyList(null, 50, "score") }
92+
launch { viewModel.getAlertCount(null, 1) }
9293
}
9394
}
9495

@@ -120,6 +121,7 @@ class MainHomeFragment : Fragment() {
120121
profileProgressBar.max = userInfo.progressMax
121122
profileProgressBar.progress = userInfo.progressScore
122123
characterImg.setImageResource(userInfo.characterImgSrc)
124+
alarmActiveDot.visibility = if (userInfo.isAlert) VISIBLE else INVISIBLE
123125
}
124126
}
125127

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/mystudy/MyStudyHomeFragment.kt

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.util.Log
66
import android.view.LayoutInflater
77
import android.view.View
88
import android.view.View.GONE
9+
import android.view.View.INVISIBLE
910
import android.view.View.VISIBLE
1011
import android.view.ViewGroup
1112
import androidx.core.content.ContextCompat
@@ -17,6 +18,7 @@ import com.takseha.data.dto.feed.StudyStatus
1718
import com.takseha.presentation.R
1819
import com.takseha.presentation.adapter.MyStudyRVAdapter
1920
import com.takseha.presentation.databinding.FragmentMyStudyHomeBinding
21+
import com.takseha.presentation.ui.home.MainHomeAlertActivity
2022
import com.takseha.presentation.viewmodel.home.MainHomeViewModel
2123
import com.takseha.presentation.viewmodel.home.MyStudyWithTodo
2224
import com.takseha.presentation.viewmodel.mystudy.MyStudyHomeViewModel
@@ -39,6 +41,7 @@ class MyStudyHomeFragment : Fragment() {
3941
lifecycleScope.launch {
4042
launch { viewModel.getMyStudyList(null, 50, sortStatus) }
4143
launch { viewModel.getStudyCount() }
44+
launch { viewModel.getAlertCount(null, 1) }
4245
}
4346
}
4447

@@ -54,6 +57,7 @@ class MyStudyHomeFragment : Fragment() {
5457
super.onViewCreated(view, savedInstanceState)
5558
viewLifecycleOwner.lifecycleScope.launch {
5659
viewModel.myStudyState.collectLatest {
60+
binding.alarmActiveDot.visibility = if (it.isAlert) VISIBLE else INVISIBLE
5761
binding.myStudyCnt.text = it.studyCnt.toString()
5862

5963
if (it.isMyStudiesEmpty == null) {
@@ -78,6 +82,10 @@ class MyStudyHomeFragment : Fragment() {
7882
}
7983
// 정렬: 최신순, 랭킹순
8084
with(binding) {
85+
alarmBtn.setOnClickListener {
86+
val intent = Intent(requireContext(), MainHomeAlertActivity::class.java)
87+
startActivity(intent)
88+
}
8189
sortBtn.setOnClickListener {
8290
var standard: String
8391
if (sortStatus == "createdDateTime") {
@@ -109,6 +117,7 @@ class MyStudyHomeFragment : Fragment() {
109117
viewLifecycleOwner.lifecycleScope.launch {
110118
launch { viewModel.getMyStudyList(null, 50, sortStatus) }
111119
launch { viewModel.getStudyCount() }
120+
launch { viewModel.getAlertCount(null, 1) }
112121
}
113122
}
114123

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/mystudy/MyStudyMainFragment.kt

+11
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ class MyStudyMainFragment : Fragment() {
125125
val clip = ClipData.newPlainText("githubLink", textToCopy)
126126
clipboard.setPrimaryClip(clip)
127127
}
128+
todoInfoBtn.setOnClickListener {
129+
if(todoInfoText.visibility == GONE) {
130+
todoInfoText.visibility = VISIBLE
131+
} else {
132+
todoInfoText.visibility = GONE
133+
}
134+
}
135+
todoBox.setOnClickListener {
136+
view.findNavController()
137+
.navigate(R.id.action_myStudyMainFragment_to_toDoFragment, bundle)
138+
}
128139
todoMoreBtn.setOnClickListener {
129140
view.findNavController()
130141
.navigate(R.id.action_myStudyMainFragment_to_toDoFragment, bundle)

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/mystudy/ToDoFragment.kt

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ class ToDoFragment : Fragment() {
8383
todoSwipeRefreshLayout.isRefreshing = false
8484
}
8585
}
86+
todoInfoBtn.setOnClickListener {
87+
if(todoInfoText.visibility == GONE) {
88+
todoInfoText.visibility = VISIBLE
89+
} else {
90+
todoInfoText.visibility = GONE
91+
}
92+
}
8693
backBtn.setOnClickListener {
8794
it.findNavController().popBackStack()
8895
}

android/gitudy/presentation/src/main/java/com/takseha/presentation/ui/profile/ProfileHomeFragment.kt

-4
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ class ProfileHomeFragment : Fragment() {
9797
val intent = Intent(requireContext(), ProfileEditActivity::class.java)
9898
startActivity(intent)
9999
}
100-
alarmBtn.setOnClickListener {
101-
val intent = Intent(requireContext(), MainHomeAlertActivity::class.java)
102-
startActivity(intent)
103-
}
104100
commitMoreBtn.setOnClickListener {
105101
val intent = Intent(requireContext(), MyCommitActivity::class.java)
106102
intent.putExtra("isLeader", false)

android/gitudy/presentation/src/main/java/com/takseha/presentation/viewmodel/feed/FeedHomeViewModel.kt

+31-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.lifecycle.viewModelScope
77
import com.takseha.data.dto.feed.StudyInfo
88
import com.takseha.data.dto.feed.StudyRankResponse
99
import com.takseha.data.repository.gitudy.GitudyBookmarksRepository
10+
import com.takseha.data.repository.gitudy.GitudyNoticeRepository
1011
import com.takseha.data.repository.gitudy.GitudyStudyRepository
1112
import com.takseha.presentation.viewmodel.common.BaseViewModel
1213
import kotlinx.coroutines.async
@@ -19,6 +20,7 @@ import kotlinx.coroutines.launch
1920
class FeedHomeViewModel : BaseViewModel() {
2021
private var gitudyStudyRepository = GitudyStudyRepository()
2122
private var gitudyBookmarksRepository = GitudyBookmarksRepository()
23+
private val gitudyNoticeRepository = GitudyNoticeRepository()
2224

2325
private var _uiState = MutableStateFlow(FeedHomeUiState())
2426
val uiState = _uiState.asStateFlow()
@@ -171,13 +173,41 @@ class FeedHomeViewModel : BaseViewModel() {
171173
}
172174
)
173175
}
176+
177+
fun getAlertCount(cursorTime: String?, limit: Long) =viewModelScope.launch {
178+
safeApiCall(
179+
apiCall = { gitudyNoticeRepository.getNoticeList(cursorTime, limit) },
180+
onSuccess = { response ->
181+
if (response.isSuccessful) {
182+
val noticeList = response.body()
183+
184+
if (noticeList?.isEmpty() != false) {
185+
_uiState.update { it.copy(
186+
isAlert = false
187+
) }
188+
} else {
189+
_uiState.update { it.copy(
190+
isAlert = true
191+
) }
192+
}
193+
194+
} else {
195+
Log.e(
196+
"FeedHomeViewModel",
197+
"isAlertResponse status: ${response.code()}\nisAlertResponse message: ${response.errorBody()?.string()}"
198+
)
199+
}
200+
}
201+
)
202+
}
174203
}
175204

176205
data class FeedHomeUiState(
177206
var studyInfoList: List<StudyInfoWithBookmarkStatus> = listOf(),
178207
var studyCategoryMappingMap: Map<Int, List<String>> = mapOf(),
179208
var studyCnt: Int? = null,
180-
var isFeedEmpty: Boolean? = null
209+
var isFeedEmpty: Boolean? = null,
210+
val isAlert: Boolean = false
181211
)
182212

183213
data class StudyInfoWithBookmarkStatus(

android/gitudy/presentation/src/main/java/com/takseha/presentation/viewmodel/feed/MakeStudyViewModel.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class MakeStudyViewModel() : BaseViewModel() {
103103
Log.e("MakeStudyViewModel", "Exception: ${it.message}")
104104
} ?: run {
105105
response?.let {
106-
Log.e("MakeStudyViewModel", "HTTP Error: ${it.code()} ${it.message()}")
106+
Log.e("MakeStudyViewModel", "HTTP Error: ${it.code()} ${it.errorBody()?.string()}")
107107
}
108108
}
109109
}

0 commit comments

Comments
 (0)