@@ -13,6 +13,7 @@ import android.util.Log
1313import android.view.LayoutInflater
1414import android.view.View
1515import android.view.ViewGroup
16+ import androidx.core.content.ContextCompat
1617import androidx.fragment.app.Fragment
1718import androidx.lifecycle.Observer
1819import androidx.lifecycle.ViewModelProvider
@@ -71,10 +72,12 @@ class EmojisFragment : Fragment() {
7172 processResponseBody(emojiGsons)
7273 }
7374 } else {
74- // Handle error
75- Snackbar .make(binding.textEmojis, response.toString(), Snackbar .LENGTH_LONG )
76- .setBackgroundTint(resources.getColor(R .color.deep_orange_darken_4))
77- .show()
75+ context?.let { context ->
76+ // Handle error
77+ Snackbar .make(binding.textEmojis, response.toString(), Snackbar .LENGTH_LONG )
78+ .setBackgroundTint(ContextCompat .getColor(context, R .color.deep_orange_darken_4))
79+ .show()
80+ }
7881 binding.progressBarEmojis.visibility = View .GONE
7982 }
8083 }
@@ -84,10 +87,12 @@ class EmojisFragment : Fragment() {
8487
8588 Log .e(javaClass.name, " t.getCause():" , t.cause)
8689
87- // Handle error
88- Snackbar .make(binding.textEmojis, t.cause.toString(), Snackbar .LENGTH_LONG )
89- .setBackgroundTint(resources.getColor(R .color.deep_orange_darken_4))
90- .show()
90+ context?.let { context ->
91+ // Handle error
92+ Snackbar .make(binding.textEmojis, t.cause.toString(), Snackbar .LENGTH_LONG )
93+ .setBackgroundTint(ContextCompat .getColor(context, R .color.deep_orange_darken_4))
94+ .show()
95+ }
9196 binding.progressBarEmojis.visibility = View .GONE
9297 }
9398 })
0 commit comments