Skip to content

Instantly share code, notes, and snippets.

View kwong93's full-sized avatar

Kevin Wong kwong93

View GitHub Profile
@kwong93
kwong93 / gist:b11a80ab982c8fd2992dc46061007357
Created February 16, 2017 19:38
RxJava flatMap single
/**
* Do 1 heavy operation, when successful, fire 2 more heavy operations sequentially that use the first operation's data
*/
private List<String> getHeavyList() {
List<String> list = new ArrayList<>();
list.add("First string");
list.add("Second string");
list.add("Third string");
@kwong93
kwong93 / gist:66dfcad029578bfc4780548f540a0533
Last active February 15, 2017 21:46
rxjava:2.0.6, rxandroid:2.0.1
private List<String> getHeavyList() {
List<String> list = new ArrayList<>();
list.add("First string");
list.add("Second string");
list.add("Third string");
return list;
}
@kwong93
kwong93 / gist:3dcea9f4207a85842ada1bb1b680f798
Last active October 7, 2017 00:49
Show or hide Android soft keyboard
public static void hideKeyboard(Context context, View view) {
getInputMethodManager(context).hideSoftInputFromWindow(view.getWindowToken(), 0);
}
public static void showKeyboard(Context context, View view) {
getInputMethodManager(context).showSoftInput(view, 0);
}
public static InputMethodManager getInputMethodManager(Context context) {
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);