There's one more important thing left to show you in this chapter. We will show you some delayed execution in Android. We will give you some examples of delayed operation applied to our UI. Open your ItemsFragment and make these changes:
class ItemsFragment : BaseFragment() { ... override fun onResume() { super.onResume() ... val items = view?.findViewById<ListView>(R.id.items) items?.let { items.postDelayed({ if (!activity.isFinishing) { items.setBackgroundColor(R.color.grey_text_middle) } }, 3000) } } ... }
After three seconds, if we don't close this screen, the background color will be changed to a slightly darker grey tone. Run your application and see for yourself. Now, let's do the same thing in a different way: ...