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
//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, |
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
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) { |
OlderNewer