Created
April 28, 2023 12:08
-
-
Save nisaefendioglu/6af79dab27b3abd05fa6f29e4349f0ac to your computer and use it in GitHub Desktop.
This file contains 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
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