Skip to content

Instantly share code, notes, and snippets.

View dtunctuncer's full-sized avatar
💦
psst

dtunctuncer

💦
psst
  • Amsterdam
View GitHub Profile
@fergdev
fergdev / gist:b8255a604b0521c3d0701f8a3733742d
Created September 30, 2023 21:55
M3 - Compose Component Mash
package ferg.componentmash
import android.app.Activity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@jsuryahyd
jsuryahyd / commands.sh
Created September 28, 2023 10:41
disable zscaler on mac
# https://www.atpeaz.com/disable-zscaler-temporarily-on-your-mac/
# disable
sudo launchctl unload /Library/LaunchDaemons/com.zscaler.service.plist && sudo launchctl unload /Library/LaunchDaemons/com.zscaler.tunnel.plist
# Reenable
sudo launchctl load /Library/LaunchDaemons/com.zscaler.service.plist && sudo launchctl load /Library/LaunchDaemons/com.zscaler.tunnel.plist
@ichenhe
ichenhe / NestedScrollableHost.kt
Created October 12, 2020 07:26
Fix parallel scroll with a NestedScrollView inside a ViewPager2
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tfcporciuncula
tfcporciuncula / PdfDownloader.kt
Last active September 8, 2022 06:41
PdfDownloader.kt
class PdfDownloader @Inject constructor(
private val context: Context,
private val yourApi: YourApi
) {
private class DownloadException(message: String, cause: Throwable? = null) : RuntimeException(message, cause)
suspend fun download(url: String, fileName: String): String = withContext(Dispatchers.IO) {
val file = createFile(fileName)
@tfcporciuncula
tfcporciuncula / PdfAdapter.kt
Last active March 19, 2024 11:50
PDF rendering the easy way
class PdfAdapter(
// this would come from the ViewModel so we don't need to recreate it on config change
// and the VM can close it within onCleared()
private val renderer: PdfRenderer,
// this would come from the Activity/Fragment based on the display metrics
private val pageWidth: Int
) : RecyclerView.Adapter<PdfAdapter.ViewHolder>() {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
@jeziellago
jeziellago / send_app_notification_or_deeplink.py
Last active March 2, 2023 02:35
Send android push notification to app or open app from deeplink using ADB (Android Debug Bridge)
@DDihanov
DDihanov / UiExtension.kt
Last active May 26, 2020 10:10
Chain Animate ConstraintLayouts
import android.content.Context
import android.transition.AutoTransition
import android.transition.TransitionManager
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.transition.doOnEnd
//convenience method to animate several constraint layouts one after another
//important to only pass in the constraint layout LAYOUT FILE ids
@enricocid
enricocid / GradientDayLP.kt
Last active February 11, 2020 17:59
Draw gradient LP according to hour of the day
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.os.Handler
import android.service.wallpaper.WallpaperService
import android.util.DisplayMetrics
import android.view.SurfaceHolder
import android.view.WindowManager
import java.util.*
@Suppress("FunctionName")
fun BroadcastReceiverFlow(c: Context, intentFilter: IntentFilter): Flow<Intent> {
return callbackFlow {
val broadcastReceiver = object : android.content.BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
offer(intent)
}
}
c.registerReceiver(broadcastReceiver, intentFilter)
awaitClose { c.unregisterReceiver(broadcastReceiver) }
@rharter
rharter / InjectableActivityScenario.kt
Created July 19, 2019 15:27
An ActivityScenario that allows you to use Dagger Android's automatic, lifecycle based injection without making your Application class `open`, or overriding it in tests.
package com.pixite.pigment.testing
import android.app.Activity
import android.app.Instrumentation
import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle