Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Focusing

Mustafa Yiğit mustafayigitt

🚀
Focusing
View GitHub Profile
@mustafayigitt
mustafayigitt / Validator.kt
Created Jun 29, 2022
Validator.Builder example
View Validator.kt
Validator.Builder()
.addRules(
ValidatableRule.Email("Enter valid mail address"),
ValidatableRule.Required("Input is required"),
)
.addCollector {
mBinding.editText.doOnTextChanged { text, _, _, _ ->
inputValidator.input = text.toString()
}
}
View build.gradle
dependencies {
implementation 'com.github.mustafayigitt:validator:Tag'
}
@mustafayigitt
mustafayigitt / build.gradle
Last active Jun 13, 2022
import jitpack project level
View build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
@mustafayigitt
mustafayigitt / BaseDiffCallback.kt
Created Jan 4, 2022
BaseDiffCallback is a item callback for BaseRecyclerAdapter(ListAdapter)
View BaseDiffCallback.kt
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 Jan 4, 2022
BaseComparable is a base class for BaseDiffCallback
View BaseComparable.kt
interface BaseComparable{
val id: String
}
@mustafayigitt
mustafayigitt / GenericBaseRecyclerviewAdapter.kt
Last active Jan 4, 2022
Generic Base Recyclerview Adapter with ViewBinding & Multiple View Click Support
View GenericBaseRecyclerviewAdapter.kt
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 Nov 28, 2021
Collection(Recyclerview)example with Jetpack Compose
View MainActivity.kt
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 Nov 24, 2021
ui with Jetpack Compose
View MainActivity.kt
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
View activity_main.xml
<?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">
View AuthRepositoryTest.kt
package com.packagename.data.repository
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.packagename.BuildConfig
import com.packagename.R
import com.packagename.data.local.AppDatabase
import com.packagename.data.model.AuthModel
import com.packagename.data.preferences.PreferencesManager
import com.packagename.data.remote.response.ResponseRegister
import com.packagename.data.remote.service.AuthService