Skip to content

Instantly share code, notes, and snippets.

@Schadenfeude
Schadenfeude / ExampleUsage.swift
Last active October 12, 2023 15:03
Easy onSwipe extension for Swift Views
import SwiftUI
// Example usage
let canDelete = true
let rowId = UUID().uuidString
HStack {
Text("Some row we want to swipe")
}.onSwipe(
isEnabled: canDelete,
# Contributed by PracticalChip
# Project home page https://github.com/PracticalChip/Adblocking
# This was added at the request of the developer of Diversion
steamcdn-a.akamaihd.net
media.steampowered.com
media4.steampowered.com
aax-eu.amazon-adsystem.com # whitelisted for smallnetbuilder.com
aax-us-east.amazon-adsystem.com # whitelisted for smallnetbuilder.com
@Schadenfeude
Schadenfeude / ConnectivityMonitor.kt
Created April 11, 2023 11:52
Connectivity Monitor (Android)
interface ConnectivityMonitor {
val isConnected: Boolean
val networkType: NetworkType
val isConnectedState: Flow<Boolean>
val networkTypeState: Flow<NetworkType>
}
@Schadenfeude
Schadenfeude / KeyboardHeightProvider.kt
Created March 2, 2022 10:30
Provides the height of the keyboard
class KeyboardHeightProvider(activity: Activity) : PopupWindow(activity),
OnGlobalLayoutListener {
private val mActivity: Activity = activity
private val rootView: View = View(activity)
// Record the maximum height of the pop content area
private var heightMax = 0
private val mutHeightChanged = MutableStateFlow(0)
val onHeightChanged: StateFlow<Int> = mutHeightChanged
@Schadenfeude
Schadenfeude / Kotlin RecylcerView Adapter.kt
Last active August 20, 2020 16:22
Live Template for RecyclerView Adapter with ListAdapter
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.dronesense.pilotkit.common.extension.inflate
#parse("File Header.java")
@Schadenfeude
Schadenfeude / asl_drawer
Created April 24, 2020 11:41
Drawer (≡) to close (x) animated vector drawable
<?xml version="1.0" encoding="utf-8"?>
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/open"
android:drawable="@drawable/ic_drawer_closed"
android:state_selected="true"/>
<item
android:id="@+id/closed"
android:drawable="@drawable/ic_drawer"/>
@Schadenfeude
Schadenfeude / .gitignore
Created July 29, 2019 10:45
Top level .gitignore for Android projects
*.iml
.idea/
.gradle/
build/
local.properties
.DS_Store
captures
.externalNativeBuild
@Schadenfeude
Schadenfeude / app.build.gradle
Last active May 15, 2023 12:08
Gradle configuration for better dependency management in a multi-module project
apply plugin: 'com.android.application'
apply from: "$rootDir/common.gradle"
apply plugin: 'androidx.navigation.safeargs.kotlin'
android {
defaultConfig {
applicationId app_config.app_id
setProperty("archivesBaseName", app_config.archive_file)
}
@Schadenfeude
Schadenfeude / Jenkinsfile
Last active March 18, 2024 00:25
Example Jenkinsfile declarative pipeline for Android projects
pipeline {
agent {
// Run on a build agent where we have the Android SDK installed
label 'android'
}
environment {
// Fastlane Environment Variables
PATH = "$HOME/.fastlane/bin:" +
"$HOME/.rvm/gems/ruby-2.5.3/bin:" +
"$HOME/.rvm/gems/ruby-2.5.3@global/bin:" +
@Schadenfeude
Schadenfeude / RetryApiCall.kt
Last active January 17, 2019 13:54
RxKotlin retryWhen & takeUntil example
companion object {
private const val COUNTER_START = 1
private const val MAX_ATTEMPTS = 5
private const val ORIGINAL_DELAY_IN_SECONDS = 2L
}
//Not important
val transactionJson = JsonObject().apply { addProperty(TRANSACTION_ID, transactionId) }
var disposable: Disposable? = null