This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onStop() { | |
super.onStop() | |
/** | |
* Always unregister to the Android API before the view gets destroyed | |
* -> no memory leak ✅ | |
*/ | |
activity?.unregisterReceiver(localBroadcastReceiver) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseTwoPanelsLeakFragment( | |
private val side: Fragment, | |
private val main: Fragment | |
) : Fragment() { | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
childFragmentManager.beginTransaction().apply { | |
replace(R.id.side_container, side) | |
replace(R.id.main_container, main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RoleManagementLeakFragment( | |
side: Fragment, | |
main: Fragment | |
) : BaseTwoPanelsLeakFragment(side, main) { | |
private val sharedViewModel: SharedViewModel by activityViewModels() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseTwoPanelsSolutionFragment( | |
private val side: WeakReference<Fragment>, | |
private val main: WeakReference<Fragment> | |
) : Fragment() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RoleManagementSolutionFragment( | |
side: WeakReference<Fragment>, | |
main: WeakReference<Fragment> | |
) : BaseTwoPanelsSolutionFragment(side, main) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseTwoPanelsLeakFragment( | |
private val side: Fragment, | |
private val main: Fragment | |
) : Fragment() { | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
childFragmentManager.beginTransaction().apply { | |
replace(R.id.side_container, side) | |
replace(R.id.main_container, main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun CollapsingToolbar() { | |
Box(modifier = Modifier.fillMaxSize()) { | |
Header() | |
Body() | |
Toolbar() | |
Title() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val headerHeight = 275.dp | |
@Composable | |
private fun Header() { | |
val headerHeightPx = with(LocalDensity.current) { headerHeight.toPx() } | |
Box(modifier = Modifier.fillMaxWidth().height(headerHeight)) { | |
Image( | |
painter = painterResource(id = R.drawable.bg_pexel), | |
contentDescription = "", | |
contentScale = ContentScale.FillBounds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun Body() { | |
Column(horizontalAlignment = Alignment.CenterHorizontally) { | |
Spacer(Modifier.height(headerHeight)) | |
repeat(5) { | |
Text( | |
text = stringResource(R.string.lorem_ipsum), | |
style = MaterialTheme.typography.body1, | |
textAlign = TextAlign.Justify, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val scroll: ScrollState = rememberScrollState(0) |