Skip to content

Instantly share code, notes, and snippets.

View PrashamTrivedi's full-sized avatar
🏠
Working from home

Prasham Trivedi PrashamTrivedi

🏠
Working from home
View GitHub Profile
@LouisCAD
LouisCAD / LifecycleCoroutines.kt
Last active July 3, 2022 11:47
CoroutineScope and Job integration with Lifecycle for Android. Meant to be used for your coroutines in lifecycle aware components. OUTDATED. See up to date implementation here: https://github.com/LouisCAD/Splitties/tree/master/modules/lifecycle-coroutines
import android.arch.lifecycle.GenericLifecycleObserver
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY
import android.arch.lifecycle.LifecycleOwner
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job {
@alexjlockwood
alexjlockwood / ObjectAnimatorCompat.java
Last active January 1, 2018 10:52
ObjectAnimator motion along a path for pre-Lollipop devices (https://j.mp/object-animator-path-motion)
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@CodingDoug
CodingDoug / README.md
Last active October 3, 2020 20:18
Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

If you're trying to do this, you came to the right place!

Watch this code work in real time: https://twitter.com/CodingDoug/status/945035556555186176

Setup

These instructions assume that you already have a Firebase project, and billing is enabled. Billing is required to use the Vision API.

@android10
android10 / README.md
Last active November 29, 2020 00:50
Keep a FORKED repository synced with UPSTREAM on Github

Configure a remote that points to the upstream repository in Git.

  • List the current configured remote repository for your fork.
git remote -v
origin  git@github.com:YOUR_USERNAME/YOUR_FORK.git (fetch)
origin  git@github.com:YOUR_USERNAME/YOUR_FORK.git (push)
<scheme name="Material Dark" version="142" parent_scheme="Darcula">
<!--
1. Install the Roboto Mono Regular font - https://fonts.google.com/specimen/Roboto+Mono?selection.family=Roboto+Mono
2. Copy `Material Dark.icls` to `~/Library/Preferences/AndroidStudio3.0/colors/`
3. Restart AS
4. Preferences > Editor > Color and Fonts > select Material Dark and press OK
-->
<option name="FONT_SCALE" value="1.0" />
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active September 28, 2023 15:01
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 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
#!/bin/sh
# Copy templates to Android Studio in default location
TMP_PATH=`pwd`
TEMPLATES_PATH="/Applications/Android Studio.app/Contents/plugins/android/lib/templates/other"
DIRS=`find $TMP_PATH -type d -maxdepth 1 -not -name '.*' -not -path $TMP_PATH`
for f in $DIRS
@donnfelker
donnfelker / config
Last active November 19, 2019 11:28
Watch or Unwatch a file in git
# Goes in your .git/config file
[alias]
# Temporarily stop tracking a file in git.
# usage: git unwatch path/to/file
unwatch = update-index --assume-unchanged
# Resume tracking a file in git.
# usage: git watch path/to/file
watch = update-index --no-assume-unchanged
@ValCanBuild
ValCanBuild / drawer_layout_preview.xml
Created September 10, 2015 09:35
Android preview DrawerLayout NavigationView
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
@chanakin
chanakin / build.gradle
Last active June 28, 2022 20:44
Gradle Build file that creates different "apps" based on the build type, letting you load apps side-by-side (beta vs. production)
apply plugin: 'com.android.application'
def final yourApplicationId = 'com.yourId.android'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
sourceSets {
androidTest {
java.srcDirs = ['test/java']
}
}