Last active
October 24, 2024 23:09
-
-
Save kartikarora/386333dba62ce58bc2d232df5c958d7f to your computer and use it in GitHub Desktop.
Activity 8 Step 2
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
... | |
val geminiInterface = GeminiInterface() | |
val scope = CoroutineScope(Dispatchers.IO) | |
val generatedQuote = scope.async(Dispatchers.IO) { | |
geminiInterface.getSingleQuote(currentTopicName) | |
} | |
updateAppWidgetState(context, glanceId) { prefs -> | |
val quote = sampleData.firstOrNull { | |
it.name == currentTopicName | |
}?.quotes?.random() ?: generatedQuote.await() | |
prefs[QuoteWidget.KEY_QUOTE] = quote?.text ?: "Quote not found" | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment