Skip to content

Commit

Permalink
Merge branch '21-졸업-요건-ui' of https://github.com/FOR-GRAD/For-Grad-an…
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyuuum committed Feb 16, 2024
2 parents c3959f0 + 7a8480e commit e2bb947
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand All @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) :
Expand All @@ -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)
}
}
}
Expand Down Expand Up @@ -72,7 +68,6 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) :
fun setData(data: List<GradesTotalDto>) {
dataList.clear()
dataList.addAll(data)
// viewModel.onSetNullCheckGrade(true)
repeat(8 - dataList.size) {
dataList.add(
GradesTotalDto(
Expand All @@ -83,9 +78,10 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) :
"0"
)
)
viewModel.onSetNullCheckGrade(false)
}
notifyDataSetChanged()
}



}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<GradInfoApi>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/custom_dialog_background_gray.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="#78000000" />
</shape>
30 changes: 30 additions & 0 deletions app/src/main/res/layout/custom_dialog_grade.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@null">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_dialog_black_47"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/textView_message"
style="@style/SemiBoldFont.16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="21dp"
android:text="아직 이수되지 않은 학기 입니다."
android:textColor="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
90 changes: 50 additions & 40 deletions app/src/main/res/layout/item_average_grade.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="vm"
type="umc.com.mobile.project.ui.gradInfo.viewmodel.GradeViewModel" />

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:layout_marginTop="5dp"
android:background="@drawable/bg_stroke_gray_radius_16_5"
android:paddingStart="27dp"
android:paddingTop="20dp"
android:paddingEnd="27dp"
android:paddingBottom="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_semester_content1"
style="@style/MediumFont.13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1-1"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_average_grade_content1"
style="@style/BoldFont.20"
android:layout_width="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:text="0.0"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="9dp"
android:layout_marginTop="5dp"
android:background="@drawable/bg_stroke_gray_radius_16_5"
android:paddingStart="27dp"
android:paddingTop="20dp"
android:paddingEnd="27dp"
android:paddingBottom="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_semester_content1" />
</androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintTop_toTopOf="parent">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_semester_content1"
style="@style/MediumFont.13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1-1"
android:textColor="@{vm.isNullCheckGrade ? @color/gray : @color/black}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_average_grade_content1"
style="@style/BoldFont.20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:text="0.0"
android:textColor="@{vm.isNullCheckGrade ? @color/gray : @color/black}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_semester_content1" />
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

0 comments on commit e2bb947

Please sign in to comment.