Skip to content

Instantly share code, notes, and snippets.

View wajahatkarim3's full-sized avatar
:octocat:
Subscribe to my newsletter: remotekaro.substack.com

Wajahat Karim wajahatkarim3

:octocat:
Subscribe to my newsletter: remotekaro.substack.com
View GitHub Profile
@qamarelsafadi
qamarelsafadi / OnBackPressedAlternativeWay.kt
Last active April 4, 2023 10:09
OnBackPressed Alternative way for fragments and activities
/* ----------------------------------------- Activity ------------------------------------------ */
/* make sure you have at least 'androidx.activity:activity-ktx:1.6.0-rc01' at your dependencies
(just to let you know this dependency is not stable yet )
*/
implementation 'androidx.activity:activity-ktx:1.6.0-rc01'
fun AppCompatActivity.onBackPressed(isEnabled: Boolean, callback: () -> Unit) {
onBackPressedDispatcher.addCallback(this,
@qamarelsafadi
qamarelsafadi / NewMenuApiImplementation.kt
Last active January 19, 2024 12:52
This gist will help you to get started with the new menu implementation way, you can find 2 extensions that will help you not repeat a huge code, Enjoy it.
// Step 1 : implement the new activity dependency in you gradle
implementation 'androidx.activity:activity-ktx:1.5.1'
// if you are using compose
implementation 'androidx.activity:activity-compose:1.5.1'
/* ---------------------------------------------- Activity Extension -------------------------------------------------------*/
fun AppCompatActivity.bindMenu(
@MenuRes menuRes: Int,
@c5inco
c5inco / SwipeableCards.kt
Last active April 21, 2024 13:06
Jetpack Compose implementation of inspiration: https://twitter.com/philipcdavis/status/1534192823792128000
package des.c5inco.cardswipecompose
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.calculateTargetValue
import androidx.compose.animation.core.keyframes
import androidx.compose.animation.splineBasedDecay
@c5inco
c5inco / ChainedSpring.kt
Last active March 17, 2024 17:32
Jetpack Compose implementation of inspiration: https://twitter.com/amos_gyamfi/status/1496487449735872526
package des.c5inco.material3
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.spring
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Surface
@Kashif-E
Kashif-E / proguard_rules.pro
Last active March 27, 2024 06:24
This gist contains almost all the pro guard rules that you will ever need for R8
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
package com.shreyaspatil.callbackflownetwork
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.MutableStateFlow
@wertgit
wertgit / ReminderWorker
Created November 27, 2019 06:53
ReminderWorker
import android.R
import android.annotation.SuppressLint
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import androidx.core.app.NotificationCompat
import androidx.work.*
import org.koin.core.KoinComponent
import org.koin.core.inject
@wertgit
wertgit / CustomSwipeToRefresh.kt
Created November 22, 2019 03:27
A Customed SwipeRefreshLayout that handles swiping issues with a RecyclerView inside a SwipeRefreshLayout. It also works for HorizontalScrollView.
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.ViewConfiguration
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import kotlin.math.abs
/**
@tatianamac
tatianamac / tatiana-mac-speaker-rider.md
Last active March 24, 2024 12:22
Tatiana Mac's Speaker Rider

Speaker Rider

by Tatiana Mac

Last updated 14 April 2021

What is a speaker rider?

As speaking comes with immense privilege, I have crafted a speaker rider to set expectations and boundaries around my engagement. I am grateful to all the conference organisers who have brilliantly hosted me. I would love to continue to exercise this privilege to speak at conferences, and use this privilege to make the landscape more accessible and beneficial to tech's most historically excluded and marginalised communities.

Considerations

😫 I provide a lot of explanations for those of you who never had to consider these things. Most thoughtful conferences I've attended check most of these boxes intrinsically, particularly when conference runners are experienced speakers. They get it.

@RubyLichtenstein
RubyLichtenstein / PainlessFragmentArguments.md
Last active February 11, 2021 00:40
Painless android fragments with Kotlin

Starting new fragments with Kotlin is easy

Example

val user = User(id = "id", name = "Ruby")
val userFragment: UserFragment = newFragment<User, UserFragment>(user)

How this magic works