Inspired by Jason Rudolph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> Flowable<T>.doOnFirst(onFirstAction: (T) -> Unit): Flowable<T> = | |
take(1) | |
.doOnNext { onFirstAction.invoke(it) } | |
.concatWith(skip(1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple cache | |
// h/t Matthew Good: Android United slack channel | |
fun <T> MutableList<T>.addCache(new: T, max: Int) { | |
if (max == size) { | |
this.remove(this.last()) | |
this.add(new) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The dialog returned by ShadowDialog.getLatestDialog() does not expose much for testing. | |
* However, getting an AlertDialog shadow can help. | |
*/ | |
@RunWith(RobolectricTestRunner::class) | |
class WebLoginActivityTest { | |
private lateinit var activity: SomeActivity | |
@Before |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.v7.widget.CardView | |
android:id="@+id/cardView" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
app:cardCornerRadius="0dp" | |
app:cardElevation="4dp"> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (1) Defer to the support actionbar | |
// Set the toolbar to be the support actionbar of an AppCompatActivity | |
// ... | |
setSupportActionBar(find(R.id.toolbar)) | |
with(supportActionBar!!) { | |
setDisplayHomeAsUpEnabled(true) | |
setDisplayShowHomeEnabled(true) | |
} | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# dependencies | |
echo "Installing dependencies via Homebrew (http://brew.sh)" | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
brew update | |
brew install gcc48 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.google.ara.app.manager.util; | |
import java.util.List; | |
public final class ModuleNameJoiner { | |
private ModuleNameJoiner() { } | |
private static final String DEFAULT_SEPARATOR = ", "; | |
public static String join(List<String> moduleNames, String conjoiner) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adjust the touchable area of a view. | |
*/ | |
public static void LayoutHelper adjustTouchableArea(View view, View parent, TouchDelegateSizer sizer) { | |
parent.post(new Runnable() { | |
@Override | |
public void run() { | |
Rect r = new Rect(); | |
view.getHitRect(r); | |
parent.setTouchDelegate(new TouchDelegate(sizer.adjustTouchableArea(r), view)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2013 Square, Inc. | |
* | |
* 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 |