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) | |
} |
View RSAEncryptionHelper.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
import android.util.Base64 | |
import java.security.KeyFactory | |
import java.security.PrivateKey | |
import java.security.PublicKey | |
import java.security.spec.PKCS8EncodedKeySpec | |
import java.security.spec.X509EncodedKeySpec | |
import javax.crypto.Cipher | |
/** | |
* |