Skip to content

Instantly share code, notes, and snippets.

View sagar-viradiya's full-sized avatar
:octocat:
Focusing

Sagar Viradiya sagar-viradiya

:octocat:
Focusing
View GitHub Profile
@sagar-viradiya
sagar-viradiya / ThreadLikePathAnimation.kt
Last active December 17, 2024 14:34
An attampt to implement Threads app like path animation on pull to refresh in Jetpack Compose
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun PullToRefreshAnimation() {
val path = remember {
GitHubLogoPath.path.toPath()
}
val lines = remember {
path.asAndroidPath().flatten(error = 0.5f).toList()
}
@sagar-viradiya
sagar-viradiya / LocationUpdates.kt
Created September 26, 2021 15:14
Example of observing location updates through callback-ktx
viewLifecycleOwner.lifecycleScope.launch {
fusedLocationProviderClient.locationFlow(locationRequest, lifecycleOwner).collect { location ->
// Consume location
}
}
@sagar-viradiya
sagar-viradiya / LocationUpdate.kt
Last active September 26, 2021 15:14
Example of getting last location through callback-ktx
viewLifecycleOwner.lifecycleScope.launch {
val location = fusedLocationProviderClient.awaitLastLocation() // Suspend coroutine
// Use location
}
@sagar-viradiya
sagar-viradiya / internal-test-track-workflow.yml
Last active November 18, 2020 17:30
Workflow for automating production release
name: Internal release
on:
push:
tags:
- '[1-9]+.[0.9]+.[0.9]+'
jobs:
build:
name: Building release app
runs-on: ubuntu-latest
@sagar-viradiya
sagar-viradiya / activity_main.xml
Last active August 17, 2021 17:55
DevFest India 2020 Day 1 - Main Acitvity UI
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/backgroundColor"
tools:context=".MainActivity">
<androidx.core.widget.ContentLoadingProgressBar
@sagar-viradiya
sagar-viradiya / colors.xml
Last active October 18, 2020 17:40
DevFest India 2020 Day 1 - colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#B30000</color>
<color name="colorPrimaryDark">#980304</color>
<color name="colorAccent">#9EBE95</color>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="backgroundColor">#EDEEEE</color>
</resources>
@sagar-viradiya
sagar-viradiya / cheat_sheet.xml
Created October 2, 2020 13:33
Cheat sheet for DevFest 2020
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello world!"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@tools:sample/backgrounds/scenic"/>
@sagar-viradiya
sagar-viradiya / build.gradle
Last active January 3, 2024 22:47
DevFest India 2020 Day 1 - build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.devfest.india.bmsclone"
@sagar-viradiya
sagar-viradiya / internal-app-sharing-workflow.yml
Last active November 15, 2020 12:02
GitHub actions workflow for automating your internal android app distribution on Internal App Sharing
name: Build, Upload to IAS and share on slack.
on:
push:
branches:
# Specify branch from where you are sharing build
- [branch_name]
jobs:
build:
name: Building app
runs-on: ubuntu-latest
@sagar-viradiya
sagar-viradiya / CoroutinesExtensions.kt
Created August 3, 2020 14:24
Kotlin coroutines extensions for switching thread easily
suspend inline fun <T> runOnDefault(crossinline task: suspend () -> T): T {
return withContext(Dispatchers.Default) {
task.invoke()
}
}
suspend inline fun <T> runOnIO(crossinline task: suspend () -> T): T {
return withContext(Dispatchers.IO) {
task.invoke()
}