feat: [detection & history] add empty history indicator on latest detection and history screen

This commit is contained in:
Wisnu Andika
2025-04-23 20:54:43 +07:00
parent 074d6866bb
commit 5ef19299cb
5 changed files with 34 additions and 4 deletions

View File

@ -4,10 +4,10 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-07-20T06:36:39.946968600Z">
<DropdownSelection timestamp="2025-04-23T13:38:33.325921500Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\rizky\.android\avd\Pixel_7_API_33.avd" />
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\wisnu\.android\avd\Pixel_7_Pro_API_34.avd" />
</handle>
</Target>
</DropdownSelection>

View File

@ -53,7 +53,7 @@ class DetectionFragment : Fragment(R.layout.fragment_detection) {
navigateToDiagnoseDetail(data)
}
fun onDeleteClicked(data: HistoryDiagnose) {
override fun onDeleteClicked(data: HistoryDiagnose) {
AlertDialog.Builder(requireContext())
.setTitle("Hapus Riwayat")
.setMessage("Apakah kamu yakin ingin menghapus riwayat ini?")
@ -80,6 +80,15 @@ class DetectionFragment : Fragment(R.layout.fragment_detection) {
viewModel.detectionList.collect { historyDiagnoses ->
Log.d("DetectionFragment", "Observing detection list. Count: ${historyDiagnoses.size}")
detectionAdapter.submitList(historyDiagnoses)
if (historyDiagnoses.isEmpty()) {
binding.textViewEmptyHistory.visibility = View.VISIBLE
binding.rvResultDetection.visibility = View.GONE
} else {
binding.textViewEmptyHistory.visibility = View.GONE
binding.rvResultDetection.visibility = View.VISIBLE
detectionAdapter.submitList(historyDiagnoses)
}
}
}
}

View File

@ -314,6 +314,7 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
val confidenceFloat = historyDiagnose.confidence.toFloatOrNull() ?: 0f
binding.confidenceResultDiagnosis.text = "Confidence: %.1f%%".format(confidenceFloat)
binding.cdHomeScreenAnalyze.visibility = View.VISIBLE
binding.tvHsHistoryEmpty.visibility = View.GONE
}

View File

@ -48,6 +48,15 @@
android:paddingTop="@dimen/margin_component"
app:layout_constraintTop_toBottomOf="@id/dd_cont_title">
<TextView
android:id="@+id/textViewEmptyHistory"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Belum Ada Riwayat"
android:textColor="@color/grayFont"
android:layout_gravity="center"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_result_detection"
android:layout_width="match_parent"

View File

@ -421,6 +421,17 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<TextView
android:id="@+id/tv_hs_history_empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_component"
android:text="Belum Ada Riwayat Deteksi Terbaru"
android:textColor="@color/grayFont"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cv_hs_history_title" />
<ProgressBar
android:id="@+id/progress_result"
android:layout_width="wrap_content"