diff --git a/app/build.gradle b/app/build.gradle index c1a0894cf..6ec0a6180 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -159,7 +159,7 @@ ext { } dependencies { - implementation "io.github.wulkanowy:sdk:07a21c1" + implementation "io.github.wulkanowy:sdk:bb08354" coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoAdapter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoAdapter.kt index 602ec07ad..2d8387491 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoAdapter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoAdapter.kt @@ -1,6 +1,8 @@ package io.github.wulkanowy.ui.modules.studentinfo import android.view.LayoutInflater +import android.view.View.GONE +import android.view.View.VISIBLE import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import io.github.wulkanowy.databinding.ItemStudentInfoBinding @@ -9,7 +11,7 @@ import javax.inject.Inject class StudentInfoAdapter @Inject constructor() : RecyclerView.Adapter() { - var items = listOf>() + var items = listOf() var onItemClickListener: (position: Int) -> Unit = {} @@ -25,8 +27,9 @@ class StudentInfoAdapter @Inject constructor() : val item = items[position] with(holder.binding) { - studentInfoItemTitle.text = item.first - studentInfoItemSubtitle.text = item.second + studentInfoItemTitle.text = item.title + studentInfoItemSubtitle.text = item.subtitle + studentInfoItemArrow.visibility = if (item.showArrow) VISIBLE else GONE with(root) { setOnClickListener { onItemClickListener(position) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoFragment.kt index 47a649909..e9ef41372 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoFragment.kt @@ -107,7 +107,7 @@ class StudentInfoFragment : } } - override fun updateData(data: List>) { + override fun updateData(data: List) { with(studentInfoAdapter) { items = data notifyDataSetChanged() @@ -129,7 +129,11 @@ class StudentInfoFragment : getString(R.string.student_info_family_name) to studentInfo.familyName, getString(R.string.student_info_parents_name) to studentInfo.parentsNames ).map { - if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it + StudentInfoItem( + it.first, + it.second.ifBlank { getString(R.string.all_no_data) }, + false, + ) } ) } @@ -141,7 +145,11 @@ class StudentInfoFragment : getString(R.string.student_info_cellphone) to studentInfo.cellPhoneNumber, getString(R.string.student_info_email) to studentInfo.email ).map { - if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it + StudentInfoItem( + it.first, + it.second.ifBlank { getString(R.string.all_no_data) }, + false, + ) } ) } @@ -153,10 +161,11 @@ class StudentInfoFragment : studentInfo.firstGuardian?.let { it.kinship.capitalise() to it.fullName }, studentInfo.secondGuardian?.let { it.kinship.capitalise() to it.fullName }, ).map { (title, value) -> - val updatedValue = value.ifBlank { getString(R.string.all_no_data) } - val updatedTitle = title.ifBlank { getString(R.string.all_no_data) } - - updatedTitle to updatedValue + StudentInfoItem( + title.ifBlank { getString(R.string.all_no_data) }, + value.ifBlank { getString(R.string.all_no_data) }, + true, + ) } ) } @@ -168,7 +177,11 @@ class StudentInfoFragment : getString(R.string.student_info_registered_address) to studentInfo.registeredAddress, getString(R.string.student_info_correspondence_address) to studentInfo.correspondenceAddress ).map { - if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it + StudentInfoItem( + it.first, + it.second.ifBlank { getString(R.string.all_no_data) }, + false, + ) } ) } @@ -182,7 +195,11 @@ class StudentInfoFragment : getString(R.string.student_info_phones) to studentGuardian.phones, getString(R.string.student_info_email) to studentGuardian.email ).map { - if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it + StudentInfoItem( + it.first, + it.second.ifBlank { getString(R.string.all_no_data) }, + false, + ) } ) } @@ -196,7 +213,11 @@ class StudentInfoFragment : getString(R.string.student_info_phones) to studentGuardian.phones, getString(R.string.student_info_email) to studentGuardian.email ).map { - if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it + StudentInfoItem( + it.first, + it.second.ifBlank { getString(R.string.all_no_data) }, + false, + ) } ) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoItem.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoItem.kt new file mode 100644 index 000000000..bb149b2b1 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoItem.kt @@ -0,0 +1,7 @@ +package io.github.wulkanowy.ui.modules.studentinfo + +data class StudentInfoItem( + val title: String, + val subtitle: String, + val showArrow: Boolean +) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoPresenter.kt index d5f84dc21..55ac66d0b 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoPresenter.kt @@ -61,11 +61,11 @@ class StudentInfoPresenter @Inject constructor( fun onItemSelected(position: Int) { if (infoType != StudentInfoView.Type.FAMILY) return - if (position == 0) { - view?.openStudentInfoView(StudentInfoView.Type.FIRST_GUARDIAN, studentWithSemesters) - } else { - view?.openStudentInfoView(StudentInfoView.Type.SECOND_GUARDIAN, studentWithSemesters) - } + view?.openStudentInfoView( + if (position == 0) StudentInfoView.Type.FIRST_GUARDIAN + else StudentInfoView.Type.SECOND_GUARDIAN, + studentWithSemesters + ) } fun onItemLongClick(text: String) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoView.kt index 2f0c6753a..87613e626 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/studentinfo/StudentInfoView.kt @@ -15,7 +15,7 @@ interface StudentInfoView : BaseView { fun initView() - fun updateData(data: List>) + fun updateData(data: List) fun showPersonalTypeData(studentInfo: StudentInfo) diff --git a/app/src/main/res/layout/fragment_student_info.xml b/app/src/main/res/layout/fragment_student_info.xml index 5970e2fc4..d270da4a0 100644 --- a/app/src/main/res/layout/fragment_student_info.xml +++ b/app/src/main/res/layout/fragment_student_info.xml @@ -24,7 +24,8 @@ + android:layout_height="match_parent" + tools:listitem="@layout/item_student_info" /> + +