Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

Sagar Viradiya sagar-viradiya

:octocat:
Focusing
View GitHub Profile
@sagar-viradiya
sagar-viradiya / internal-test-track-workflow.yml
Last active Nov 18, 2020
Workflow for automating production release
View internal-test-track-workflow.yml
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 Aug 17, 2021
DevFest India 2020 Day 1 - Main Acitvity UI
View activity_main.xml
<?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 Oct 18, 2020
DevFest India 2020 Day 1 - colors.xml
View 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 Oct 2, 2020
Cheat sheet for DevFest 2020
View cheat_sheet.xml
<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 Dec 23, 2020
DevFest India 2020 Day 1 - build.gradle file
View build.gradle
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 Nov 15, 2020
GitHub actions workflow for automating your internal android app distribution on Internal App Sharing
View internal-app-sharing-workflow.yml
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 Aug 3, 2020
Kotlin coroutines extensions for switching thread easily
View CoroutinesExtensions.kt
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()
}
View CoroutinesPermissionManager.kt
/**
* A static factory method to request permission from activity.
*
* @param activity an instance of [AppCompatActivity]
* @param requestId Request ID for permission request
* @param permissions Permission(s) to request
*
* @return [PermissionResult]
*
* Suspends the coroutines until result is available.
View LiveDataPermissionManager.kt
/**
* A static method to request permission from activity.
* Your activity must implement [PermissionObserver]
*
* @param activity an instance of [AppCompatActivity] which is also [PermissionObserver]
* @param requestId Request ID for permission request
* @param permissions Permission(s) to request
*
* @throws [IllegalArgumentException] if your activity doesn't implement [PermissionObserver]
*/
View PermissionObserver.kt
/**
* Interface definition for a callback to get [LiveData] of [PermissionResult]
*
* Implement this interface to get [LiveData] for observing permission request result.
*/
interface PermissionObserver {
fun setupObserver(permissionResultLiveData: LiveData<PermissionResult>)
}