Package 

Class AmbientAwareTimeKt

    • Method Summary

      Modifier and Type Method Description
      final static Unit AmbientAwareTime(AmbientState stateUpdate, Long updatePeriodMillis, Function2<ZonedDateTime, Boolean, Unit> block) An example of using AmbientAware: Provides the time, at the specified update frequency, whilst in interactive mode, or when ambient-generated updates occur (typically every 1 min).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • AmbientAwareTime

        @Composable() final static Unit AmbientAwareTime(AmbientState stateUpdate, Long updatePeriodMillis, Function2<ZonedDateTime, Boolean, Unit> block)

        An example of using AmbientAware: Provides the time, at the specified update frequency, whilst in interactive mode, or when ambient-generated updates occur (typically every 1 min).

        Example usage:

        AmbientAware { stateUpdate -> Box( contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize() ) { AmbientAwareTime(stateUpdate) { dateTime, isAmbient -> // Basic example of AmbientAwareTime usage val ambientFmt = remember { DateTimeFormatter.ofPattern("HH:mm") } val interactiveFmt = remember { DateTimeFormatter.ofPattern("HH:mm:ss") } val dateTimeStr = if (isAmbient) { ambientFmt.format(ZonedDateTime.now()) } else { interactiveFmt.format(ZonedDateTime.now()) } Text(dateTimeStr) } } }

        Parameters:
        stateUpdate - The state update from AmbientAware
        updatePeriodMillis - The update period, whilst in interactive mode
        block - The developer-supplied composable for rendering the date and time.