Skip to content

Instantly share code, notes, and snippets.

import android.content.Context
import android.widget.ArrayAdapter
import android.widget.Filter
import androidx.annotation.LayoutRes
open class NoFilterArrayAdapter<T>(context: Context, @LayoutRes resource: Int, items: List<T>) :
ArrayAdapter<T>(context, resource, items) {
override fun getFilter(): Filter {
@khaledahmedelsayed
khaledahmedelsayed / LoadMore.Kt
Last active March 3, 2024 17:55
Load More (Pagination) ListAdapter and RecyclerView
/**
* Use these classes to implement pagination without paging libs
*/
import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
@khaledahmedelsayed
khaledahmedelsayed / Extensions.kt
Last active July 17, 2024 14:35
Kotlin useful extensions
/**
* Kotlin extensions you can use in any project that solves common problems in Android
*/
fun Checkable.setOnCheckableSafeClick(view: View, listener: () -> Unit) {
view.setOnTouchListener { _, event ->
if (event.action == MotionEvent.ACTION_UP)
listener()
true
@khaledahmedelsayed
khaledahmedelsayed / FileSelectorHelper.kt
Last active March 3, 2024 17:58
File Selector Helper
/**
* You can use this helper class in your fragment using composition to select files from gallery/camera
*/
import android.Manifest
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
@khaledahmedelsayed
khaledahmedelsayed / FileMultipleSelectorHelper.kt
Created March 3, 2024 11:32
File Multiple Selector Helper
import android.Manifest
import android.net.Uri
import android.os.Build
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.Fragment
class FileMultipleSelectorHelper(
fragment: Fragment,
# =============================
# Fastlane CI/CD Example (Sanitized Template)
# This Fastfile was adapted from a production Android app and sanitized for public sharing.
# Replace placeholders like `MyApp`, `@team`, package name, and environment variable names with your own values.
# All sensitive data (keystores, service account JSON, app/package IDs, Slack webhook) must be supplied via
# environment variables / GitHub Actions secrets – never commit them.
# Use `bundle install` then always run lanes with `bundle exec fastlane <lane>`.
# =============================
# Make sure to have bundler and fastlane installed and then run "bundle install", and always use "bundle exec" not fastlane directly