Instantly share code, notes, and snippets.

View jacoco.gradle
project.afterEvaluate {
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type -> type.name }
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
// When no product flavors defined, use empty so that the for loop below can continue.
if (!productFlavors) productFlavors.add('')
productFlavors.each { productFlavorName ->
buildTypes.each { buildTypeName ->
View build and distribute
./gradlew clean
testDebugUnitTest
testDebugUnitTestCoverage
lintStaging
assembleStaging
crashlyticsUploadDistributionStaging
View jenkinsfile.groovy
pipeline {
agent {
node { label 'mobile' }
}
environment {
PATH = "/usr/bin:" +
"/usr/local/bin:" +
"$PATH"
ANDROID_HOME = "/Users/azimoci/dev/android/"
View ExampleNavigator.java
public class CategoryNavigator {
private final CategoryActivity context;
@Inject
public CategoryNavigator(CategoryActivity context) {
this.context = context;
}
public void openContactForm() {
context.startActivity(ContactFormActivity.intent(context, ContactFormActivity.ContactType.EMAIL));
View RxTransformerManager.java
@Singleton
public class RxTransformerManager {
@Inject
public RxTransformerManager() {
}
/**
* Any operator applied before this transformation will be run on io thread
* while any operator applied after will be run on main thread
View tests-results
> water-log@0.2.1 test ...
> mocha --reporter spec
Conversation
actionWelcomeUser
✓ Should create new anonymous user
✓ Should greet new user with audio when screen isnt available
✓ Should greet new user with response and suggestion chips when screen is available
✓ Should greet existing user with name if exists
✓ Should greet existing user with general message if name doesnt exists
View conversation2.js
class Conversation {
//...
_greetNewUser() {
if (this._isScreenAvailable()) {
this._askWithSuggestionChips(Str.GREETING_NEW_USER, Str.GREETING_USER_SUGGESTION_CHIPS)
} else {
this.dialogflowApp.ask(Str.GREETING_NEW_USER, Str.GREETING_NEW_USER_NO_INPUT_PROMPT);
}
View facts-repository.js
class FactsRepository {
//...
getWaterFactRichResponse(waterFact) {
return this.dialogflowApp.buildRichResponse()
.addSimpleResponse(Str.CARD_SIMPLE_RESPONSE)
.addBasicCard(this.dialogflowApp
.buildBasicCard(waterFact.TEXT)
.setTitle(waterFact.TITLE)
.addButton(waterFact.BUTTON, waterFact.LINK)
View conversation.js
class Conversation {
//...
//Intent facts_drinking_water
getFactForDrinkingWater() {
const waterFact = this.factsRepository.getRandomWaterFact();
let speechResponse;
if (this._isScreenAvailable()) {
speechResponse = this.factsRepository.getWaterFactRichResponse(waterFact);
} else {
View actions.js
//assistant-actions.js
module.exports = {
//...
ACTION_FACTS_DRINKING_WATER: 'facts_drinking_water'
};
//index.js
exports.waterLog = functions.https.onRequest((request, response) => {
//...