This file contains hidden or 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
android.os.BadParcelableException: Parcelable encountered IOException writing serializable object (name = com.xx.xx.auxiliar.ErrorData) | |
at android.os.Parcel.writeSerializable(Parcel.java:2797) | |
at android.os.Parcel.writeValue(Parcel.java:2563) | |
at android.os.Parcel.writeValue(Parcel.java:2362) | |
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1298) | |
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1843) | |
at android.os.Bundle.writeToParcel(Bundle.java:1389) |
This file contains hidden or 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
fun LazyListState.animateScrollAndCentralizeItem(index: Int, scope: CoroutineScope) { | |
val itemInfo = this.layoutInfo.visibleItemsInfo.firstOrNull { it.index == index } | |
scope.launch { | |
when { | |
itemInfo != null -> { | |
val center = [email protected] / 2 | |
val childCenter = itemInfo.offset + itemInfo.size / 2 | |
[email protected]((childCenter - center).toFloat()) | |
} | |
else -> { |
This file contains hidden or 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
items(rankingUIModel.rankingUIModel.challengeRankingItems) { | |
ItemQualifying(modifier= Modifier.animateItemPlacement( | |
spring( | |
stiffness = Spring.StiffnessVeryLow, | |
visibilityThreshold = IntOffset.VisibilityThreshold | |
) | |
), item = it, onRankingItemPressed = onRankingItemPressed) | |
} |
This file contains hidden or 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
Viewmodel--> | |
private var _data: Channel<PagingData<Event>> = Channel() | |
var data = _data.receiveAsFlow() | |
fun callApiExample(){ | |
usecaseFoo... .collect{ _data.send(it)} | |
} | |
Fragment--> |
This file contains hidden or 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 displayMetrics: DisplayMetrics by lazy { Resources.getSystem().displayMetrics } | |
/** | |
* Returns boundary of the screen in pixels (px). | |
*/ | |
val screenRectPx: Rect | |
get() = displayMetrics.run { Rect(0, 0, widthPixels, heightPixels) } | |
/** | |
* Returns boundary of the screen in density independent pixels (dp). |
This file contains hidden or 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
.background( | |
brush = Brush.verticalGradient( | |
colors = listOf( | |
MaterialTheme.colors.primary, | |
MaterialTheme.colors.primary.copy(0.2f) | |
) | |
) | |
) |
This file contains hidden or 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
@Preview(name = "NEXUS_7", device = Devices.NEXUS_7) | |
@Preview(name = "NEXUS_7_2013", device = Devices.NEXUS_7_2013) | |
@Preview(name = "NEXUS_5", device = Devices.NEXUS_5) | |
@Preview(name = "NEXUS_6", device = Devices.NEXUS_6) | |
@Preview(name = "NEXUS_9", device = Devices.NEXUS_9) | |
@Preview(name = "NEXUS_10", device = Devices.NEXUS_10) | |
@Preview(name = "NEXUS_5X", device = Devices.NEXUS_5X) | |
@Preview(name = "NEXUS_6P", device = Devices.NEXUS_6P) | |
@Preview(name = "PIXEL_C", device = Devices.PIXEL_C) | |
@Preview(name = "PIXEL", device = Devices.PIXEL) |
This file contains hidden or 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
Dispatchers.Default - Uses a thread pool equivalent to number of CPU cores. Should be used for CPU bound workload. | |
Dispatchers.IO - Uses a pool of 64 threads. Ideal for IO bound workload, where the thread is usually waiting; maybe for network request or disk read/write. | |
Dispatchers.Main (Android only): Uses main thread to execute the coroutines. Ideal for updating UI elements. | |
GlobalScope.launch(Dispatchers.IO): Launches a top-level coroutine on Dispatchers.IO. Coroutine is unbound and keeps running until finished or cancelled. Often discouraged since programmer has to maintain a reference to join() or cancel(). |
This file contains hidden or 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 TopAppBar(modifier: Modifier, backgroundColor: Color, onClickProfile: () -> Unit, onSearch: (String) -> Unit) { | |
TopAppBar(title = { | |
Row { | |
Text( | |
text = "AUDI APP STORE", | |
color = MaterialTheme.colors.onPrimary, | |
modifier = Modifier | |
.fillMaxWidth() | |
.height(60.dp) |
This file contains hidden or 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 AnimatedText(text: String, modifier: Modifier, tween: Int = 1000, color: Color, textStyle: TextStyle) { | |
val textScale by rememberInfiniteTransition().animateFloat( | |
initialValue = 0.9f, targetValue = 1f, animationSpec = infiniteRepeatable( | |
animation = tween(tween), repeatMode = RepeatMode.Reverse | |
) | |
) | |
Text( | |
modifier = modifier.scale(textScale), text = text, color = color, style = textStyle | |
) |
NewerOlder