Guest User

Untitled

a guest
Dec 12th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. private val loadFeature by lazy { Posts.init() }
  2. private fun injectFeature() = loadFeature
  3.  
  4. class PostListActivity : AppCompatActivity() {
  5.  
  6. private val vm: PostListViewModel by viewModel()
  7.  
  8. override fun onCreate(savedInstanceState: Bundle?) {
  9. super.onCreate(savedInstanceState)
  10. setContentView(R.layout.activity_post_list)
  11.  
  12. injectFeature()
  13.  
  14. if (savedInstanceState == null) {
  15. vm.get(refresh = false)
  16. }
  17.  
  18. vm.posts.observe(this, Observer { updatePosts(it) })
  19. swipeRefreshLayout.setOnRefreshListener { vm.get(refresh = true) }
  20. }
  21. }
Add Comment
Please, Sign In to add comment