Skip to content

Instantly share code, notes, and snippets.

View zeeshanrasool91's full-sized avatar
💭
Feeling progamming :)

Zeeshan rasool zeeshanrasool91

💭
Feeling progamming :)
View GitHub Profile
@preetham1316
preetham1316 / HomeFragment.kt
Created August 4, 2023 05:50
Sticky Header with Click Listeners for Recycler View
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.stickyheader.databinding.FragmentHomeListBinding
import com.example.stickyheader.header.StickyHeaderItemDecorator
import com.example.stickyheader.model.ItemModel
@LinX64
LinX64 / BaseListAdapter.kt
Created October 26, 2022 20:37
BaseListAdapter for ListAdapters
import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.LinearLayout.LayoutParams
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
abstract class BaseListAdapter<T : Any, VB : ViewBinding> :
@thasneemp
thasneemp / AndroidEditText.kt
Last active May 13, 2025 08:13
Android EditText text change with flow coroutine debounce
fun EditText.textChanges(): Flow<String> {
return callbackFlow {
val listener = doOnTextChanged { text, _, _, _ -> trySend(text.toString()) }
awaitClose { removeTextChangedListener(listener) }
}.onStart { emit(text.toString()) }
}
private fun searchQuery(searchQuery: String): Flow<List<String>> {
val items = listOf("Hello", "How are You", "Oh no!", "Iam Good!")
return flow {
@akndmr
akndmr / BaseViewBindingFragment.kt
Created February 23, 2022 23:27
BaseFragment for ViewBinding, BaseViewBinding
abstract class BaseFragment<VB: ViewBinding, VM : BaseViewModel>(
private val bindingInflater: (LayoutInflater) -> VB
) : Fragment() {
private var _binding: VB? = null
open val binding: VB
get() = _binding as VB
override fun onCreateView(
@tai-nguyen2112
tai-nguyen2112 / HeaderItemDecoration.kt
Last active October 17, 2024 09:22 — forked from filipkowicz/HeaderItemDecoration.kt
Sticky header for RecyclerView, Item Decorator for sticky headers in Kotlin
package com.filipkowicz.headeritemdecorator
/*
solution based on - based on Sevastyan answer on StackOverflow
changes:
- take to account views offsets
- transformed to Kotlin
- now works on viewHolders
@dkexception
dkexception / BaseFragment.kt
Created January 11, 2022 18:20
Base fragment class with ViewBinding supported by default, and a special support to BaseViewModel
typealias Inflate<T> = (LayoutInflater, ViewGroup?, Boolean) -> T
abstract class BaseFragment<VB : ViewBinding, VM : BaseViewModel>(
private val inflate: Inflate<VB>
) : Fragment() {
private var _binding: VB? = null
val binding get() = _binding!!
protected abstract val viewModel: VM
@nphausg
nphausg / GsonExtensions.kt
Created May 27, 2021 06:00
GsonExtensions.kt
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import java.lang.reflect.Type
// region [G-SON]
val gSon: Gson by lazy { GsonBuilder().disableHtmlEscaping().create() }
fun Any?.toJson(): String = gSon.toJson(this)
@yogacp
yogacp / AbstractAdapter.kt
Last active September 12, 2023 11:53
Recyclerview that use Abstract Adapter and viewbinding
/**
* Create the Abstract Adapter and the ViewHolder that we need to hold the item view
*/
abstract class AbstractAdapter<T : ViewBinding, ITEM> constructor(
protected var itemList: List<ITEM>,
private val bindingClass: (LayoutInflater, ViewGroup, Boolean) -> T
) : RecyclerView.Adapter<AbstractAdapter.Holder>() {
var binding: T? = null
@EugeneTheDev
EugeneTheDev / DotsLoaders.kt
Created March 18, 2021 23:15
Dots loading animations with Jetpack Compose
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@fergusonm
fergusonm / gist:88a728eb543c7f6727a7cc473671befc
Last active October 28, 2023 20:01
launchWhenX dropping events
class MainFragment : Fragment(R.layout.main_fragment) {
companion object {
fun newInstance() = MainFragment()
}
private lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {