-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
460 additions
and
469 deletions.
There are no files selected for viewing
30 changes: 8 additions & 22 deletions
30
app/src/main/java/umc/com/mobile/project/data/model/gradInfo/CompletionResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,32 @@ | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class CompletionResponse( | ||
@SerializedName("isSuccess") | ||
val isSuccess: Boolean, | ||
@SerializedName("code") | ||
val code: String, | ||
@SerializedName("message") | ||
val message: String, | ||
@SerializedName("result") | ||
val result: Result | ||
) | ||
|
||
data class Result( | ||
@SerializedName("titleList") | ||
val titleList: TitleList, | ||
val titleList: List<String>, | ||
@SerializedName("completionDtoMap") | ||
val completionDtoMap: List<Map<String, List<String>>>, | ||
@SerializedName("majorRequirements") | ||
val majorRequirements: MajorRequirements | ||
val completionDtoMap: List<Map<String, List<String>>> | ||
) | ||
|
||
data class TitleList( | ||
@SerializedName("titleList") | ||
val titles: List<String> | ||
) | ||
|
||
data class CompletionDto( | ||
data class CompletionDtoMap( | ||
@SerializedName("필수교양(기초)") | ||
val requiredBasic: List<String>, | ||
val requiredBasicCourses: List<String>, | ||
@SerializedName("필수교양(소양)") | ||
val requiredCultural: List<String>, | ||
val requiredGeneralCourses: List<String>, | ||
@SerializedName("선택필수교양") | ||
val optionalRequired: List<String>, | ||
val electiveRequiredCourses: List<String>, | ||
@SerializedName("소 계") | ||
val optionalRequiredSubtotal: List<String> | ||
) | ||
|
||
data class MajorRequirements( | ||
val subtotal: List<String>, | ||
@SerializedName("제1트랙") | ||
val track1: List<String>, | ||
@SerializedName("제2트랙") | ||
val track2: List<String>, | ||
@SerializedName("부전공 부전공 - micro college") | ||
val minorMicroCollege: List<String> | ||
val minor: List<String> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
app/src/main/java/umc/com/mobile/project/ui/gradInfo/adapter/AverageRVAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package umc.com.mobile.project.ui.gradInfo.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.databinding.ItemAverageGradeBinding | ||
import umc.com.mobile.project.ui.gradInfo.viewmodel.GradeViewModel | ||
|
||
class AverageRVAdapter(private val viewModel: GradeViewModel) : | ||
RecyclerView.Adapter<AverageRVAdapter.MyViewHolder>() { | ||
private var dataList = mutableListOf<GradesTotalDto>() | ||
|
||
inner class MyViewHolder(private val binding: ItemAverageGradeBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
init { | ||
binding.root.setOnClickListener { | ||
val position = adapterPosition | ||
if (position != RecyclerView.NO_POSITION) { | ||
val semester = "${position + 1} 학기" | ||
val semesterGrade = "${position + 1} 학기 성적" | ||
viewModel.onSemesterItemClick(semester) | ||
viewModel.onSemesterGradeItemClick(semesterGrade) | ||
} | ||
} | ||
} | ||
|
||
fun bind(gradesTotalDto: GradesTotalDto, position: Int) { | ||
val count = if (position % 2 == 0) { | ||
1 | ||
} else { | ||
2 | ||
} | ||
val semester = if (position % 2 == 0) position / 2 + 1 else (position + 1) / 2 | ||
|
||
binding.tvSemesterContent1.text = "$semester - $count" | ||
binding.tvAverageGradeContent1.text = gradesTotalDto.averageGrade | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { | ||
val binding = ItemAverageGradeBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
) | ||
return MyViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: MyViewHolder, position: Int) { | ||
holder.bind(dataList[position], position) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return dataList.size | ||
} | ||
|
||
fun setData(data: List<GradesTotalDto>) { | ||
dataList.clear() | ||
dataList.addAll(data) | ||
repeat(8 - dataList.size) { | ||
dataList.add( | ||
GradesTotalDto( | ||
"0", | ||
"0", | ||
"0.0", | ||
"0.0", | ||
"0" | ||
) | ||
) | ||
} | ||
notifyDataSetChanged() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.