Skip to content

Instantly share code, notes, and snippets.

@wing-tree
wing-tree / LegacyHomePressed.kt
Last active November 19, 2024 17:50
Legacy code used to detect Android Home and Recent keys pressed.
import android.content.Intent
import androidx.annotation.CallSuper
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.coroutineScope
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@wing-tree
wing-tree / SwipeToReveal.kt
Created October 6, 2023 10:10
Android Jetpack Compose SwipeToReveal
enum class RevealValue {
Hidden,
Revealed
}
class RevealState(
revealedWidth: Float,
positionalThreshold: (Float) -> Float = {
it.times(0.5f)
},
@wing-tree
wing-tree / BillingDelegateImpl
Created March 29, 2022 10:08
BillingDelegateImpl
import android.app.Activity
import android.content.Context
import com.android.billingclient.api.*
import com.wing.tree.n.back.training.domain.util.`is`
import com.wing.tree.n.back.training.presentation.constant.Sku
import timber.log.Timber
object BillingDelegateImpl : BillingDelegate {
private val consumableSkusList = listOf<String>()
private val skusList = listOf(Sku.REMOVE_ADS)
@wing-tree
wing-tree / BillingDelegate
Last active March 29, 2022 10:07
BillingDelegate
import android.app.Activity
import android.content.Context
import com.android.billingclient.api.BillingClient
import com.android.billingclient.api.SkuDetails
interface BillingDelegate {
fun build(context: Context)
fun endConnection()
fun launchBillingFlow(activity: Activity, skuDetails: SkuDetails)
fun queryPurchasesAsync(skuType: String = BillingClient.SkuType.INAPP)