Skip to content

Instantly share code, notes, and snippets.

View dlew's full-sized avatar

Daniel Lew dlew

View GitHub Profile
RetrofitService.doTheThing(params) // Your typical API call
.subscribeOn(Schedulers.io()) // Execute API call on IO thread
.observeOn(AndroidSchedulers.mainThread()) // Execute observers on Android's main thread
.subscribe(results -> handle(results)); // Handling the results of the API call
public class LazyListManagerUtils {
public static <T> List<T> add(List<T> list, T item) {
if (list == null) {
list = new ArrayList<T>();
list.add(item);
}
else if (!list.contains(item)) {
list.add(item);
}
@dlew
dlew / gist:3100299
Created July 12, 2012 19:23
Easier findVewById()
@SuppressWarnings("unchecked")
public static <T extends View> T findView(Activity activity, int id) {
return (T) activity.findViewById(id);
}
@SuppressWarnings("unchecked")
public static <T extends View> T findView(View view, int id) {
return (T) view.findViewById(id);
}