Created
October 14, 2018 12:09
-
-
Save marcelpinto/054bcd641bcbab34c04645dd944abae8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
homeRecycler.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) | |
homeRecycler.adapter = adapter | |
homeViewModel.homePage.observe(this, Observer { resource -> | |
resource?.apply { | |
when (resource.status) { | |
SUCCESS -> { | |
adapter.isLoading = false | |
adapter.homePage = resource.data!! | |
adapter.notifyDataSetChanged() | |
} | |
ERROR -> { | |
Toast.makeText(activity, resource.message.orEmpty(), Toast.LENGTH_SHORT).show() | |
adapter.isLoading = false | |
} | |
LOADING -> { | |
adapter.isLoading = true | |
} | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment