Colton Idle
12/04/2020, 5:12 AMcodeslubber
12/04/2020, 6:07 AMSam
12/04/2020, 8:39 AMbuild.gradle
which gets new deployments properly launched on the device:
def buildCode = (int)(((new Date().getTime()/1000) - 1451606400) / 10)
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
...
versionName "0.1.${buildCode}"
...
}
}
I am not sure if this has to do with apple silicon, arctic fox, or alpha08?Rafs
12/04/2020, 9:48 AMpadding
modifier only seems to add marginKshitij Patil
12/04/2020, 10:15 AMOutilnedTextField
with savedInstanceState (<textfield-saver>) { TextFieldValue(state.text) }
Putting app in background an reopening fixes this issue. I'm not sure if I'm doing any wrong or there's a subtle issue in composeRafs
12/04/2020, 12:18 PMFloatingActionButton
Rafs
12/04/2020, 1:21 PMExtendedFloatingActionButton
into a FloatingActionButton
?Kshitij Patil
12/04/2020, 3:24 PMcollectAsState()
in it? Do I get a snapshot of snapshot of state and won't receive any further updates or will do?
I've a navigation graph definition using navigation-compose and am using different viewModel for each of its screens. I'm doing collectAsState
in the content parameter of NavGraphBuilder.comoposable()
extension function. I want the respective Composable in the navgraph to be notified on any state changes in its associated viewModel. I checked every step in the process of mutating the state and viewModel state is working properly but the Composable is not listening to these changes and thus not being updated.
How should this be achieved in general? Individual Composables listening to their own ViewModels when they're part of some navigation hierarchy like BottomNavigation ?Kshitij Patil
12/04/2020, 5:14 PMComposeNavigator
which is supposed to handle backstack and create destination. Where can I find the example usage of it?Manuel Lorenzo
12/04/2020, 5:49 PMandroid {
buildFeatures {
compose = true
}
compileOptions {
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
}
composeOptions {
composeOptions.kotlinCompilerVersion = versionsProperties["version.kotlin"].toString()
kotlinCompilerExtensionVersion = versionsProperties["version.androidx.ui"].toString()
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check")
useIR = true
}
}
However, I’m still getting the following error message for several classes:
Class 'androidx.compose.ui.Modifier' is compiled by a new Kotlin compiler backend and cannot be loaded by the old compiler
Nat Strangerweather
12/04/2020, 6:26 PMSrSouza
12/04/2020, 6:44 PMBradleycorn
12/04/2020, 7:16 PMremember()
but that launches its calculation
in a coroutine scoped to the composable? Something like:
val myVal by remember(viewModel) {
viewModel.someSuspendingMethod()
}
My use case is that I have a suspend
method in a ViewModel who’s return value I need to remember
. Sure I could make the ViewModel method a “normal” method and use viewModelScope
to launch a coroutine, but that is going to be scoped to the ViewModel, which itself is scoped to the Activity. I want it to be scoped to the composable (so that if the composable is removed from the tree, the coroutine is canceled).
I guess I could use produceState
for this? Is that the best way?
val myVal by produceState(initialValue = "Loading...", subject = viewModel) {
value = viewModel.someSuspendingMethod()
}
Bradleycorn
12/04/2020, 7:34 PMTextView("Some Text", modifier = …)
instead of Text("Some Text", modifier = …)
… man I’d be 💰Grigoriev Dmitriy
12/04/2020, 10:42 PMVsevolod Ganin
12/05/2020, 1:37 AMCrossfade
and I want it not animate anything on initial compositionColton Idle
12/05/2020, 8:39 AMLazyColumn {
item {
Text("MAIN HEADER")
}
items(mylist.sections) { section: MyClass.Section ->
Text(section.title)
section.subsections.forEach {
Text(it.body)
}
}
}
this does not work, but it's what I expected I should do
LazyColumn {
item {
Text("MAIN HEADER")
}
items(mylist.sections) { section: MyClass.Section ->
Text(section.title)
item(sec.subsections) {
Text(it.body)
}
}
}
Nat Strangerweather
12/05/2020, 11:21 AMKshitij Patil
12/05/2020, 1:20 PMexoplayer
with compose and for some reason the video is not getting shown. The audio starts playing as soon as the composable is rendered but video is not working. I've tried the latest version and 2.11.7
version of exoplayer and I'm currently using compose alpha07
val context = ContextAmbient.current
val exoPlayer = remember(mediaUri) {
SimpleExoPlayer.Builder(context)
.build()
.apply {
val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(
context,
Util.getUserAgent(context, context.packageName)
)
val source = HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(mediaUri.toUri())
this.prepare(source)
}
}
Box(
modifier = Modifier.preferredSize(244.dp)
.padding(vertical = 24.dp, horizontal = 8.dp)
.clip(RoundedCornerShape(12.dp)),
) {
AndroidView(
viewBlock = { context ->
PlayerView(context).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
useController = false
resizeMode = RESIZE_MODE_ZOOM
player = exoPlayer
exoPlayer.playWhenReady = true
}
},
modifier = Modifier.fillMaxSize()
)
}
onDispose {
exoPlayer.stop()
exoPlayer.release()
}
Here is my implementation snippet, any help would be appreciated.
Thanks!Daniele B
12/05/2020, 1:56 PMBradleycorn
12/05/2020, 3:33 PM@Composable
fun FancyText(text: String) {
val formattedText = remember(text) { computeTextFormatting(text) }
Text(formattedText)
}
Is the use of remember
necessary/valuable here? Seems like the only time this would get recomposed is if text
changes, and in that case we’d want to re-compute the formattedText
value. In other words, we’ll always re-compute the formattedText
value, so do we even need remember
?Jeisson Sáchica
12/05/2020, 5:21 PMDoris Liu
12/05/2020, 10:37 PMTransition
, would you prefer to seek by: 1️⃣ percentage based progress (0-1f), or 2️⃣ playtime (between 0 and total duration)?zsperske
12/06/2020, 3:26 AMThis version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 4.3 or newer.
Jorge Rodríguez
12/06/2020, 4:22 AMe: java.lang.IncompatibleClassChangeError: Found interface org.jetbrains.kotlin.ir.declarations.IrClass, but class was expected
at androidx.compose.compiler.plugins.kotlin.VersionChecker.check(VersionChecker.kt:65)
at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:49)
at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade$doGenerateFiles$1.invoke(JvmBackendFacade.kt:72)
at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade$doGenerateFiles$1.invoke(JvmBackendFacade.kt:34)
at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:98)
at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFiles(JvmBackendFacade.kt:87)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:40)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:616)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:203)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:51)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:86)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:346)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:102)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:240)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:39)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:81)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:93)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:601)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:93)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1633)
at jdk.internal.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
e: java.lang.IncompatibleClassChangeError: Found interface org.jetbrains.kotlin.ir.declarations.IrClass, but class was expected
Execution failed for task ':app:compileDebugKotlin'.
> Internal compiler error. See log for more details
Rafs
12/06/2020, 9:18 AMDavide Giuseppe Farella
12/06/2020, 10:23 AMColton Idle
12/06/2020, 10:49 AMkotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
viewBinding true
}
composeOptions {
kotlinCompilerVersion '1.4.20'
kotlinCompilerExtensionVersion '1.0.0-alpha08'
}
...
implementation "androidx.compose.runtime:runtime:1.0.0-alpha08"
3. Everything works fine
4. Add implementation "androidx.compose.ui:ui:1.0.0-alpha08"
5. Every fragment in my app now has a red line on the class name (but still seems to build fine). Hovering over the error says "Class 'MyFragment' is not abstract and does not implement abstract base class member public abstract fun <I : Any!, O : Any!> prepareCall"
Ideas?darkmoon_uk
12/06/2020, 10:58 AMViewModelProvider.Factory
with a lambda that constructs ViewModels with parameters, there is no way to assign this as the default factory. This entails that you either have to pass the factory around your composable functions to use it e.g. by viewModels(myFactory)
or actually override the getDefaultViewModelFactory
method. This is convenient enough in an Activity
but becomes more troublesome if you try to do it for a NavHost
.
In other words the API design is coercing us toward using Dependency Injection frameworks in our ViewModels, rather than just plain construction. Whether you favour DI frameworks or not; construction parameters are objectively the primary mechanism in the Kotlin language for providing dependencies to an object: this at least implies that construction parameters should remain the first and best supported mechanism, followed by others.
Am I missing something here or is there a case for Google to make these API's more flexible?Oussama Haff.
12/06/2020, 4:40 PMLazyColumnFor
don’t have the same rendering of the shadow despite of having a fixed elevation of 4.dp
on each material Card
item. Am I missing something ?
In the screenshots bellow I compare between the shadow of the first and the last elements in the list
link to sources : https://github.com/hfrsoussama/android-conferences/blob/a8b3725f1f8ad6f995d04bc554[…]rc/main/java/dev/lesam/androidconferences/HomeScreenActivity.ktOussama Haff.
12/06/2020, 4:40 PMLazyColumnFor
don’t have the same rendering of the shadow despite of having a fixed elevation of 4.dp
on each material Card
item. Am I missing something ?
In the screenshots bellow I compare between the shadow of the first and the last elements in the list
link to sources : https://github.com/hfrsoussama/android-conferences/blob/a8b3725f1f8ad6f995d04bc554[…]rc/main/java/dev/lesam/androidconferences/HomeScreenActivity.ktSergey Y.
12/06/2020, 6:45 PMOussama Haff.
12/06/2020, 6:54 PM