Skip to content

Instantly share code, notes, and snippets.

@nisaefendioglu
Created April 28, 2023 12:08
Show Gist options
  • Save nisaefendioglu/6af79dab27b3abd05fa6f29e4349f0ac to your computer and use it in GitHub Desktop.
Save nisaefendioglu/6af79dab27b3abd05fa6f29e4349f0ac to your computer and use it in GitHub Desktop.
class MyPagingActivity : AppCompatActivity() {
private val viewModel: MyViewModel by viewModels()
private lateinit var adapter: MyPagingDataAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityMyPagingBinding.inflate(layoutInflater)
setContentView(binding.root)
adapter = MyPagingDataAdapter()
binding.recyclerView.adapter = adapter
lifecycleScope.launch {
viewModel.dataStream.collectLatest { data ->
adapter.submitData(data)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment