Marcin Środa
09/08/2020, 12:49 PMonActive
/ onCommit
/ onDispose
, but what about something similar to onPause
/ onResume
? I’m looking for something that will tell me that the activity has gone background / foreground.JulianK
09/08/2020, 12:55 PMNamig Tahmazli
09/08/2020, 3:01 PM* [key] is a utility composable that is used to "group" or "key" a block of execution inside of a
* composition. This is sometimes needed for correctness inside of control-flow that may cause a
* given composable invocation to execute more than once during composition.
*
* The value for a key *does not need to be globally unique*, and needs only be unique amongst the
* invocations of [key] *at that point* in composition.
*
* For instance, consider the following example:
*
* @sample androidx.compose.runtime.samples.locallyUniqueKeys
Here I do not know how I can check locallyUniqueKeys
to understand the given sample better.
Do you know where I can find them?Julius Marozas
09/08/2020, 8:14 PMvalue
on some State<T>
"S", then the Compose runtime automatically recomposes X when S changes. Potentially bypassing recomposing any composables that just forward S to X without calling value
.
In my app, I have a "container composables" that are responsible for observing streams from a view model and passing the observed values to children composables. In one of the containers I have StateFlow<List<T>>.collectAsState()
and I pass State<List<T>>
to children of the container. What should I do, if I want to pass a boolean indicating whether List<T>
is empty? Can I somehow create a new State<Boolean>
?
And in general, should I always prefer to pass State<T>
to composables instead of just T
?Sergey Y.
09/08/2020, 9:03 PMJD
09/09/2020, 2:52 AMJD
09/09/2020, 3:43 AMonImeActionPerformed = { action, softKeyboardController ->
if (action == ImeAction.Done) {
onImeAction()
softKeyboardController?.hideSoftwareKeyboard()
}
},
Handling on the submit callback:
val submit = {
onItemComplete(TodoItem(text))
setIcon(TodoIcon.Default)
setText("")
}
Video:Mehmet Peker
09/09/2020, 7:14 AMMBegemot
09/09/2020, 9:21 AMMBegemot
09/09/2020, 9:34 AMRow(Modifier.padding(5.dp)) {
Text("Selected")
//Switch(checked = lselected, onCheckedChange = { lselected = !lselected} )
Checkbox(checked = lselected, onCheckedChange = { lselected = !lselected} )
Text("Unselected")
}
MBegemot
09/09/2020, 9:45 AMvar lselected by mutableStateOf(true)
But again if it's a checkbox it's fine ...You can see the issue by clicking on settings languages +languagesvipulasri
09/09/2020, 11:19 AMBounceInterpolator
in jetpack compose?Yann Badoual
09/09/2020, 3:07 PMvar animationIndex by remember { mutableStateOf(0) }
val definition = remember(animationIndex) { buildTransition(animationIndex = animationIndex) }
val state = transition(
definition = definition,
initState = AnimationState.START,
toState = AnimationState.END,
onStateChangeFinished = {
if (animationIndex < animationCount) {
animationIndex++
}
}
)
This works, but feels weird, and has some drawbacks:
• Doesn't work well with @Preview animation inspector
• animationIndex
can't be used in the code depending on the animation, because when one animation is completed, there's a brief moment where animationIndex
was incremented but state
is still on the AnimationState.END
because the next one didn't start. So I have to add the index as a key inside the state to fix this. It works fine, but error proneAsh
09/09/2020, 3:30 PMRobert Menke
09/09/2020, 4:05 PMviewModel
that will provide a properly scoped view model.
This looks great, but my concern is that for testing purposes if I want to create a fake for a service that makes a network call and then inject it into my view model I still need something like Hilt. Is there a recommended best practice or tutorial for dependency injection with compose?Nick
09/09/2020, 5:10 PMAndroidView
Composable, but I can't seem to get it working. Has anyone else had luck embedding an old-style view on the alpha-02
build? It doesn't necessarily need to be Google Sign-in, it could be any other view. I've watched the alpha video where they embed the Google Maps view but that did not help me!Arkadii Ivanov
09/09/2020, 5:17 PM@Composable inline
function from another @Composable
function. E.g. I can't call Column {}
. There is a compilation error.Ali Zargar Shabestari
09/09/2020, 5:47 PMPreferenceFragmentCompat
without rewriting the logic it provides for free.Jan Skrasek
09/09/2020, 6:56 PMColton Idle
09/09/2020, 7:10 PMDaniele B
09/09/2020, 7:19 PMScrollView
.
How do you do that in Compose?Mohamed Elfiky
09/09/2020, 8:19 PMJoaquim
09/09/2020, 8:31 PMLazyColumn
start at a given position / offset to maintain scroll position across compositions? (like when navigating back to a list from a detail view)Konyaco
09/10/2020, 1:45 AMjava.lang.IllegalStateException: KeyEvent can't be processed because this key input node is not active.
when I press any key (including backpress, hardware keyboard keys). Do you have the same problem? How can I fix it? 🤔thanksBrett Best
09/10/2020, 3:36 AMColton Idle
09/10/2020, 5:52 AMbuildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion MyVersions.compose_version //this id defined as val compose_version = "1.0.0-alpha02"
kotlinCompilerVersion '1.4.0'
}
I get an error when my app runs due to moshi/kotlin reflection?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.free, PID: 8768
kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Could not compute caller for function: public constructor MyNetworkResponse(myFields...) defined in com.myapp.free.MyNetworkResponse[DeserializedClassConstructorDescriptor@aa293b] (member = null)
at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:89)
at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:36)
at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:62)
at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
at kotlin.reflect.jvm.internal.KFunctionImpl.getCaller(Unknown Source:7)
at kotlin.reflect.jvm.ReflectJvmMapping.getJavaMethod(ReflectJvmMapping.kt:63)
at kotlin.reflect.jvm.KCallablesJvm.setAccessible(KCallablesJvm.kt:82)
at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory.create(KotlinJsonAdapter.kt:223)
at com.squareup.moshi.Moshi.nextAdapter(Moshi.java:172)
Has anyone come across this? I've looked in issuetracker to no avail.Henning B
09/10/2020, 7:13 AMMehdi Haghgoo
09/10/2020, 8:26 AMAdam Bennett
09/10/2020, 9:09 AMjava.lang.NoSuchMethodError: No static method MdcTheme(Landroid/content/Context;ZZZZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Lcom/google/android/material/composethemeadapter/MdcTheme; or its super classes (declaration of 'com.google.android.material.composethemeadapter.MdcTheme' appears in /data/app/co.cuvva.design.app-LxFTTKv0lEIaA4yoLB_eJw==/base.apk)
at co.cuvva.design.app.common.CategoriesActivityKt.DesignAppTheme(CategoriesActivity.kt:59)
at co.cuvva.design.app.common.CategoriesActivityKt.access$DesignAppTheme(Unknown Source:0)
at co.cuvva.design.app.common.CategoriesActivity$onCreate$1.invoke(CategoriesActivity.kt:42)
at co.cuvva.design.app.common.CategoriesActivity$onCreate$1.invoke(Unknown Source:10)
at androidx.compose.runtime.internal.ComposableLambda.invoke(ComposableLambda.kt:142)
at androidx.compose.runtime.internal.ComposableLambda.invoke(Unknown Source:10)
at androidx.compose.ui.selection.SelectionContainerKt$SelectionContainer$3$1.invoke(SelectionContainer.kt:88)
at androidx.compose.ui.selection.SelectionContainerKt$SelectionContainer$3$1.invoke(Unknown Source:10)
at androidx.compose.runtime.internal.ComposableLambda.invoke(ComposableLambda.kt:142)
at androidx.compose.runtime.internal.ComposableLambda.invoke(Unknown Source:10)
Mehmet Peker
09/10/2020, 10:11 AMMehmet Peker
09/10/2020, 10:11 AMTimo Drick
09/10/2020, 10:17 AMMehmet Peker
09/10/2020, 10:39 AMTimo Drick
09/10/2020, 10:45 AMval activity = ContextAmbient.current as Activity
Mehmet Peker
09/10/2020, 11:01 AMoverride fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val binding = FragmentMessageBinding.inflate(LayoutInflater.from(requireContext()), container, false)
(binding.root as ViewGroup).setContent(Recomposer.current()) {
MessageScreen(this)
}
return binding.root
}
override fun onNavigationClick() {
requireActivity().onBackPressed()
}
Timo Drick
09/10/2020, 11:05 AMMessageScreen(onNavigaionClick: () -> Unit)
MessageScreen() { onNavigationClick() }
Mehmet Peker
09/10/2020, 11:11 AMTimo Drick
09/10/2020, 11:11 AMMehmet Peker
09/10/2020, 11:18 AMTimo Drick
09/10/2020, 11:19 AMMehmet Peker
09/10/2020, 11:22 AMTimo Drick
09/10/2020, 11:23 AMMehmet Peker
09/10/2020, 11:30 AMTimo Drick
09/10/2020, 11:31 AMoverride fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
return ComposeView(requireContext()).apply {
setContent {
MessageView ...
}
}
Mehmet Peker
09/10/2020, 11:41 AM