@@ -14,6 +14,7 @@ import android.util.Log
1414import android.view.LayoutInflater
1515import android.view.View
1616import android.view.ViewGroup
17+ import androidx.core.content.ContextCompat
1718import androidx.fragment.app.Fragment
1819import androidx.lifecycle.ViewModelProvider
1920import 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