ADDED CODE FOR Changing Text color from red to green if the result is normal

This commit is contained in:
Mariya
2023-12-26 12:59:44 +05:30
parent d1b5ca32bf
commit 0faf4adbd7
2 changed files with 10 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.MutableLiveData
@@ -604,6 +605,9 @@ class HemoCubeFragment : Fragment() {
if (calculatedRatio < 0.05)
return getString(R.string.error_repeat_test_higher_volume)
if (calculatedRatio in 0.05..0.155)
activity?.runOnUiThread {
binding.tvSubtitle4.setTextColor(ContextCompat.getColor(requireContext(), R.color.brightGreen))
}
return getString(R.string.normal)
if (calculatedRatio in 0.155..0.175)
return getString(R.string.negative_borderline)
@@ -631,6 +635,9 @@ class HemoCubeFragment : Fragment() {
hemoCubeViewModel.messages.postValue("result classification")
if (predictedDenovixRatio != null) {
if (predictedDenovixRatio in 0.0..0.16)
activity?.runOnUiThread {
binding.tvSubtitle4.setTextColor(ContextCompat.getColor(requireContext(), R.color.brightGreen))
}
return getString(R.string.normal)
if (predictedDenovixRatio in 0.16..0.165)
return getString(R.string.negative_borderline)

View File

@@ -9,6 +9,8 @@
<color name="white">#FFFFFFFF</color>
<color name="gray">#808080</color>
<color name="brightGreen">#00FF00</color>
<color name="red">#FF0000</color>
<color name="blue_app">#4daaff</color>
<color name="blue_app_dark">#005db3</color>
<color name="blue_app_light">#e5f3ff</color>
@@ -17,7 +19,7 @@
<color name="primary">#4daaff</color>
<color name="primary_dark">#005db3</color>
<color name="primary_light">#e5f3ff</color>
<color name="red">#FF0000</color>