Skip to content

Instantly share code, notes, and snippets.

View mertceyhan's full-sized avatar
🎯
Focusing

Cafer Mert Ceyhan mertceyhan

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