This file contains hidden or 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 <T1, T2, T3, R> asyncCombineLatest(o1: Observable<T1>, | |
o2: Observable<T2>, | |
o3: Observable<T3>, | |
asyncCombineFunc: (T1, T2, T3) -> Observable<R>): Observable<R> = | |
Observable.combineLatest(o1, o2, o3, | |
Function3<T1, T2, T3, Observable<R>> { t1, t2, t3 -> asyncCombineFunc(t1, t2, t3) } | |
).flatMap { it } |
This file contains hidden or 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
public class MainActivity extends AppCompatActivity { | |
private Toolbar toolbar; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
setupToolbar(); | |
} |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical"> | |
<android.support.v4.widget.NestedScrollView | |
android:id="@+id/nested_scrollview" | |
android:layout_width="match_parent" |
This file contains hidden or 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/bash | |
# adb must be running in root mode to broadcast intents | |
adb -e root | |
adb -e shell settings put global airplane_mode_on 1 | |
# radios won't actually turn off until this is broadcasted | |
adb -e shell am broadcast -a android.intent.action.AIRPLANE_MODE |
This file contains hidden or 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
/** | |
* Add this to (e.g.) an EditText via addTextChangedListener() to only allow user input that | |
* is accepted by the supplied predicate. | |
* | |
* e.g. | |
* emailEditText.addTextChangedListener(PredicateTextWatcher({ presenter.isValidEmail(it) }) | |
* | |
* Inspired by original Java code here: http://stackoverflow.com/a/11545229/1405990 | |
*/ | |
class PredicateTextWatcher(val predicate : (String) -> Boolean) : TextWatcher { |
This file contains hidden or 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
/** | |
* Add this to (e.g.) an EditText via addTextChangedListener() to prevent any user input | |
* that doesn't match its supplied regex. | |
* | |
* Inspired by original Java code here: http://stackoverflow.com/a/11545229/1405990 | |
*/ | |
class RegexMaskTextWatcher(regexForInputToMatch : String) : TextWatcher { | |
private val regex = Pattern.compile(regexForInputToMatch) | |
private var previousText: String = "" |
This file contains hidden or 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
/** | |
* Asynchronous equivalent of filterNotNull in Kotlin's stdlin (kotlin.collections) | |
*/ | |
fun <T> Observable<T?>.filterNotNull() : Observable<T> { | |
return this.filter { item -> item != null }.map { it!! } | |
} |
This file contains hidden or 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
function kill_one_ps() { | |
ps -A | grep $1 | egrep -m1 -o '^\d+' | xargs kill -9 | |
} | |
function kill_all_ps() { | |
ps -A | grep $1 | egrep -o '^\d+' | xargs kill -9 | |
} | |
# aliases | |
alias kill_adb="kill_all_ps Genymotion ; kill_one_ps 'adb.*server'" |