-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve TokenBundleRepositoryImpl to check if API is available #1089
Improve TokenBundleRepositoryImpl to check if API is available #1089
Conversation
c57ca48
to
c002461
Compare
@@ -75,7 +84,16 @@ class MainActivity : ComponentActivity() { | |||
modifier = Modifier.fillMaxSize(), | |||
color = MaterialTheme.colorScheme.background | |||
) { | |||
val coroutineScope = rememberCoroutineScope() | |||
var apiAvailable by remember { mutableStateOf(false) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's safe to do the operations, then I think defaulting to true. Or making this true/false/null would be better here. Avoid glitching the screen in the hopefully typical case where it is available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it makes sense, and it would be better to have this in a VM, and have proper states
this sample app is very simple, in comparison to the wear counterpart, it's in my plans to improve it further and will address it together
override suspend fun isAvailable(): Boolean { | ||
return try { | ||
GoogleApiAvailability.getInstance() | ||
.checkApiAvailability(registry.dataClient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure you like the God object of the registry, but if we push this up there, then it can be done once, at startup meaning it's immediately available so screen can draw correctly immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be ideal to have these checks in WearDataLayerRegistry, not sure about having it immediately available, it would be an assumption about the time taken by play service lib to check it
raised #1091
WHAT
Improve
TokenBundleRepositoryImpl
to check if DataClient API is available.WHY
In order to handle the following exception when device doesn't have the API available:
HOW
DataStore
inTokenBundleRepositoryImpl
untilupdate
function is called;update
to check for api availability and fail silently when not available;isAvailable
function toTokenBundleRepository
so developers can check if the repository can be used on the device running;Checklist 馃搵