Skip to content

Instantly share code, notes, and snippets.

View cloudbank's full-sized avatar
🎯
Focusing

S.G. Vogel cloudbank

🎯
Focusing
View GitHub Profile
//1) inject a datasource and repository, which is passed to the constructor of the ViewModel
@Singleton
class LoginDataSource @Inject constructor(){
private var mAuth: FirebaseAuth. ...//
class LoginRepository @Inject constructor(val dataSource: LoginDataSource) { ...
//2) use the Executor overload from the DataSource:
var executor: ThreadPoolExecutor = ThreadPoolExecutor(
numCores * 2, numCores * 2,
private fun updateImageWithImageDecoder(assetFileName: String, imageView: ImageView) {
val context = requireContext()
viewLifecycleOwner.lifecycleScope.launch {
val d = withContext(Dispatchers.Default) {
val source = ImageDecoder.createSource(context.assets, assetFileName)
val drawable = ImageDecoder.decodeDrawable(source)
return@withContext drawable
}
withContext(Dispatchers.Main) {