Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,6 @@ dependencies {

// dot indicator
implementation("com.tbuonomo:dotsindicator:5.0")

implementation("com.google.android.flexbox:flexbox:3.0.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ data class FeedUploadRequest(
var othersId: List<Int>?,
var distance: Int,
var reducedKcal: Int,
var location: String,
var weather: String,
var temperature: Int,
var fineDust: String,
var location: String?,
var weather: String?,
var temperature: Int?,
var fineDust: String?,
var feeling: String?
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ data class FeedEmotionResponse(
val agentProfileImgUrl: String,
val agentNickname: String,
val emotionType: String, // "LIKE", "BEST", "SUPPORT", "CONGRAT"
val reactedAt: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class GroupMateListFragment : Fragment() {
override fun onItemClick(position: Int) {
val userId = getGroupUnexercisedMateInfo?.get(position)?.userId ?: 0

homeViewModel.batonGroupMember(mainActivity, userId)
homeViewModel.batonGroupMember(mainActivity, userId) {

}
}
}
}
Expand Down
66 changes: 58 additions & 8 deletions app/src/main/java/com/team/score/Group/GroupSearchFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ class GroupSearchFragment : Fragment() {
// 검색
if(editTextSearch.text.isNotEmpty()) {
keyword = editTextSearch.text.toString()
viewModel.searchSchoolGroup(mainActivity, schoolId, keyword)

recyclerViewSearchResult.visibility = View.VISIBLE
textViewSearchTitle.text = "‘${keyword}’ 검색 결과"

viewModel.searchSchoolGroup(mainActivity, schoolId, keyword) {
layoutSearchResult.visibility = View.VISIBLE
recyclerViewSearchResult.visibility = View.GONE
layoutSearchResultEmpty.visibility = View.VISIBLE
layoutSearchEmpty.visibility = View.GONE
}
}

true
Expand All @@ -72,8 +81,19 @@ class GroupSearchFragment : Fragment() {
editTextSearch.text.clear()
layoutSearchEmpty.visibility = View.VISIBLE
layoutSearchResult.visibility = View.GONE
layoutSearchResultEmpty.visibility = View.GONE

searchKewordUiUpdate()

searchKewordAdapter.updateList(MyApplication.preferences.getRecentSearchesLimited(mainActivity))
}

buttonSearchOtherGroup.setOnClickListener {
editTextSearch.text.clear()
layoutSearchEmpty.visibility = View.VISIBLE
layoutSearchResult.visibility = View.GONE
layoutSearchResultEmpty.visibility = View.GONE
}
}
}

Expand Down Expand Up @@ -123,13 +143,30 @@ class GroupSearchFragment : Fragment() {
}

searchKewordAdapter = RecentSearchGroupKeywordAdapter(mainActivity, MyApplication.preferences.getRecentSearchesLimited(mainActivity)).apply {
itemClickListener = object : RecentSearchGroupKeywordAdapter.OnItemClickListener {
override fun onItemClick(position: Int) {
keyword = MyApplication.preferences.getRecentSearchesLimited(mainActivity).get(position)
binding.searchBar.editTextSearch.setText(keyword)
viewModel.searchSchoolGroup(mainActivity, schoolId, keyword)
itemClickListener = object : RecentSearchGroupKeywordAdapter.OnItemClickListener {
override fun onItemClick(position: Int) {
// 검색어 클릭 시
keyword = MyApplication.preferences.getRecentSearchesLimited(mainActivity)[position]
binding.run {
searchBar.editTextSearch.setText(keyword)
recyclerViewSearchResult.visibility = View.VISIBLE
textViewSearchTitle.text = "‘${keyword}’ 검색 결과"
}
viewModel.searchSchoolGroup(mainActivity, schoolId, keyword) {
binding.run {
layoutSearchResult.visibility = View.VISIBLE
recyclerViewSearchResult.visibility = View.GONE
layoutSearchResultEmpty.visibility = View.VISIBLE
layoutSearchEmpty.visibility = View.GONE
}
}
}

override fun onDeleteClick(position: Int) {
// 삭제 시 동작 필요 시 작성
searchKewordUiUpdate()
}
}
}
}

recommendGroupAdapter = SearchGroupAdapter(mainActivity, getRecommendGroupInfo).apply {
Expand Down Expand Up @@ -195,7 +232,6 @@ class GroupSearchFragment : Fragment() {
binding.run {
layoutSearchResult.visibility = View.VISIBLE
layoutSearchEmpty.visibility = View.GONE
textViewSearchTitle.text = "‘${keyword}’ 검색 결과"
}

searchGroupAdapter.updateList(getGroupInfo)
Expand All @@ -219,11 +255,25 @@ class GroupSearchFragment : Fragment() {
layoutSearchEmpty.visibility = View.VISIBLE
layoutSearchResult.visibility = View.GONE

searchKewordUiUpdate()

toolbar.run {
buttonBack.setOnClickListener {
fragmentManager?.popBackStack()
}
}
}
}

fun searchKewordUiUpdate() {
binding.run {
if(MyApplication.preferences.getRecentSearchesLimited(mainActivity).isEmpty()) {
textViewRecentSearchTitle.visibility = View.GONE
recyclerViewSearchWord.visibility = View.GONE
} else {
textViewRecentSearchTitle.visibility = View.VISIBLE
recyclerViewSearchWord.visibility = View.VISIBLE
}
}
}
}
10 changes: 6 additions & 4 deletions app/src/main/java/com/team/score/Group/MyGroupDetailFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,14 @@ class MyGroupDetailFragment : Fragment() {
times[index].text = if (hasExercise) timeText else "" // 기록 없으면 시간 텍스트 없음
times[index].visibility = if (hasExercise) View.VISIBLE else View.GONE
spaces[index].visibility = if (hasExercise) View.VISIBLE else View.GONE
val graphWidth = (37 * resources.displayMetrics.density).toInt()
if(!hasExercise) {
val graphWidth = (37 * resources.displayMetrics.density).toInt()

graphs[index].layoutParams = graphs[index].layoutParams.apply {
width = graphWidth
graphs[index].layoutParams = graphs[index].layoutParams.apply {
width = graphWidth
}
graphs[index].requestLayout() // 레이아웃 갱신
}
graphs[index].requestLayout() // 레이아웃 갱신


Glide.with(profiles[index].context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ class MyGroupRankingFragment : Fragment() {
binding.run {
if(myRanking != null) {
layoutGroupMyRanking.run {
textViewGroupTotalExerciseTimeValue.text = "${myRanking.weeklyExerciseTime?.div(60)}시간"
var time = if(myRanking.weeklyExerciseTime == 0.0) 0 else myRanking.weeklyExerciseTime?.div(60)?.toInt()
textViewGroupTotalExerciseTimeValue.text = "${time}시간"
textViewGroupLevelValue.text = "${myRanking.weeklyLevelIncrement}"
textViewGroupRankingValue.text = "${myRanking.rankNum}위"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ class GroupMemberOthersRankingAdapter(

if((item?.changedAmount ?: 0) < 0) {
imageViewRankingChange.setImageResource(R.drawable.ic_arrow_down_blue)
textViewRankingChange.text = "${(item?.changedAmount ?: 0)}"
textViewRankingChange.run {
text = "${-(item?.changedAmount ?: 0)}"
setTextColor(resources.getColor(R.color.blue))
}
} else if((item?.changedAmount ?: 0) == 0) {
imageViewRankingChange.visibility = View.INVISIBLE
textViewRankingChange.visibility = View.INVISIBLE
} else {
imageViewRankingChange.setImageResource(R.drawable.ic_arrow_up_red)
textViewRankingChange.text = "${(item?.changedAmount ?: 0)}"
textViewRankingChange.run {
text = "${(item?.changedAmount ?: 0)}"
setTextColor(resources.getColor(R.color.red))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class RecentSearchGroupKeywordAdapter(
}

interface OnItemClickListener {
fun onItemClick(position: Int) {}
fun onItemClick(position: Int)
fun onDeleteClick(position: Int)
}

var itemClickListener: OnItemClickListener? = null
Expand All @@ -58,13 +59,12 @@ class RecentSearchGroupKeywordAdapter(
binding.buttonDelete.setOnClickListener {
MyApplication.preferences.removeRecentSearch(activity, MyApplication.preferences.getRecentSearchesLimited(activity).get(position))
updateList(MyApplication.preferences.getRecentSearchesLimited(activity))

itemClickListener?.onDeleteClick(adapterPosition)
}

binding.root.setOnClickListener {
itemClickListener?.onItemClick(adapterPosition)

// 클릭 리스너 호출
onItemClickListener?.invoke(position)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class GroupViewModel: ViewModel() {
}

// 학교 그룹 검색
fun searchSchoolGroup(activity: MainActivity, schoolId: Int, keyword: String?) {
fun searchSchoolGroup(activity: MainActivity, schoolId: Int, keyword: String?, onFailure: () -> Unit) {

val tempGroupList = mutableListOf<GroupInfoResponse>()

Expand Down Expand Up @@ -467,10 +467,13 @@ class GroupViewModel: ViewModel() {
401 -> {
refreshToken(
activity,
retryRequest = { searchSchoolGroup(activity, schoolId, keyword) },
retryRequest = { searchSchoolGroup(activity, schoolId, keyword, onFailure) },
onFailure = { activity.finish() }
)
}
404 -> {
onFailure()
}
}
}
}
Expand Down Expand Up @@ -752,8 +755,7 @@ class GroupViewModel: ViewModel() {
feed.agentId,
feed.agentProfileImgUrl,
feed.agentNickname,
feed.emotionType,
feed.reactedAt
feed.emotionType
)

tempFeedEmotion.add(feedEmotionList)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/team/score/Home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class HomeFragment : Fragment() {
layoutWeeklyResult.recyclerViewGraph.apply {
adapter = weeklyGraphAdapter
layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
val spacingRatio = 0.15f
val spacingRatio = 0.18f
addItemDecoration(
DynamicSpacingItemDecoration(spacingRatio)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ class GroupRelayAdapter(
itemClickListener = object : GroupRelayTodayUnexercisedMemberAdapter.OnItemClickListener {
override fun onItemClick(unexerciseMemberPosition: Int) {
val userId = group.notExercisedUsers?.get(unexerciseMemberPosition)?.userId ?: return
viewModel.batonGroupMember(activity, userId)
updateList(group.notExercisedUsers, unexerciseMemberPosition)
viewModel.batonGroupMember(activity, userId) {
updateList(group.notExercisedUsers, unexerciseMemberPosition)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class HomeViewModel: ViewModel() {
}

// 바통 찌르기
fun batonGroupMember(activity: Activity, receiverId: Int) {
fun batonGroupMember(activity: Activity, receiverId: Int, onSuccess: () -> Unit) {
val apiClient = ApiClient(activity)
val tokenManager = TokenManager(activity)

Expand All @@ -95,6 +95,8 @@ class HomeViewModel: ViewModel() {

isBaton.value = BatonStatus(true, receiverId)

onSuccess()

} else {
// 통신이 실패한 경우(응답코드 3xx, 4xx 등)
var result: Boolean? = response.body()
Expand All @@ -110,7 +112,7 @@ class HomeViewModel: ViewModel() {
401 -> {
refreshToken(
activity,
retryRequest = { batonGroupMember(activity, receiverId) },
retryRequest = { batonGroupMember(activity, receiverId, onSuccess) },
onFailure = { activity.finish() }
)
}
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/java/com/team/score/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
package com.team.score

import android.Manifest
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.annotation.RequiresPermission
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModelProvider
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.LocationResult
import com.google.android.gms.location.LocationServices
import com.team.score.API.TokenManager
import com.team.score.Group.GroupFragment
import com.team.score.Home.HomeFragment
import com.team.score.Login.viewModel.UserViewModel
import com.team.score.Mypage.MypageMainFragment
import com.team.score.Mypage.viewModel.MypageViewModel
import com.team.score.Record.RecordFragment
import com.team.score.Record.viewModel.RecordViewModel
import com.team.score.Utils.DistanceUtil
import com.team.score.Utils.GlobalApplication.Companion.firebaseAnalytics
import com.team.score.Utils.MyApplication
import com.team.score.Utils.TimeUtil
import com.team.score.Utils.TimerManager
import com.team.score.Utils.TrackingService
import com.team.score.databinding.ActivityMainBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class MypageMainFragment : Fragment() {
Glide.with(this@MypageMainFragment)
.load(getUserInfo?.profileImgUrl)
.into(imageViewProfile)
textViewNotificationTime.text = "${formatExerciseTimeToKorean(getUserInfo?.goal ?: "00:00:00")}"
textViewNotificationTime.text = "${formatExerciseTimeToKorean(getUserInfo?.goal)}"

// 레벨 layout
layoutLevel.run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class MypageProfileEditFragment : Fragment(), SignUpGoalTimeBottomSheetListener,
mainActivity = activity as MainActivity

initView()
observeViewModel()

// Registers a photo picker activity launcher in single-select mode.
val pickMedia =
Expand Down Expand Up @@ -198,7 +197,14 @@ class MypageProfileEditFragment : Fragment(), SignUpGoalTimeBottomSheetListener,
MyApplication.userUpdateInfo?.userUpdateDto?.height = height ?: 0
MyApplication.userUpdateInfo?.userUpdateDto?.weight = weight ?: 0

viewModel.updateUserInfo(mainActivity)
viewModel.updateUserInfo(mainActivity,
onSuccess = {
parentFragmentManager.popBackStack()
},
onFailure = {
Toast.makeText(mainActivity, "마지막으로 학교 정보를 변경한 후 30일이 경과하지 않아 학교 정보를 수정할 수 없습니다.", Toast.LENGTH_LONG).show()
}
)
}

}
Expand All @@ -215,19 +221,6 @@ class MypageProfileEditFragment : Fragment(), SignUpGoalTimeBottomSheetListener,
binding.buttonEdit.isEnabled = true
}

fun observeViewModel() {
viewModel.run {
isUpdateUserInfo.observe(viewLifecycleOwner) {
if(it == true) {
fragmentManager?.popBackStack()
} else if(it == false) {
// 학교 정보 수정 불가 toast message
Toast.makeText(mainActivity, "마지막으로 학교 정보를 변경한 후 30일이 경과하지 않아 학교 정보를 수정할 수 없습니다.", Toast.LENGTH_LONG).show()
}
}
}
}

@RequiresApi(Build.VERSION_CODES.O)
fun initView() {
mainActivity.hideBottomNavigation(true)
Expand Down
Loading