Skip to content

Instantly share code, notes, and snippets.

View code-schreiber's full-sized avatar

Sebastian Guillen code-schreiber

View GitHub Profile
@tomaszpolanski
tomaszpolanski / logging.kt
Last active February 7, 2021 15:24
RxLogging
@file:Suppress("NOTHING_TO_INLINE")
import android.util.Log
import io.reactivex.*
inline fun <reified T> printEvent(tag: String, success: T?, error: Throwable?) =
when {
success == null && error == null -> Log.d(tag, "Complete") /* Only with Maybe */
success != null -> Log.d(tag, "Success $success")
error != null -> Log.d(tag, "Error $error")
@kmark
kmark / AudioRecordActivity.java
Last active January 4, 2024 11:01
An example of how to read in raw PCM data from Android's AudioRecord API (microphone input, for instance) and output it to a valid WAV file. Tested on API 21/23 on Android and API 23 on Android Wear (modified activity) where AudioRecord is the only available audio recording API. MediaRecorder doesn't work. Compiles against min API 15 and probabl…
/*
* Copyright 2016 Kevin Mark
*
* 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
@kaushikgopal
kaushikgopal / android_lifecycle_recommendations.md
Last active February 2, 2022 07:28
Notes on opportune moments to do "stuff" in the Android Lifecycle
  • In general you want to try and put things in onStart and onStop for logical start and stops.

Activity

onCreate

  • Dagger inject self into graph
  • setContentView(R.layout.xxx)
  • Butterknife.bind(this)
  • RxJava CompositeSubscription.add (if NON UI related work being done)
  • realm = Realm.getDefaultInstance();
@rishabhmhjn
rishabhmhjn / executeShellInGradle
Created November 5, 2014 07:26
Executing shell commands and getting output in gradle
def getVersionName = { ->
def hashStdOut = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = hashStdOut
}
def buildNumberStdOut = new ByteArrayOutputStream()
exec {
commandLine 'echo', "$BUILD_NUMBER"