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 ImageSplitViewer(modifier: Modifier) { | |
val widthTargetState = remember { mutableStateOf(0.dp) } | |
val widthPosition = animateDpAsState( | |
targetValue = widthTargetState.value, | |
animationSpec = tween(durationMillis = 5000) | |
) | |
Box { | |
Image( |
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 Test() { | |
val animationTargetState = remember { mutableStateOf(0f) } | |
val animationState = animateFloatAsState(targetValue = animationTargetState.value) | |
LaunchedEffect(Unit) { | |
delay(2000) | |
// Trigger the animation so does the recomposition in the composable which | |
// the `animationState.value` is read |
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
import kotlinx.coroutines.* | |
import org.junit.Test | |
class CoroutinePlaygroundTest { | |
@Test | |
fun catchingExceptionAroundAsyncCoroutineBuilder_ShouldNotHandleTheException() { | |
val coroutineScope = CoroutineScope(newSingleThreadContext("MyCoroutineScope")) | |
var asyncExceptionHandled = false |
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
runBlocking { | |
launch { | |
// There could be a race condition with the parent coroutine and this nested | |
// runBlocking will block the thread which means nothing in parent will be executed | |
// even if it is an another coroutine | |
runBlocking { | |
launch { | |
hang() | |
} | |
} |
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
<resources> | |
<style name="Theme.StylesNThemes" parent="Theme.AppCompat.DayNight.DarkActionBar"> | |
<item name="colorPrimary">@color/purple_500</item> | |
</style> | |
<style name="MyButton" parent="Widget.AppCompat.Button"> | |
<item name="android:background">@drawable/button_background</item> | |
<item name="android:textColor">@color/white</item> | |
<!-- Setting a theme attribute inside the MyButton style --> | |
<item name="colorPrimary">@color/red</item> |
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
class SingleLineHeaderTextView : AppCompatTextView { | |
private val DEF_STYLE_RES = R.style.Widget_StylesNThemes_TextView_Header_SingleLine | |
// Other view attributes and constructors | |
constructor( | |
context: Context, | |
attrs: AttributeSet, | |
defStyleAttr: Int | |
) : super( |
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
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<TextView | |
style="@style/Widget.StylesNThemes.TextView.Header.SingleLine" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Hello World!" |
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
<resources> | |
<style name="Widget.StylesNThemes.TextView.Header.SingleLine" parent="Widget.MaterialComponents.TextView"> | |
<item name="android:singleLine">true</item> | |
<!-- If we were not using text appearance then we had to set all attributes inside | |
TextAppearance.StylesNThemes.Header here --> | |
<item name="android:textAppearance">@style/TextAppearance.StylesNThemes.Header</item> | |
</style> | |
</resources> |
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
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Hello World!" | |
android:textAppearance="@style/TextAppearance.StylesNThemes.Header" |
NewerOlder