Skip to content
Snippets Groups Projects
Unverified Commit 3a97d2aa authored by Mohamed Metwalli's avatar Mohamed Metwalli Committed by GitHub
Browse files

Fix Qr Code flickering (#3526)


Co-authored-by: default avatarI502720 <axel.herbstreith@sap.com>
Co-authored-by: default avatarBMItter <Berndus@gmx.de>
parent 3cb2d6d6
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,7 @@ class PersonCertificatesProvider @Inject constructor( ...@@ -56,7 +56,7 @@ class PersonCertificatesProvider @Inject constructor(
* After calling this [personCertificates] will emit new values. * After calling this [personCertificates] will emit new values.
* Setting it to null deletes it. * Setting it to null deletes it.
*/ */
suspend fun setCurrentCwaUser(personIdentifier: CertificatePersonIdentifier?) { fun setCurrentCwaUser(personIdentifier: CertificatePersonIdentifier?) {
Timber.d("setCurrentCwaUser(personIdentifier=%s)", personIdentifier) Timber.d("setCurrentCwaUser(personIdentifier=%s)", personIdentifier)
personCertificatesSettings.currentCwaUser.update { personIdentifier } personCertificatesSettings.currentCwaUser.update { personIdentifier }
} }
......
...@@ -55,9 +55,15 @@ class PersonDetailsViewModel @AssistedInject constructor( ...@@ -55,9 +55,15 @@ class PersonDetailsViewModel @AssistedInject constructor(
events.postValue(Back) events.postValue(Back)
} }
private val qrcodeCache = mutableMapOf<String, Bitmap?>()
private val qrCodeFlow: Flow<Bitmap?> = personCertificatesFlow.transform { private val qrCodeFlow: Flow<Bitmap?> = personCertificatesFlow.transform {
emit(null) val input = it.highestPriorityCertificate.qrCode
emit(qrCodeGenerator.createQrCode(it.highestPriorityCertificate.qrCode, margin = 0)) emit(qrcodeCache[input]) // Initial state
val qrcode = qrcodeCache[input] ?: qrCodeGenerator.createQrCode(input, margin = 0)
qrcodeCache[input] = qrcode
emit(qrcode)
} }
val uiState: LiveData<List<CertificateItem>> = combine( val uiState: LiveData<List<CertificateItem>> = combine(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment