Skip to content

Commit 05acce7

Browse files
committed
Replace usages of deprecated getColor() API
1 parent bd866e9 commit 05acce7

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

app/src/main/java/ai/elimu/content_provider/ui/letter_sound/LetterSoundsFragment.kt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import android.util.Log
1414
import android.view.LayoutInflater
1515
import android.view.View
1616
import android.view.ViewGroup
17+
import androidx.core.content.ContextCompat
1718
import androidx.fragment.app.Fragment
1819
import androidx.lifecycle.ViewModelProvider
1920
import com.google.android.material.snackbar.Snackbar
@@ -73,10 +74,13 @@ class LetterSoundsFragment : Fragment() {
7374
processResponseBody(letterSoundGsons)
7475
}
7576
} else {
76-
// Handle error
77-
Snackbar.make(binding.textLetterSounds, response.toString(), Snackbar.LENGTH_LONG)
78-
.setBackgroundTint(resources.getColor(R.color.deep_orange_darken_4))
79-
.show()
77+
context?.let { context ->
78+
// Handle error
79+
Snackbar.make(binding.textLetterSounds, response.toString(), Snackbar.LENGTH_LONG)
80+
.setBackgroundTint(ContextCompat.getColor(context, R.color.deep_orange_darken_4))
81+
.show()
82+
}
83+
8084
binding.progressBarLetterSounds.visibility = View.GONE
8185
}
8286
}
@@ -86,10 +90,13 @@ class LetterSoundsFragment : Fragment() {
8690

8791
Log.e(TAG, "t.getCause():", t.cause)
8892

89-
// Handle error
90-
Snackbar.make(binding.textLetterSounds, t.cause.toString(), Snackbar.LENGTH_LONG)
91-
.setBackgroundTint(resources.getColor(R.color.deep_orange_darken_4))
92-
.show()
93+
context?.let { context ->
94+
// Handle error
95+
Snackbar.make(binding.textLetterSounds, t.cause.toString(), Snackbar.LENGTH_LONG)
96+
.setBackgroundTint(ContextCompat.getColor(context, R.color.deep_orange_darken_4))
97+
.show()
98+
}
99+
93100
binding.progressBarLetterSounds.visibility = View.GONE
94101
}
95102
})

0 commit comments

Comments
 (0)