Skip to content

Instantly share code, notes, and snippets.

View mustafayigitt's full-sized avatar
🚀
Focusing

Mustafa Yiğit mustafayigitt

🚀
Focusing
View GitHub Profile
@mustafayigitt
mustafayigitt / MainActivity.kt
Created March 24, 2024 20:33
basic notification
package com.ytapps.myapplication
import android.Manifest
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
@mustafayigitt
mustafayigitt / Validator.kt
Created June 29, 2022 11:51
Validator.Builder example
Validator.Builder()
.addRules(
ValidatableRule.Email("Enter valid mail address"),
ValidatableRule.Required("Input is required"),
)
.addCollector {
mBinding.editText.doOnTextChanged { text, _, _, _ ->
inputValidator.input = text.toString()
}
}
@mustafayigitt
mustafayigitt / build.gradle
Created June 13, 2022 08:10
Import validator
dependencies {
implementation 'com.github.mustafayigitt:validator:Tag'
}
@mustafayigitt
mustafayigitt / build.gradle
Last active June 13, 2022 08:09
import jitpack project level
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
@mustafayigitt
mustafayigitt / BaseDiffCallback.kt
Created January 4, 2022 13:05
BaseDiffCallback is a item callback for BaseRecyclerAdapter(ListAdapter)
import androidx.recyclerview.widget.DiffUtil
class BaseDiffCallback<T : BaseComparable> : DiffUtil.ItemCallback<T>() {
override fun areItemsTheSame(oldItem: T, newItem: T) =
oldItem.id == newItem.id
override fun areContentsTheSame(oldItem: T, newItem: T) =
oldItem.equals(newItem)
}
@mustafayigitt
mustafayigitt / BaseComparable.kt
Created January 4, 2022 13:04
BaseComparable is a base class for BaseDiffCallback
interface BaseComparable{
val id: String
}
@mustafayigitt
mustafayigitt / GenericBaseRecyclerviewAdapter.kt
Last active January 4, 2022 13:03
Generic Base Recyclerview Adapter with ViewBinding & Multiple View Click Support
abstract class BaseRecyclerAdapter<T : BaseComparable, VB : ViewBinding>(
private inline val bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> VB,
private inline val onBind: (item: T, binding: VB) -> Unit,
private inline val actions: (VB) -> List<Pair<View, (T) -> Unit>>,
) : ListAdapter<T, BaseRecyclerAdapter<T, VB>.BaseViewHolder>(BaseDiffCallback<T>()) {
inner class BaseViewHolder(
val binding: VB
) : RecyclerView.ViewHolder(binding.root) {
@mustafayigitt
mustafayigitt / MainActivity.kt
Created November 28, 2021 14:02
Collection(Recyclerview)example with Jetpack Compose
val context = LocalContext.current
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 24.dp),
verticalArrangement = Arrangement.spacedBy(20.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
@mustafayigitt
mustafayigitt / MainActivity.kt
Created November 24, 2021 10:36
ui with Jetpack Compose
val scrollState = rememberScrollState()
val scope = rememberCoroutineScope()
var selectedAnimal by remember { mutableStateOf<Animal?>(null) }
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(scrollState),
verticalArrangement = Arrangement.spacedBy(20.dp),
horizontalAlignment = Alignment.CenterHorizontally
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">