diff --git a/app/src/main/java/umc/com/mobile/project/data/model/home/UserResponse.kt b/app/src/main/java/umc/com/mobile/project/data/model/home/UserResponse.kt index d94e9e9f..9c5410ff 100644 --- a/app/src/main/java/umc/com/mobile/project/data/model/home/UserResponse.kt +++ b/app/src/main/java/umc/com/mobile/project/data/model/home/UserResponse.kt @@ -25,10 +25,6 @@ data class Result( ) data class FutureTimeTableDto( - val semester: SemesterInfo -) - -data class SemesterInfo( val sumCredits: Int, val timeTableDtoList: List ) diff --git a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/adapter/AverageRVAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/adapter/AverageRVAdapter.kt index 5fe96cec..b2bbc9c5 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/adapter/AverageRVAdapter.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/adapter/AverageRVAdapter.kt @@ -46,7 +46,7 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) : val grade = if (position % 2 == 0) position / 2 + 1 else (position + 1) / 2 // totalAverageGrade += Integer.parseInt(gradesTotalDto.averageGrade) - binding.tvSemesterContent1.text = "$grade - $semester" + binding.tvSemesterContent1.text = "$grade - $semester" binding.tvAverageGradeContent1.text = gradesTotalDto.averageGrade // viewModel.onSetTotalAverageGrade(totalAverageGrade, position+1) } @@ -72,6 +72,7 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) : fun setData(data: List) { dataList.clear() dataList.addAll(data) +// viewModel.onSetNullCheckGrade(true) repeat(8 - dataList.size) { dataList.add( GradesTotalDto( @@ -82,8 +83,8 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) : "0" ) ) + viewModel.onSetNullCheckGrade(false) } - notifyDataSetChanged() } diff --git a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/viewmodel/GradeViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/viewmodel/GradeViewModel.kt index 44ff1dc7..b0167844 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/viewmodel/GradeViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/viewmodel/GradeViewModel.kt @@ -45,6 +45,10 @@ class GradeViewModel : ViewModel() { val totalAverage: LiveData get() = _totalAverage + private val _isNullCheckGrade: MutableLiveData = MutableLiveData() + val isNullCheckGrade: LiveData + get() = _isNullCheckGrade + val selectedSemesterGradeAndGrades: MediatorLiveData?>> = MediatorLiveData() init { @@ -138,4 +142,8 @@ class GradeViewModel : ViewModel() { fun onSetTotalAverageGrade(totalAverageGrade: Double, totalNumber: Int) { _totalAverage.postValue((totalAverageGrade/totalNumber)) } + + fun onSetNullCheckGrade(flag: Boolean) { + _isNullCheckGrade.postValue(flag) + } } \ No newline at end of file diff --git a/app/src/main/java/umc/com/mobile/project/ui/home/HomeFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/home/HomeFragment.kt index 1f424e21..ce980b49 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/home/HomeFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/home/HomeFragment.kt @@ -23,7 +23,6 @@ import umc.com.mobile.project.ui.home.viewmodel.HomeViewModel class HomeFragment : Fragment() { private var _binding: FragmentHomeBinding? = null private val viewModel: HomeViewModel by viewModels() -// private val gradDateViewModel: GradDateViewModel by activityViewModels() private val binding get() = _binding!! override fun onCreateView( @@ -39,7 +38,6 @@ class HomeFragment : Fragment() { viewModel.getUserInfo() // 홈 화면 정보 조회 api navigateFragment() -// saveCheeringMemo() // 응원의 한마디 연결 setupRecyclerView() // recyclerView 연결 setupHomeInfoRetrofit() // 홈 화면 ui 연결 @@ -48,7 +46,6 @@ class HomeFragment : Fragment() { override fun onPause() { super.onPause() -// saveCheeringMemo() } override fun onDestroyView() { @@ -66,13 +63,6 @@ class HomeFragment : Fragment() { } } -/* - private fun saveCheeringMemo() { - gradDateViewModel.dateResponse.observe(viewLifecycleOwner, Observer { - }) - } -*/ - private fun setupRecyclerView() { val adapter = NextPlanRVAdapter() @@ -80,14 +70,10 @@ class HomeFragment : Fragment() { val futureTimeTableDto = userInfoResponse?.result?.futureTimeTableDto if (futureTimeTableDto != null) { val futureSemesterInfo = futureTimeTableDto.values.firstOrNull() - if (futureSemesterInfo?.semester != null) { - val timeTableDtoList = futureSemesterInfo.semester.timeTableDtoList + val timeTableDtoList = futureSemesterInfo?.timeTableDtoList + if (timeTableDtoList != null) { adapter.setData(timeTableDtoList) - } else { - Log.e("HomeFragment", "정보 없음") } - } else { - Log.e("HomeFragment", "정보 없음") } }) @@ -120,7 +106,7 @@ class HomeFragment : Fragment() { binding.tvGradeSemester.text = planKey binding.tvTotalCredit.text = - (it?.result?.futureTimeTableDto?.get(planKey)?.semester?.sumCredits ?: "총 학점 0").toString() + "총 학점 ${it?.result?.futureTimeTableDto?.get(planKey)?.sumCredits}" ?: "총 학점 0" val dDay = it?.result?.dday ?: 0 binding.progressbarToGrad.progress = 1460 - dDay diff --git a/app/src/main/java/umc/com/mobile/project/ui/home/adapter/NextPlanRVAdapter.kt b/app/src/main/java/umc/com/mobile/project/ui/home/adapter/NextPlanRVAdapter.kt index 81c9b4a8..e959a866 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/home/adapter/NextPlanRVAdapter.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/home/adapter/NextPlanRVAdapter.kt @@ -3,12 +3,12 @@ package umc.com.mobile.project.ui.home.adapter import androidx.recyclerview.widget.RecyclerView import android.view.LayoutInflater import android.view.ViewGroup +import umc.com.mobile.project.data.model.gradInfo.GradesTotalDto import umc.com.mobile.project.data.model.home.TimeTableDto import umc.com.mobile.project.databinding.ItemHomeNextPlanBinding class NextPlanRVAdapter : RecyclerView.Adapter() { - - private var dataList = listOf() + private var dataList = mutableListOf() inner class MyViewHolder(private val binding: ItemHomeNextPlanBinding) : RecyclerView.ViewHolder(binding.root) { @@ -36,8 +36,9 @@ class NextPlanRVAdapter : RecyclerView.Adapter() return dataList.size } - fun setData(dataList: List) { - this.dataList = dataList + fun setData(data: List) { + dataList.clear() + dataList.addAll(data) notifyDataSetChanged() } diff --git a/app/src/main/java/umc/com/mobile/project/ui/home/viewmodel/HomeViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/home/viewmodel/HomeViewModel.kt index 7172c1e8..4b3f7745 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/home/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/home/viewmodel/HomeViewModel.kt @@ -85,10 +85,9 @@ class HomeViewModel : ViewModel() { if (userResponse.result.futureTimeTableDto.isEmpty()) { _planStatus.postValue(false) + } else { + _planStatus.postValue(true) } -// Log.d("home", "${response.body()}") - Log.d("home", "${userResponse.result.futureTimeTableDto}") - } else { _error.postValue("서버 응답이 올바르지 않습니다.") } } else { diff --git a/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt b/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt index 8a3c054d..469bdba8 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt @@ -2,15 +2,19 @@ package umc.com.mobile.project.ui.login import android.content.Intent import android.os.Bundle +import android.os.Handler import android.view.KeyEvent +import android.view.WindowManager import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager import androidx.activity.viewModels +import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.Observer import androidx.lifecycle.lifecycleScope import umc.com.mobile.project.MainActivity +import umc.com.mobile.project.R import umc.com.mobile.project.databinding.ActivityLoginBinding import umc.com.mobile.project.ui.login.viewmodel.LoginViewModel import kotlin.coroutines.coroutineContext @@ -56,6 +60,28 @@ class LoginActivity : AppCompatActivity() { } false } + + // 이전 화면에서 로그아웃을 통해 돌아온 경우 다이얼로그 표시 + val isLoggedOut = intent.getBooleanExtra("logged_out", false) + if (isLoggedOut) { + showLogoutDialog() + } + } + + private fun showLogoutDialog() { + var dialogBuilder = + AlertDialog.Builder(this, R.style.CustomAlertDialogTheme) + + val customView = layoutInflater.inflate(R.layout.custom_dialog_logout_home, null) + dialogBuilder.setView(customView) + + val dialog = dialogBuilder.create() + + dialog.show() + + Handler().postDelayed({ + dialog.dismiss() + }, 2000) } } \ No newline at end of file diff --git a/app/src/main/java/umc/com/mobile/project/ui/setting/SettingFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/setting/SettingFragment.kt index 4b69de5a..c0602938 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/setting/SettingFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/setting/SettingFragment.kt @@ -7,6 +7,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.Button import android.widget.Toast import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels @@ -35,7 +36,8 @@ class SettingFragment : Fragment() { viewModel.userInfoResponse.observe(viewLifecycleOwner, Observer { binding.tvAccountIdContent.text = it?.result?.id.toString() - binding.tvAccountMajorContent.text = "1트랙: ${it?.result?.track1} / 트랙: ${it?.result?.track2}" + binding.tvAccountMajorContent.text = + "1트랙: ${it?.result?.track1} / 트랙: ${it?.result?.track2}" }) return binding.root @@ -52,25 +54,29 @@ class SettingFragment : Fragment() { } binding.tvEtcLogout.setOnClickListener { - var dialog = AlertDialog.Builder(requireContext()) - dialog.setTitle("로그아웃을 하시겠습니까?") - dialog.setMessage("서비스를 이용해주셔서 감사합니다.") + var dialogBuilder = + AlertDialog.Builder(requireContext(), R.style.CustomAlertDialogTheme) - fun toast() { - Toast.makeText(requireContext(), "로그아웃 되었습니다.", Toast.LENGTH_SHORT).show() + val customView = layoutInflater.inflate(R.layout.custom_dialog_logout, null) + dialogBuilder.setView(customView) + val alertDialog = dialogBuilder.create() + + alertDialog.show() + + customView.findViewById