View TypewriterTextEffect.kt
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
/** | |
* A composable function that displays a text with a typewriter-like effect, revealing characters in chunks. | |
* | |
* @param text The input text to be displayed with the typewriter effect. | |
* @param minDelayInMillis The minimum delay in milliseconds between revealing character chunks, defaults to 10ms. | |
* @param maxDelayInMillis The maximum delay in milliseconds between revealing character chunks, defaults to 50ms. | |
* @param minCharacterChunk The minimum number of characters to reveal at once, defaults to 1. | |
* @param maxCharacterChunk The maximum number of characters to reveal at once, defaults to 5. | |
* @param onEffectCompleted A callback function invoked when the entire text has been revealed. | |
* @param displayTextComposable A composable function that receives the text to display with the typewriter effect. |
View Screen.kt
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
/** | |
* Add this into AndroidManifest.xml to disable the automatic screen views tracker. | |
* | |
* <meta-data | |
* android:name="google_analytics_automatic_screen_reporting_enabled" | |
* android:value="false" /> | |
* */ | |
@Composable | |
fun Screen( |
View WormHorizontalPagerIndicator.kt
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
@ExperimentalPagerApi | |
@Composable | |
fun WormHorizontalPagerIndicator( | |
pagerState: PagerState, | |
modifier: Modifier = Modifier, | |
activeColor: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), | |
inactiveColor: Color = activeColor.copy(ContentAlpha.disabled), | |
indicatorWidth: Dp = 8.dp, | |
activeIndicatorWidth: Dp = 25.dp, | |
indicatorHeight: Dp = indicatorWidth, |
View OverlayBottomSheetScaffold.kt
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
@ExperimentalMaterialApi | |
@Composable | |
fun OverlayBottomSheetScaffold( | |
sheetContent: @Composable ColumnScope.() -> Unit, | |
scaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState(), | |
sheetPeekHeight: Dp = 0.dp, | |
maxOverlayAlpha: Float = 0.7f, | |
overlayColor: Color = Color.Black, | |
cancelable: Boolean = true, | |
content: @Composable (PaddingValues) -> Unit, |
View Anagram.kt
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
object Anagram { | |
fun isAnagram(firstText: String, secondText: String): Boolean { | |
return firstText.sumOf { it.code } == secondText.sumOf { it.code } | |
} | |
} |
View FizzBuzz.kt
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
object FizzBuzz { | |
fun print() { | |
for (i in 1..100) { | |
if ((i.rem(3) == 0) and (i.rem(5) == 0)) { | |
println("FizzBuzz") | |
} else if (i.rem(3) == 0) { | |
println("Fizz") | |
} else if (i.rem(5) == 0) { |
View PalindromeDetector.kt
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
object PalindromeDetector { | |
fun isPalindrome(text: String): Boolean { | |
val content = text.toCharArray() | |
val reversedContent = content.reversedArray() | |
return content.concatToString() == reversedContent.concatToString() | |
} | |
} |
View BubbleSort.kt
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
object BubbleSort { | |
fun sort(array: Array<Int>) { | |
for (i in array.indices) { | |
for (j in 0 until array.size - i - 1) { | |
if (array[j] > array[j + 1]) { | |
swap(array, firstIndex = j, secondIndex = j + 1) | |
} | |
} | |
} |
View build.gradle.kts
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
// Project level build.gradle file | |
subprojects { | |
tasks.withType(Test::class.java) { | |
testLogging { | |
showCauses = false | |
showExceptions = false | |
showStackTraces = false | |
showStandardStreams = false |
View OnOneOffClickListener.kt
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 OnOneOffClickListener(private var defaultInterval: Int, | |
private val onOneClick: (View) -> Unit) : View.OnClickListener { | |
private var lastTimeClicked: Long = 0 | |
override fun onClick(view: View) { | |
if ((SystemClock.elapsedRealtime() - lastTimeClicked) >= (defaultInterval)) { | |
lastTimeClicked = SystemClock.elapsedRealtime() | |
onOneClick(view) | |
} |
NewerOlder