Skip to content

Instantly share code, notes, and snippets.

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

thiago lopes silva thiagoolsilva

🏠
Working from home
View GitHub Profile
@JvmOverloads
fun joinStrings(
collection: Collection<String>,
separator: String = ","
): String {
val result = StringBuffer()
val firstElement = 0
for((index, word) in collection.withIndex()) {
if(index != firstElement) result.append(separator)
result.append(word)
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
FunWithDefaultValuesKt.joinStrings(Arrays.asList("Thiago", "Lopes", "silva"));
}
}
fun joinStrings(
collection: Collection<String>,
separator: String = ","
): String {
val result = StringBuffer()
val firstElement = 0
for((index, word) in collection.withIndex()) {
if(index != firstElement) result.append(separator)
result.append(word)
}
Espresso.onView(ViewMatchers.withId(R.id.btn_login))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
.perform(ViewActions.click())
.check(ViewAssertions.matches(CustomViewMatchers.withDummyStatus(LoginButton.DummyStatus.ERROR)));
@thiagoolsilva
thiagoolsilva / custom_boundedmatcher
Created August 16, 2017 02:34
Creating a custom matcher to be used on espresso
public static Matcher<View> withDummyStatus(final LoginButton.DummyStatus expectedStatus) {
return new BoundedMatcher<View, LoginButton>(LoginButton.class) {
@Override
public void describeTo(Description description) {
description.appendText("Checking the matcher on received view: ");
description.appendText("with expectedStatus=" + expectedStatus.toString());
}
@Override
@thiagoolsilva
thiagoolsilva / dummy_custom_button
Last active August 16, 2017 02:18
It create a dummy custom button only for be used on an example of my blog
/*
* Copyright (C) 2017 Thiago lopes da Silva
*
* 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
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
final String javaSetFlavourMessage = Constants.BUILD_NAME;
/**
* The constant BUILD_NAME.
*/
public static final String BUILD_NAME = "development";
/**
* The constant BUILD_NAME.
*/
public static final String BUILD_NAME = "production";