diff --git a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/GradeFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/GradeFragment.kt index 65f6da9..04bae06 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/gradInfo/GradeFragment.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/gradInfo/GradeFragment.kt @@ -1,5 +1,6 @@ package umc.com.mobile.project.ui.gradInfo +import android.app.AlertDialog import android.os.Bundle import android.util.Log import android.view.LayoutInflater @@ -11,6 +12,7 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import okhttp3.internal.notify +import umc.com.mobile.project.R import umc.com.mobile.project.data.model.gradInfo.GradesResponse import umc.com.mobile.project.databinding.FragmentGradeBinding import umc.com.mobile.project.ui.gradInfo.adapter.AverageRVAdapter @@ -64,6 +66,10 @@ class GradeFragment : Fragment() { (binding.recyclerView2.adapter as? AverageRVAdapter)?.setData(gradesMap.values.toList()) }) + viewModel.isNullCheckGrade.observe(viewLifecycleOwner) { + if (it) { showDialog() } + } + return binding.root } @@ -82,4 +88,14 @@ class GradeFragment : Fragment() { binding.recyclerView2.adapter = adapter2 binding.recyclerView2.layoutManager = GridLayoutManager(context, 2) } + + private fun showDialog() { + val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.CustomAlertDialogTheme) + + val customView = layoutInflater.inflate(R.layout.custom_dialog_grade, null) + dialogBuilder.setView(customView) + + val alertDialog = dialogBuilder.create() + alertDialog.show() + } } 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 b2bbc9c..dacd0a4 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 @@ -4,8 +4,10 @@ import android.app.AlertDialog import androidx.recyclerview.widget.RecyclerView import android.view.LayoutInflater import android.view.ViewGroup +import androidx.core.content.ContentProviderCompat.requireContext import umc.com.mobile.project.data.model.gradInfo.GradesTotalDto import umc.com.mobile.project.databinding.ItemAverageGradeBinding +import umc.com.mobile.project.ui.gradInfo.GradeFragment import umc.com.mobile.project.ui.gradInfo.viewmodel.GradeViewModel class AverageRVAdapter(private val viewModel: GradeViewModel) : @@ -24,14 +26,8 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) : viewModel.onSemesterItemClick(semester) viewModel.onSemesterGradeItemClick(semesterGrade) - val gradesTotalDto = dataList[position] - if (gradesTotalDto.averageGrade == "0.0") { - val alertDialogBuilder = AlertDialog.Builder(binding.root.context) - alertDialogBuilder.setTitle("알림") - alertDialogBuilder.setMessage("${position + 1} 학기의 성적이 아직 입력되지 않았습니다.") - alertDialogBuilder.setPositiveButton("확인") { dialog, _ -> - dialog.dismiss() - } + if (dataList[position].averageGrade == "0.0") { + viewModel.onSetNullCheckGrade(true) } } } @@ -72,7 +68,6 @@ 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( @@ -83,9 +78,10 @@ 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 b016784..a1c2ce8 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 @@ -1,5 +1,6 @@ package umc.com.mobile.project.ui.gradInfo.viewmodel +import android.app.AlertDialog import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MediatorLiveData @@ -13,6 +14,7 @@ import umc.com.mobile.project.data.model.gradInfo.GradesResponse import umc.com.mobile.project.data.model.gradInfo.GradesTotalDto import umc.com.mobile.project.data.network.ApiClient import umc.com.mobile.project.data.network.api.GradInfoApi +import kotlin.coroutines.coroutineContext class GradeViewModel : ViewModel() { private val gradInfoApiService = ApiClient.createService() 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 469bdba..10e20ad 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 @@ -69,8 +69,7 @@ class LoginActivity : AppCompatActivity() { } private fun showLogoutDialog() { - var dialogBuilder = - AlertDialog.Builder(this, R.style.CustomAlertDialogTheme) + val dialogBuilder = AlertDialog.Builder(this, R.style.CustomAlertDialogTheme) val customView = layoutInflater.inflate(R.layout.custom_dialog_logout_home, null) dialogBuilder.setView(customView) diff --git a/app/src/main/res/drawable/custom_dialog_background_gray.xml b/app/src/main/res/drawable/custom_dialog_background_gray.xml new file mode 100644 index 0000000..b979c8a --- /dev/null +++ b/app/src/main/res/drawable/custom_dialog_background_gray.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/custom_dialog_grade.xml b/app/src/main/res/layout/custom_dialog_grade.xml new file mode 100644 index 0000000..dfb9f4e --- /dev/null +++ b/app/src/main/res/layout/custom_dialog_grade.xml @@ -0,0 +1,30 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_average_grade.xml b/app/src/main/res/layout/item_average_grade.xml index ab78d62..3014588 100644 --- a/app/src/main/res/layout/item_average_grade.xml +++ b/app/src/main/res/layout/item_average_grade.xml @@ -1,47 +1,57 @@ - + + + + + + + - - + android:layout_width="wrap_content" + android:layout_height="wrap_content"> - - + app:layout_constraintTop_toTopOf="parent"> + + - \ No newline at end of file + + + + +