Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Cafer Mert Ceyhan mertceyhan

🎯
Focusing
View GitHub Profile
@mertceyhan
mertceyhan / Screen.kt
Created Dec 4, 2022
A base screen composable to send screen view event.
View Screen.kt
/**
* 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
@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
@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,
@mertceyhan
mertceyhan / Anagram.kt
Created Feb 1, 2022
Answer of classic anagram question with Kotlin
View Anagram.kt
object Anagram {
fun isAnagram(firstText: String, secondText: String): Boolean {
return firstText.sumOf { it.code } == secondText.sumOf { it.code }
}
}
@mertceyhan
mertceyhan / FizzBuzz.kt
Created Jan 31, 2022
Answer of classic fizzbuzz question with Kotlin
View FizzBuzz.kt
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) {
@mertceyhan
mertceyhan / PalindromeDetector.kt
Created Jan 31, 2022
Answer of classic palindrome question with Kotlin
View PalindromeDetector.kt
object PalindromeDetector {
fun isPalindrome(text: String): Boolean {
val content = text.toCharArray()
val reversedContent = content.reversedArray()
return content.concatToString() == reversedContent.concatToString()
}
}
@mertceyhan
mertceyhan / BubbleSort.kt
Created Jan 13, 2022
Bubble Sort in Kotlin
View BubbleSort.kt
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)
}
}
}
@mertceyhan
mertceyhan / build.gradle.kts
Last active Nov 5, 2021
A logger for Gradle local unit test runner command
View build.gradle.kts
// Project level build.gradle file
subprojects {
tasks.withType(Test::class.java) {
testLogging {
showCauses = false
showExceptions = false
showStackTraces = false
showStandardStreams = false
View OnOneOffClickListener.kt
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)
}
@mertceyhan
mertceyhan / RSAEncryptionHelper.kt
Last active Dec 14, 2022
This class helps to you for in RSA encryption and decryption operation in Kotlin.
View RSAEncryptionHelper.kt
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
/**
*