Hi all, how to fixed below error. i am getting it...
# compose
g
Hi all, how to fixed below error. i am getting it on recomposition. android.view.InflateException: Binary XML file line #6 in /fragment_cast_mini_controller: Binary XML file line #6 in /fragment_cast_mini_controller: Error inflating class fragment Caused by: android.view.InflateException: Binary XML file line #6 in layout/fragment cast mini controller Error inflating class fragment Caused by: java.lang.IllegalArgumentException: Binary XML file line #6: Duplicate id 0x7f0a011a, tag miniControllerFragment, or parent id 0xffffffff with another fragment for com.google.android.gms.cast.framework.media.widget.MiniControllerFragment code implementation
Copy code
AndroidViewBinding(factory = { inflater, parent, attachToParent ->
    parent.removeAllViews()
    FragmentCastMiniControllerBinding.inflate(inflater, parent, attachToParent)
}, modifier.fillMaxWidth().wrapContentHeight())
and xml part
Copy code
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="<http://schemas.android.com/apk/res/android>"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <fragment
        android:id="@+id/castMiniController"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:tag="miniControllerFragment"
        android:name="com.google.android.gms.cast.framework.media.widget.MiniControllerFragment"/>

</FrameLayout>
h
did you fix it?
g
yes
Copy code
use DisposableEffect
h
mind sharing the code on what you mean?
g
@Composable fun CastMiniController(modifier: Modifier = Modifier) { val fragmentActivity = LocalContext.current as? FragmentActivity ?: return DisposableEffect(AndroidViewBinding( factory = FragmentCastMiniControllerBinding::inflate, modifier .fillMaxWidth() .wrapContentHeight() .onGloballyPositioned { layoutCoordinates -> fragmentActivity.sendBroadcast( Intent(CAST_MINT_CONTROLLER_HEIGHT_CHANGED_EVENT).apply { putExtra(CAST_MINT_CONTROLLER_HEIGHT, layoutCoordinates.size.height) } ) } )) { onDispose { val fragment = fragmentActivity.supportFragmentManager.findFragmentById(R.id.castMiniController) if (fragment != null) fragmentActivity.supportFragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss() } } }
try it
h
thank you, i will
just one question, these
CAST_MINT_CONTROLLER_HEIGHT_CHANGED_EVENT
are these
CAST_MINT_CONTROLLER_HEIGHT
internal for your app only or?
g
yes this is for my app only
thank you color 1
h
thank you, it works